mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
[StyleCop] Wox.Plugin - last amount needed to fully integrate (#5853)
* StyleCop for Plugin * getting release mode working
This commit is contained in:
@@ -8,15 +8,4 @@ namespace Wox.Plugin
|
||||
{
|
||||
public SpecialKeyState SpecialKeyState { get; set; }
|
||||
}
|
||||
|
||||
public class SpecialKeyState
|
||||
{
|
||||
public bool CtrlPressed { get; set; }
|
||||
|
||||
public bool ShiftPressed { get; set; }
|
||||
|
||||
public bool AltPressed { get; set; }
|
||||
|
||||
public bool WinPressed { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Wox.Plugin
|
||||
public ModifierKeys AcceleratorModifiers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// return true to hide wox after select result
|
||||
/// Gets or sets return true to hide wox after select result
|
||||
/// </summary>
|
||||
public Func<ActionContext, bool> Action { get; set; }
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
// 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);
|
||||
|
||||
public class WoxKeyDownEventArgs
|
||||
{
|
||||
public string Query { get; set; }
|
||||
|
||||
public KeyEventArgs keyEventArgs { get; set; }
|
||||
}
|
||||
|
||||
public class WoxQueryEventArgs
|
||||
{
|
||||
public Query Query { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
// 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;
|
||||
|
||||
namespace Wox.Plugin
|
||||
{
|
||||
public interface IFeatures { }
|
||||
|
||||
public interface IContextMenu : IFeatures
|
||||
{
|
||||
List<ContextMenuResult> LoadContextMenus(Result selectedResult);
|
||||
}
|
||||
|
||||
[Obsolete("If a plugin has a action keyword, then it is exclusive. This interface will be remove in v1.3.0")]
|
||||
public interface IExclusiveQuery : IFeatures
|
||||
{
|
||||
[Obsolete("If a plugin has a action keyword, then it is exclusive. This method will be remove in v1.3.0")]
|
||||
bool IsExclusiveQuery(Query query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represent plugin query will be executed in UI thread directly. Don't do long-running operation in Query method if you implement this interface
|
||||
/// <remarks>This will improve the performance of instant search like websearch or cmd plugin</remarks>
|
||||
/// </summary>
|
||||
[Obsolete("Wox is fast enough now, executed on ui thread is no longer needed")]
|
||||
public interface IInstantQuery : IFeatures
|
||||
{
|
||||
bool IsInstantQuery(string query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represent plugins that support internationalization
|
||||
/// </summary>
|
||||
public interface IPluginI18n : IFeatures
|
||||
{
|
||||
string GetTranslatedPluginTitle();
|
||||
|
||||
string GetTranslatedPluginDescription();
|
||||
}
|
||||
|
||||
public interface IResultUpdated : IFeatures
|
||||
{
|
||||
event ResultUpdatedEventHandler ResultsUpdated;
|
||||
}
|
||||
|
||||
public delegate void ResultUpdatedEventHandler(IResultUpdated sender, ResultUpdatedEventArgs e);
|
||||
|
||||
public class ResultUpdatedEventArgs : EventArgs
|
||||
{
|
||||
public List<Result> Results;
|
||||
public Query Query;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// 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
|
||||
{
|
||||
[Obsolete("Delete Wox.Plugin.Features using directive, " +
|
||||
"and use Wox.Plugin.Feature.IContextMenu instead, " +
|
||||
"this method will be removed in v1.3.0")]
|
||||
public interface IContextMenu { }
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// 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
|
||||
{
|
||||
[Obsolete("Delete Wox.Plugin.Features using directive, " +
|
||||
"and use Wox.Plugin.Feature.IInstantQuery instead, " +
|
||||
"this method will be removed in v1.3.0")]
|
||||
public interface IExclusiveQuery { }
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// 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
|
||||
{
|
||||
[Obsolete("Delete Wox.Plugin.Features using directive, " +
|
||||
"and use Wox.Plugin.Feature.IInstantQuery instead, " +
|
||||
"this method will be removed in v1.3.0")]
|
||||
public interface IInstantQuery { }
|
||||
}
|
||||
34
src/modules/launcher/Wox.Plugin/IFeatures.cs
Normal file
34
src/modules/launcher/Wox.Plugin/IFeatures.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
// 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 IFeatures
|
||||
{
|
||||
}
|
||||
|
||||
public interface IContextMenu : IFeatures
|
||||
{
|
||||
List<ContextMenuResult> LoadContextMenus(Result selectedResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represent plugins that support internationalization
|
||||
/// </summary>
|
||||
public interface IPluginI18n : IFeatures
|
||||
{
|
||||
string GetTranslatedPluginTitle();
|
||||
|
||||
string GetTranslatedPluginDescription();
|
||||
}
|
||||
|
||||
public interface IResultUpdated : IFeatures
|
||||
{
|
||||
event ResultUpdatedEventHandler ResultsUpdated;
|
||||
}
|
||||
|
||||
public delegate void ResultUpdatedEventHandler(IResultUpdated sender, ResultUpdatedEventArgs e);
|
||||
}
|
||||
@@ -9,7 +9,7 @@ namespace Wox.Plugin
|
||||
public PluginMetadata CurrentPluginMetadata { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Public APIs for plugin invocation
|
||||
/// Gets or sets public APIs for plugin invocation
|
||||
/// </summary>
|
||||
public IPublicAPI API { get; set; }
|
||||
}
|
||||
|
||||
@@ -36,7 +36,10 @@ namespace Wox.Plugin
|
||||
|
||||
public string PluginDirectory
|
||||
{
|
||||
get { return _pluginDirectory; }
|
||||
get
|
||||
{
|
||||
return _pluginDirectory;
|
||||
}
|
||||
|
||||
internal set
|
||||
{
|
||||
@@ -61,7 +64,7 @@ namespace Wox.Plugin
|
||||
public string FullIcoPath => IcoPath;
|
||||
|
||||
/// <summary>
|
||||
/// Init time include both plugin load time and init time
|
||||
/// Gets or sets init time include both plugin load time and init time
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public long InitTime { get; set; }
|
||||
|
||||
@@ -10,8 +10,6 @@ namespace Wox.Plugin
|
||||
|
||||
public PluginMetadata Metadata { get; internal set; }
|
||||
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Metadata.Name;
|
||||
@@ -19,8 +17,7 @@ namespace Wox.Plugin
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
PluginPair r = obj as PluginPair;
|
||||
if (r != null)
|
||||
if (obj is PluginPair r)
|
||||
{
|
||||
return string.Equals(r.Metadata.ID, Metadata.ID);
|
||||
}
|
||||
|
||||
@@ -10,9 +10,12 @@ namespace Wox.Plugin
|
||||
{
|
||||
public class Query
|
||||
{
|
||||
internal Query() { }
|
||||
internal Query()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Query"/> class.
|
||||
/// to allow unit tests for plug ins
|
||||
/// </summary>
|
||||
public Query(string rawQuery, string search, string[] terms, string actionKeyword = "")
|
||||
@@ -24,13 +27,13 @@ namespace Wox.Plugin
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raw query, this includes action keyword if it has
|
||||
/// Gets raw query, this includes action keyword if it has
|
||||
/// We didn't recommend use this property directly. You should always use Search property.
|
||||
/// </summary>
|
||||
public string RawQuery { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Search part of a query.
|
||||
/// Gets 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,
|
||||
/// so this property will always give you the "real" query part of the query
|
||||
@@ -38,7 +41,7 @@ namespace Wox.Plugin
|
||||
public string Search { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// The raw query splited into a string array.
|
||||
/// Gets or sets the raw query splited into a string array.
|
||||
/// </summary>
|
||||
public string[] Terms { get; set; }
|
||||
|
||||
@@ -46,6 +49,7 @@ namespace Wox.Plugin
|
||||
/// Query can be splited into multiple terms by whitespace
|
||||
/// </summary>
|
||||
public const string TermSeparator = " ";
|
||||
|
||||
/// <summary>
|
||||
/// User can set multiple action keywords separated by ';'
|
||||
/// </summary>
|
||||
@@ -59,12 +63,12 @@ namespace Wox.Plugin
|
||||
public string ActionKeyword { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Return first search split by space if it has
|
||||
/// Gets return first search split by space if it has
|
||||
/// </summary>
|
||||
public string FirstSearch => SplitSearch(0);
|
||||
|
||||
/// <summary>
|
||||
/// strings from second search (including) to last search
|
||||
/// Gets strings from second search (including) to last search
|
||||
/// </summary>
|
||||
public string SecondToEndSearch
|
||||
{
|
||||
@@ -76,12 +80,12 @@ namespace Wox.Plugin
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return second search split by space if it has
|
||||
/// Gets return second search split by space if it has
|
||||
/// </summary>
|
||||
public string SecondSearch => SplitSearch(1);
|
||||
|
||||
/// <summary>
|
||||
/// Return third search split by space if it has
|
||||
/// Gets return third search split by space if it has
|
||||
/// </summary>
|
||||
public string ThirdSearch => SplitSearch(2);
|
||||
|
||||
|
||||
@@ -19,7 +19,10 @@ namespace Wox.Plugin
|
||||
|
||||
public string Title
|
||||
{
|
||||
get { return _title; }
|
||||
get
|
||||
{
|
||||
return _title;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
@@ -50,13 +53,16 @@ namespace Wox.Plugin
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The text that will get displayed in the Search text box, when this item is selected in the result list.
|
||||
/// Gets or sets 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; }
|
||||
get
|
||||
{
|
||||
return _icoPath;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
@@ -73,37 +79,39 @@ namespace Wox.Plugin
|
||||
|
||||
public delegate ImageSource IconDelegate();
|
||||
|
||||
public IconDelegate Icon;
|
||||
|
||||
public IconDelegate Icon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// return true to hide wox after select result
|
||||
/// Gets or sets 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
|
||||
/// Gets or sets 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
|
||||
/// Gets or sets 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
|
||||
/// Gets or sets only results that originQuery match with current query will be displayed in the panel
|
||||
/// </summary>
|
||||
internal Query OriginQuery { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Plugin directory
|
||||
/// Gets or sets plugin directory
|
||||
/// </summary>
|
||||
public string PluginDirectory
|
||||
{
|
||||
get { return _pluginDirectory; }
|
||||
get
|
||||
{
|
||||
return _pluginDirectory;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
@@ -140,29 +148,17 @@ namespace Wox.Plugin
|
||||
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)
|
||||
public Result()
|
||||
{
|
||||
this.Title = Title;
|
||||
this.IcoPath = IcoPath;
|
||||
this.SubTitle = SubTitle;
|
||||
}
|
||||
|
||||
public Result() { }
|
||||
|
||||
/// <summary>
|
||||
/// Additional data associate with this result
|
||||
/// Gets or sets additional data associate with this result
|
||||
/// </summary>
|
||||
public object ContextData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Plugin ID that generated this result
|
||||
/// Gets plugin ID that generated this result
|
||||
/// </summary>
|
||||
public string PluginID { get; internal set; }
|
||||
}
|
||||
|
||||
16
src/modules/launcher/Wox.Plugin/ResultUpdatedEventArgs.cs
Normal file
16
src/modules/launcher/Wox.Plugin/ResultUpdatedEventArgs.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
// 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;
|
||||
|
||||
namespace Wox.Plugin
|
||||
{
|
||||
public class ResultUpdatedEventArgs : EventArgs
|
||||
{
|
||||
public List<Result> Results { get; set; }
|
||||
|
||||
public Query Query { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
|
||||
namespace Wox.Plugin.SharedCommands
|
||||
{
|
||||
@@ -25,6 +24,7 @@ namespace Wox.Plugin.SharedCommands
|
||||
try
|
||||
{
|
||||
DirectoryInfo[] dirs = dir.GetDirectories();
|
||||
|
||||
// If the destination directory doesn't exist, create it.
|
||||
if (!Directory.Exists(targetPath))
|
||||
{
|
||||
@@ -51,11 +51,10 @@ namespace Wox.Plugin.SharedCommands
|
||||
#if DEBUG
|
||||
throw e;
|
||||
#else
|
||||
MessageBox.Show(string.Format("Copying path {0} has failed, it will now be deleted for consistency", targetPath));
|
||||
System.Windows.MessageBox.Show(string.Format("Copying path {0} has failed, it will now be deleted for consistency", targetPath));
|
||||
RemoveFolder(targetPath);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static bool VerifyBothFolderFilesEqual(this string fromPath, string toPath)
|
||||
@@ -66,10 +65,14 @@ namespace Wox.Plugin.SharedCommands
|
||||
var toDir = new DirectoryInfo(toPath);
|
||||
|
||||
if (fromDir.GetFiles("*", SearchOption.AllDirectories).Length != toDir.GetFiles("*", SearchOption.AllDirectories).Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fromDir.GetDirectories("*", SearchOption.AllDirectories).Length != toDir.GetDirectories("*", SearchOption.AllDirectories).Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -78,11 +81,10 @@ namespace Wox.Plugin.SharedCommands
|
||||
#if DEBUG
|
||||
throw e;
|
||||
#else
|
||||
MessageBox.Show(string.Format("Unable to verify folders and files between {0} and {1}", fromPath, toPath));
|
||||
System.Windows.MessageBox.Show(string.Format("Unable to verify folders and files between {0} and {1}", fromPath, toPath));
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void RemoveFolder(this string path)
|
||||
@@ -90,14 +92,16 @@ namespace Wox.Plugin.SharedCommands
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
Directory.Delete(path, true);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#if DEBUG
|
||||
throw e;
|
||||
#else
|
||||
MessageBox.Show(string.Format("Not able to delete folder {0}, please go to the location and manually delete it", path));
|
||||
System.Windows.MessageBox.Show(string.Format("Not able to delete folder {0}, please go to the location and manually delete it", path));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Wox.Plugin.SharedCommands
|
||||
/// 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)
|
||||
public static void NewBrowserWindow(this string url, string browserPath)
|
||||
{
|
||||
var browserExecutableName = browserPath?
|
||||
.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None)
|
||||
@@ -35,7 +35,7 @@ namespace Wox.Plugin.SharedCommands
|
||||
var psi = new ProcessStartInfo
|
||||
{
|
||||
FileName = url,
|
||||
UseShellExecute = true
|
||||
UseShellExecute = true,
|
||||
};
|
||||
Process.Start(psi);
|
||||
}
|
||||
|
||||
@@ -14,11 +14,14 @@ namespace Wox.Plugin.SharedCommands
|
||||
{
|
||||
public delegate bool EnumThreadDelegate(IntPtr hwnd, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll")] static extern bool EnumThreadWindows(uint threadId, EnumThreadDelegate lpfn, IntPtr lParam);
|
||||
[DllImport("user32.dll")]
|
||||
private 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")]
|
||||
private static extern int GetWindowText(IntPtr hwnd, StringBuilder lpString, int nMaxCount);
|
||||
|
||||
[DllImport("user32.dll")] static extern int GetWindowTextLength(IntPtr hwnd);
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int GetWindowTextLength(IntPtr hwnd);
|
||||
|
||||
private static bool containsSecurityWindow;
|
||||
|
||||
@@ -28,13 +31,16 @@ namespace Wox.Plugin.SharedCommands
|
||||
var process = Process.Start(processStartInfo);
|
||||
|
||||
containsSecurityWindow = false;
|
||||
while (!containsSecurityWindow) // wait for windows to bring up the "Windows Security" dialog
|
||||
|
||||
// wait for windows to bring up the "Windows Security" dialog
|
||||
while (!containsSecurityWindow)
|
||||
{
|
||||
CheckSecurityWindow();
|
||||
Thread.Sleep(25);
|
||||
}
|
||||
|
||||
while (containsSecurityWindow) // while this process contains a "Windows Security" dialog, stay open
|
||||
// while this process contains a "Windows Security" dialog, stay open
|
||||
while (containsSecurityWindow)
|
||||
{
|
||||
containsSecurityWindow = false;
|
||||
CheckSecurityWindow();
|
||||
@@ -48,13 +54,18 @@ namespace Wox.Plugin.SharedCommands
|
||||
{
|
||||
ProcessThreadCollection ptc = Process.GetCurrentProcess().Threads;
|
||||
for (int i = 0; i < ptc.Count; i++)
|
||||
{
|
||||
EnumThreadWindows((uint)ptc[i].Id, CheckSecurityThread, IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool CheckSecurityThread(IntPtr hwnd, IntPtr lParam)
|
||||
{
|
||||
if (GetWindowTitle(hwnd) == "Windows Security")
|
||||
{
|
||||
containsSecurityWindow = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -72,7 +83,7 @@ namespace Wox.Plugin.SharedCommands
|
||||
FileName = fileName,
|
||||
WorkingDirectory = workingDirectory,
|
||||
Arguments = arguments,
|
||||
Verb = verb
|
||||
Verb = verb,
|
||||
};
|
||||
|
||||
return info;
|
||||
|
||||
17
src/modules/launcher/Wox.Plugin/SpecialKeyState.cs
Normal file
17
src/modules/launcher/Wox.Plugin/SpecialKeyState.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
// 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 SpecialKeyState
|
||||
{
|
||||
public bool CtrlPressed { get; set; }
|
||||
|
||||
public bool ShiftPressed { get; set; }
|
||||
|
||||
public bool AltPressed { get; set; }
|
||||
|
||||
public bool WinPressed { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -13,47 +13,54 @@ namespace Wox.Plugin
|
||||
{
|
||||
public class ThemeManager : IDisposable
|
||||
{
|
||||
private readonly Application _app;
|
||||
private const string LightTheme = "Light.Accent1";
|
||||
private const string DarkTheme = "Dark.Accent1";
|
||||
private const string HighContrastOneTheme = "HighContrast.Accent2";
|
||||
private const string HighContrastTwoTheme = "HighContrast.Accent3";
|
||||
private const string HighContrastBlackTheme = "HighContrast.Accent4";
|
||||
private const string HighContrastWhiteTheme = "HighContrast.Accent5";
|
||||
|
||||
private Theme currentTheme;
|
||||
private readonly Application App;
|
||||
private bool _disposed = false;
|
||||
private readonly string LightTheme = "Light.Accent1";
|
||||
private readonly string DarkTheme = "Dark.Accent1";
|
||||
private readonly string HighContrastOneTheme = "HighContrast.Accent2";
|
||||
private readonly string HighContrastTwoTheme = "HighContrast.Accent3";
|
||||
private readonly string HighContrastBlackTheme = "HighContrast.Accent4";
|
||||
private readonly string HighContrastWhiteTheme = "HighContrast.Accent5";
|
||||
|
||||
public event ThemeChangedHandler ThemeChanged;
|
||||
|
||||
public ThemeManager(Application app)
|
||||
{
|
||||
this.App = app;
|
||||
_app = app;
|
||||
|
||||
Uri HighContrastOneThemeUri = new Uri("pack://application:,,,/Themes/HighContrast1.xaml");
|
||||
Uri HighContrastTwoThemeUri = new Uri("pack://application:,,,/Themes/HighContrast2.xaml");
|
||||
Uri HighContrastBlackThemeUri = new Uri("pack://application:,,,/Themes/HighContrastWhite.xaml");
|
||||
Uri HighContrastWhiteThemeUri = new Uri("pack://application:,,,/Themes/HighContrastBlack.xaml");
|
||||
Uri LightThemeUri = new Uri("pack://application:,,,/Themes/Light.xaml");
|
||||
Uri DarkThemeUri = new Uri("pack://application:,,,/Themes/Dark.xaml");
|
||||
Uri highContrastOneThemeUri = new Uri("pack://application:,,,/Themes/HighContrast1.xaml");
|
||||
Uri highContrastTwoThemeUri = new Uri("pack://application:,,,/Themes/HighContrast2.xaml");
|
||||
Uri highContrastBlackThemeUri = new Uri("pack://application:,,,/Themes/HighContrastWhite.xaml");
|
||||
Uri highContrastWhiteThemeUri = new Uri("pack://application:,,,/Themes/HighContrastBlack.xaml");
|
||||
Uri lightThemeUri = new Uri("pack://application:,,,/Themes/Light.xaml");
|
||||
Uri darkThemeUri = new Uri("pack://application:,,,/Themes/Dark.xaml");
|
||||
|
||||
ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme(
|
||||
new LibraryTheme(HighContrastOneThemeUri,
|
||||
MahAppsLibraryThemeProvider.DefaultInstance));
|
||||
new LibraryTheme(
|
||||
highContrastOneThemeUri,
|
||||
MahAppsLibraryThemeProvider.DefaultInstance));
|
||||
ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme(
|
||||
new LibraryTheme(HighContrastTwoThemeUri,
|
||||
MahAppsLibraryThemeProvider.DefaultInstance));
|
||||
new LibraryTheme(
|
||||
highContrastTwoThemeUri,
|
||||
MahAppsLibraryThemeProvider.DefaultInstance));
|
||||
ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme(
|
||||
new LibraryTheme(HighContrastBlackThemeUri,
|
||||
MahAppsLibraryThemeProvider.DefaultInstance));
|
||||
new LibraryTheme(
|
||||
highContrastBlackThemeUri,
|
||||
MahAppsLibraryThemeProvider.DefaultInstance));
|
||||
ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme(
|
||||
new LibraryTheme(HighContrastWhiteThemeUri,
|
||||
MahAppsLibraryThemeProvider.DefaultInstance));
|
||||
new LibraryTheme(
|
||||
highContrastWhiteThemeUri,
|
||||
MahAppsLibraryThemeProvider.DefaultInstance));
|
||||
ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme(
|
||||
new LibraryTheme(LightThemeUri,
|
||||
MahAppsLibraryThemeProvider.DefaultInstance));
|
||||
new LibraryTheme(
|
||||
lightThemeUri,
|
||||
MahAppsLibraryThemeProvider.DefaultInstance));
|
||||
ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme(
|
||||
new LibraryTheme(DarkThemeUri,
|
||||
MahAppsLibraryThemeProvider.DefaultInstance));
|
||||
new LibraryTheme(
|
||||
darkThemeUri,
|
||||
MahAppsLibraryThemeProvider.DefaultInstance));
|
||||
|
||||
ResetTheme();
|
||||
ControlzEx.Theming.ThemeManager.Current.ThemeSyncMode = ThemeSyncMode.SyncWithAppMode;
|
||||
@@ -76,20 +83,23 @@ namespace Wox.Plugin
|
||||
|
||||
private static Theme GetHighContrastBaseType()
|
||||
{
|
||||
string RegistryKey = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes";
|
||||
string theme = (string)Registry.GetValue(RegistryKey, "CurrentTheme", string.Empty);
|
||||
string registryKey = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes";
|
||||
string theme = (string)Registry.GetValue(registryKey, "CurrentTheme", string.Empty);
|
||||
theme = theme.Split('\\').Last().Split('.').First().ToString();
|
||||
|
||||
if (theme == "hc1")
|
||||
return Theme.HighContrastOne;
|
||||
else if (theme == "hc2")
|
||||
return Theme.HighContrastTwo;
|
||||
else if (theme == "hcwhite")
|
||||
return Theme.HighContrastWhite;
|
||||
else if (theme == "hcblack")
|
||||
return Theme.HighContrastBlack;
|
||||
else
|
||||
return Theme.None;
|
||||
switch (theme)
|
||||
{
|
||||
case "hc1":
|
||||
return Theme.HighContrastOne;
|
||||
case "hc2":
|
||||
return Theme.HighContrastTwo;
|
||||
case "hcwhite":
|
||||
return Theme.HighContrastWhite;
|
||||
case "hcblack":
|
||||
return Theme.HighContrastBlack;
|
||||
default:
|
||||
return Theme.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetTheme()
|
||||
@@ -110,35 +120,38 @@ namespace Wox.Plugin
|
||||
{
|
||||
Theme oldTheme = currentTheme;
|
||||
if (theme == currentTheme)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (theme == Theme.HighContrastOne)
|
||||
{
|
||||
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(this.App, this.HighContrastOneTheme);
|
||||
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastOneTheme);
|
||||
currentTheme = Theme.HighContrastOne;
|
||||
}
|
||||
else if (theme == Theme.HighContrastTwo)
|
||||
{
|
||||
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(this.App, this.HighContrastTwoTheme);
|
||||
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastTwoTheme);
|
||||
currentTheme = Theme.HighContrastTwo;
|
||||
}
|
||||
else if (theme == Theme.HighContrastWhite)
|
||||
{
|
||||
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(this.App, this.HighContrastWhiteTheme);
|
||||
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastWhiteTheme);
|
||||
currentTheme = Theme.HighContrastWhite;
|
||||
}
|
||||
else if (theme == Theme.HighContrastBlack)
|
||||
{
|
||||
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(this.App, this.HighContrastBlackTheme);
|
||||
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastBlackTheme);
|
||||
currentTheme = Theme.HighContrastBlack;
|
||||
}
|
||||
else if (theme == Theme.Light)
|
||||
{
|
||||
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(this.App, this.LightTheme);
|
||||
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, LightTheme);
|
||||
currentTheme = Theme.Light;
|
||||
}
|
||||
else if (theme == Theme.Dark)
|
||||
{
|
||||
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(this.App, this.DarkTheme);
|
||||
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, DarkTheme);
|
||||
currentTheme = Theme.Dark;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\core\Microsoft.PowerToys.Settings.UI.Lib\Microsoft.PowerToys.Settings.UI.Lib.csproj" />
|
||||
</ItemGroup>
|
||||
<!--<ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\..\codeAnalysis\GlobalSuppressions.cs">
|
||||
<Link>GlobalSuppressions.cs</Link>
|
||||
</Compile>
|
||||
@@ -82,5 +82,5 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>-->
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user