fixing most whitespace issues, reordering namespaces and adding in headers (#5677)

This commit is contained in:
Clint Rutkas
2020-08-05 14:06:55 -07:00
committed by GitHub
parent 92a2b83bc8
commit ff69f6ed7f
72 changed files with 942 additions and 624 deletions

View File

@@ -1,4 +1,8 @@
namespace Wox.Plugin
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Wox.Plugin
{
public class ActionContext
{
@@ -8,8 +12,11 @@
public class SpecialKeyState
{
public bool CtrlPressed { get; set; }
public bool ShiftPressed { get; set; }
public bool AltPressed { get; set; }
public bool WinPressed { get; set; }
}
}
}

View File

@@ -1,4 +1,8 @@
namespace Wox.Plugin
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Wox.Plugin
{
public static class AllowedLanguage
{
@@ -18,4 +22,4 @@
|| language.ToUpper() == Executable.ToUpper();
}
}
}
}

View File

@@ -1,7 +1,9 @@
using System;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using JetBrains.Annotations;
namespace Wox.Plugin
@@ -16,4 +18,4 @@ namespace Wox.Plugin
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}

View File

@@ -1,9 +1,12 @@
using System;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Windows.Input;
namespace Wox.Plugin
{
public class ContextMenuResult
{
public string PluginName { get; set; }
@@ -28,4 +31,4 @@ namespace Wox.Plugin
return Title;
}
}
}
}

View File

@@ -1,9 +1,14 @@
using System.Windows;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Windows;
using System.Windows.Input;
namespace Wox.Plugin
{
public delegate void WoxKeyDownEventHandler(WoxKeyDownEventArgs e);
public delegate void AfterWoxQueryEventHandler(WoxQueryEventArgs e);
public delegate void ResultItemDropEventHandler(Result result, IDataObject dropObject, DragEventArgs e);
@@ -11,6 +16,7 @@ namespace Wox.Plugin
public class WoxKeyDownEventArgs
{
public string Query { get; set; }
public KeyEventArgs keyEventArgs { get; set; }
}

View File

@@ -1,6 +1,9 @@
using System;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
namespace Wox.Plugin
{

View File

@@ -1,4 +1,8 @@
using System;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace Wox.Plugin.Features
{
@@ -6,4 +10,4 @@ namespace Wox.Plugin.Features
"and use Wox.Plugin.Feature.IContextMenu instead, " +
"this method will be removed in v1.3.0")]
public interface IContextMenu { }
}
}

View File

@@ -1,4 +1,8 @@
using System;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace Wox.Plugin.Features
{

View File

@@ -1,4 +1,8 @@
using System;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace Wox.Plugin.Features
{
@@ -6,4 +10,4 @@ namespace Wox.Plugin.Features
"and use Wox.Plugin.Feature.IInstantQuery instead, " +
"this method will be removed in v1.3.0")]
public interface IInstantQuery { }
}
}

View File

@@ -1,10 +1,15 @@
using System.Collections.Generic;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
namespace Wox.Plugin
{
public interface IPlugin
{
List<Result> Query(Query query);
void Init(PluginInitContext context);
}
}
}

View File

@@ -1,4 +1,8 @@
using System.Collections.Generic;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
namespace Wox.Plugin
{
@@ -12,7 +16,7 @@ namespace Wox.Plugin
/// </summary>
/// <param name="query">query text</param>
/// <param name="requery">
/// force requery By default, Wox will not fire query if your query is same with existing one.
/// force requery By default, Wox will not fire query if your query is same with existing one.
/// Set this to true to force Wox requerying
/// </param>
void ChangeQuery(string query, bool requery = false);
@@ -38,7 +42,7 @@ namespace Wox.Plugin
void SaveAppAllSettings();
/// <summary>
/// Reloads any Plugins that have the
/// Reloads any Plugins that have the
/// IReloadable implemented. It refreshes
/// Plugin's in memory data with new content
/// added by user.
@@ -73,7 +77,7 @@ namespace Wox.Plugin
string GetTranslation(string key);
/// <summary>
/// Get all loaded plugins
/// Get all loaded plugins
/// </summary>
/// <returns></returns>
List<PluginPair> GetAllPlugins();

View File

@@ -1,11 +1,16 @@
using Microsoft.PowerToys.Settings.UI.Lib;
using System.Windows.Controls;
namespace Wox.Plugin
{
public interface ISettingProvider
{
Control CreateSettingPanel();
void UpdateSettings(PowerLauncherSettings settings);
}
}
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Windows.Controls;
using Microsoft.PowerToys.Settings.UI.Lib;
namespace Wox.Plugin
{
public interface ISettingProvider
{
Control CreateSettingPanel();
void UpdateSettings(PowerLauncherSettings settings);
}
}

View File

@@ -1,13 +1,17 @@
namespace Wox.Plugin
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Wox.Plugin
{
/// <summary>
/// This interface is to indicate and allow plugins to reload their
/// in memory data cache or other mediums when user makes a new change
/// that is not immediately captured. For example, for BrowserBookmark and Program
/// plugin does not automatically detect when a user added a new bookmark or program,
/// so this interface's function is exposed to allow user manually do the reloading after
/// so this interface's function is exposed to allow user manually do the reloading after
/// those new additions.
///
///
/// The command that allows user to manual reload is exposed via Plugin.Sys, and
/// it will call the plugins that have implemented this interface.
/// </summary>

View File

@@ -1,4 +1,6 @@
using System;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Wox.Plugin
{

View File

@@ -1,4 +1,8 @@
using System;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
@@ -9,14 +13,23 @@ namespace Wox.Plugin
public class PluginMetadata : BaseModel
{
private string _pluginDirectory;
public string ID { get; set; }
public string Name { get; set; }
public string Author { get; set; }
public string Version { get; set; }
public string Language { get; set; }
public string Description { get; set; }
public string Website { get; set; }
public bool Disabled { get; set; }
public string ExecuteFilePath { get; private set; }
public string ExecuteFileName { get; set; }
@@ -24,6 +37,7 @@ namespace Wox.Plugin
public string PluginDirectory
{
get { return _pluginDirectory; }
internal set
{
_pluginDirectory = value;
@@ -51,8 +65,10 @@ namespace Wox.Plugin
/// </summary>
[JsonIgnore]
public long InitTime { get; set; }
[JsonIgnore]
public long AvgQueryTime { get; set; }
[JsonIgnore]
public int QueryCount { get; set; }
}

View File

@@ -1,8 +1,13 @@
namespace Wox.Plugin
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Wox.Plugin
{
public class PluginPair
{
public IPlugin Plugin { get; internal set; }
public PluginMetadata Metadata { get; internal set; }

View File

@@ -1,6 +1,10 @@
using System.Runtime.CompilerServices;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("PowerLauncher")]
[assembly: InternalsVisibleTo("Wox")]
[assembly: InternalsVisibleTo("Wox.Core")]
[assembly: InternalsVisibleTo("Wox.Test")]
[assembly: InternalsVisibleTo("Wox.Test")]

View File

@@ -1,4 +1,8 @@
using System;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Linq;
@@ -28,7 +32,7 @@ namespace Wox.Plugin
/// <summary>
/// Search part of a query.
/// This will not include action keyword if exclusive plugin gets it, otherwise it should be same as RawQuery.
/// Since we allow user to switch a exclusive plugin to generic plugin,
/// Since we allow user to switch a exclusive plugin to generic plugin,
/// so this property will always give you the "real" query part of the query
/// </summary>
public string Search { get; internal set; }

View File

@@ -1,161 +1,169 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Media;
using System.Windows;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows;
using System.Windows.Media;
namespace Wox.Plugin
{
public class Result
{
private string _title;
private ToolTipData _toolTipData;
private string _pluginDirectory;
private string _icoPath;
namespace Wox.Plugin
{
public class Result
{
private string _title;
private ToolTipData _toolTipData;
private string _pluginDirectory;
private string _icoPath;
public string Title
{
get { return _title; }
set
{
_title = value.Replace("\n", " ");
}
}
public string SubTitle { get; set; }
public string Glyph { get; set; }
}
}
public string SubTitle { get; set; }
public string Glyph { get; set; }
public string FontFamily { get; set; }
public Visibility ToolTipVisibility { get; set; } = Visibility.Collapsed;
public ToolTipData ToolTipData
{
get
{
return _toolTipData;
}
set
{
_toolTipData = value;
ToolTipVisibility = Visibility.Visible;
return _toolTipData;
}
}
set
{
_toolTipData = value;
ToolTipVisibility = Visibility.Visible;
}
}
/// <summary>
/// The text that will get displayed in the Search text box, when this item is selected in the result list.
/// </summary>
public string QueryTextDisplay { get; set; }
public string IcoPath
{
get { return _icoPath; }
set
{
if (!string.IsNullOrEmpty(PluginDirectory) && !Path.IsPathRooted(value))
{
_icoPath = Path.Combine(value, IcoPath);
}
else
{
_icoPath = value;
}
}
}
public delegate ImageSource IconDelegate();
public IconDelegate Icon;
/// <summary>
/// return true to hide wox after select result
/// </summary>
public Func<ActionContext, bool> Action { get; set; }
public int Score { get; set; }
/// <summary>
/// A list of indexes for the characters to be highlighted in Title
/// </summary>
public IList<int> TitleHighlightData { get; set; }
/// <summary>
/// A list of indexes for the characters to be highlighted in SubTitle
/// </summary>
public IList<int> SubTitleHighlightData { get; set; }
/// <summary>
/// Only results that originQuery match with current query will be displayed in the panel
/// </summary>
internal Query OriginQuery { get; set; }
/// <summary>
/// Plugin directory
/// </summary>
public string PluginDirectory
{
get { return _pluginDirectory; }
set
{
_pluginDirectory = value;
if (!string.IsNullOrEmpty(IcoPath) && !Path.IsPathRooted(IcoPath))
{
IcoPath = Path.Combine(value, IcoPath);
}
}
}
public override bool Equals(object obj)
{
var r = obj as Result;
var equality = string.Equals(r?.Title, Title) &&
string.Equals(r?.SubTitle, SubTitle) &&
string.Equals(r?.IcoPath, IcoPath) &&
TitleHighlightData == r.TitleHighlightData &&
SubTitleHighlightData == r.SubTitleHighlightData;
return equality;
}
public override int GetHashCode()
{
var hashcode = (Title?.GetHashCode() ?? 0) ^
(SubTitle?.GetHashCode() ?? 0);
return hashcode;
}
public override string ToString()
{
return Title + SubTitle;
}
[Obsolete("Use IContextMenu instead")]
/// <summary>
/// Context menus associate with this result
/// </summary>
public List<Result> ContextMenu { get; set; }
[Obsolete("Use Object initializers instead")]
public Result(string Title, string IcoPath, string SubTitle = null)
{
this.Title = Title;
this.IcoPath = IcoPath;
this.SubTitle = SubTitle;
}
public Result() { }
/// <summary>
/// Additional data associate with this result
/// </summary>
public object ContextData { get; set; }
/// <summary>
/// Plugin ID that generated this result
/// </summary>
public string PluginID { get; internal set; }
}
}
/// </summary>
public string QueryTextDisplay { get; set; }
public string IcoPath
{
get { return _icoPath; }
set
{
if (!string.IsNullOrEmpty(PluginDirectory) && !Path.IsPathRooted(value))
{
_icoPath = Path.Combine(value, IcoPath);
}
else
{
_icoPath = value;
}
}
}
public delegate ImageSource IconDelegate();
public IconDelegate Icon;
/// <summary>
/// return true to hide wox after select result
/// </summary>
public Func<ActionContext, bool> Action { get; set; }
public int Score { get; set; }
/// <summary>
/// A list of indexes for the characters to be highlighted in Title
/// </summary>
public IList<int> TitleHighlightData { get; set; }
/// <summary>
/// A list of indexes for the characters to be highlighted in SubTitle
/// </summary>
public IList<int> SubTitleHighlightData { get; set; }
/// <summary>
/// Only results that originQuery match with current query will be displayed in the panel
/// </summary>
internal Query OriginQuery { get; set; }
/// <summary>
/// Plugin directory
/// </summary>
public string PluginDirectory
{
get { return _pluginDirectory; }
set
{
_pluginDirectory = value;
if (!string.IsNullOrEmpty(IcoPath) && !Path.IsPathRooted(IcoPath))
{
IcoPath = Path.Combine(value, IcoPath);
}
}
}
public override bool Equals(object obj)
{
var r = obj as Result;
var equality = string.Equals(r?.Title, Title) &&
string.Equals(r?.SubTitle, SubTitle) &&
string.Equals(r?.IcoPath, IcoPath) &&
TitleHighlightData == r.TitleHighlightData &&
SubTitleHighlightData == r.SubTitleHighlightData;
return equality;
}
public override int GetHashCode()
{
var hashcode = (Title?.GetHashCode() ?? 0) ^
(SubTitle?.GetHashCode() ?? 0);
return hashcode;
}
public override string ToString()
{
return Title + SubTitle;
}
[Obsolete("Use IContextMenu instead")]
/// <summary>
/// Context menus associate with this result
/// </summary>
public List<Result> ContextMenu { get; set; }
[Obsolete("Use Object initializers instead")]
public Result(string Title, string IcoPath, string SubTitle = null)
{
this.Title = Title;
this.IcoPath = IcoPath;
this.SubTitle = SubTitle;
}
public Result() { }
/// <summary>
/// Additional data associate with this result
/// </summary>
public object ContextData { get; set; }
/// <summary>
/// Plugin ID that generated this result
/// </summary>
public string PluginID { get; internal set; }
}
}

View File

@@ -1,4 +1,8 @@
using System;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.IO;
using System.Windows;

View File

@@ -1,3 +1,7 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics;
using System.IO;
@@ -7,8 +11,8 @@ namespace Wox.Plugin.SharedCommands
{
public static class SearchWeb
{
/// <summary>
/// Opens search in a new browser. If no browser path is passed in then Chrome is used.
/// <summary>
/// Opens search in a new browser. If no browser path is passed in then Chrome is used.
/// Leave browser path blank to use Chrome.
/// </summary>
public static void NewBrowserWindow(this string url, string browserPath)
@@ -37,7 +41,7 @@ namespace Wox.Plugin.SharedCommands
}
}
/// <summary>
/// <summary>
/// Opens search as a tab in the default browser chosen in Windows settings.
/// </summary>
public static void NewTabInBrowser(this string url, string browserPath)
@@ -53,6 +57,7 @@ namespace Wox.Plugin.SharedCommands
Process.Start(url);
}
}
// This error may be thrown for Process.Start(browserPath, url)
catch (System.ComponentModel.Win32Exception)
{

View File

@@ -1,19 +1,23 @@
using System;
using System.Collections.Generic;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Wox.Plugin.SharedCommands
{
public static class ShellCommand
{
public delegate bool EnumThreadDelegate(IntPtr hwnd, IntPtr lParam);
[DllImport("user32.dll")] static extern bool EnumThreadWindows(uint threadId, EnumThreadDelegate lpfn, IntPtr lParam);
[DllImport("user32.dll")] static extern int GetWindowText(IntPtr hwnd, StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll")] static extern int GetWindowTextLength(IntPtr hwnd);
private static bool containsSecurityWindow;
@@ -29,6 +33,7 @@ namespace Wox.Plugin.SharedCommands
CheckSecurityWindow();
Thread.Sleep(25);
}
while (containsSecurityWindow) // while this process contains a "Windows Security" dialog, stay open
{
containsSecurityWindow = false;

View File

@@ -1,10 +1,13 @@
using ControlzEx.Theming;
using MahApps.Metro.Theming;
using Microsoft.Win32;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using ControlzEx.Theming;
using MahApps.Metro.Theming;
using Microsoft.Win32;
namespace Wox.Plugin
{
@@ -142,6 +145,7 @@ namespace Wox.Plugin
{
currentTheme = Theme.None;
}
ThemeChanged?.Invoke(oldTheme, currentTheme);
}

View File

@@ -1,4 +1,8 @@
using System;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace Wox.Plugin
{
@@ -14,6 +18,7 @@ namespace Wox.Plugin
{
throw new ArgumentException("title cannot be null or empty", "title");
}
Title = title;
Text = text;
}

View File

@@ -68,5 +68,19 @@
<ItemGroup>
<ProjectReference Include="..\..\..\core\Microsoft.PowerToys.Settings.UI.Lib\Microsoft.PowerToys.Settings.UI.Lib.csproj" />
</ItemGroup>
<!--<ItemGroup>
<Compile Include="..\..\..\codeAnalysis\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json">
<Link>StyleCop.json</Link>
</AdditionalFiles>
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>-->
</Project>