mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-11 12:14:53 +08:00
Added theming to Shell and WindowWalker
This commit is contained in:
parent
8edd3226be
commit
f492c4efdb
@ -25,7 +25,8 @@ namespace Microsoft.Plugin.Shell
|
|||||||
{
|
{
|
||||||
public class Main : IPlugin, ISettingProvider, IPluginI18n, IContextMenu, ISavable
|
public class Main : IPlugin, ISettingProvider, IPluginI18n, IContextMenu, ISavable
|
||||||
{
|
{
|
||||||
private const string Image = "Images/shell.dark.png";
|
private string IconPath { get; set; }
|
||||||
|
|
||||||
private PluginInitContext _context;
|
private PluginInitContext _context;
|
||||||
private bool _winRStroked;
|
private bool _winRStroked;
|
||||||
private readonly KeyboardSimulator _keyboardSimulator = new KeyboardSimulator(new InputSimulator());
|
private readonly KeyboardSimulator _keyboardSimulator = new KeyboardSimulator(new InputSimulator());
|
||||||
@ -88,7 +89,7 @@ namespace Microsoft.Plugin.Shell
|
|||||||
results.AddRange(autocomplete.ConvertAll(m => new Result
|
results.AddRange(autocomplete.ConvertAll(m => new Result
|
||||||
{
|
{
|
||||||
Title = m,
|
Title = m,
|
||||||
IcoPath = Image,
|
IcoPath = IconPath,
|
||||||
Action = c =>
|
Action = c =>
|
||||||
{
|
{
|
||||||
Execute(Process.Start, PrepareProcessStartInfo(m));
|
Execute(Process.Start, PrepareProcessStartInfo(m));
|
||||||
@ -121,7 +122,7 @@ namespace Microsoft.Plugin.Shell
|
|||||||
{
|
{
|
||||||
Title = m.Key,
|
Title = m.Key,
|
||||||
SubTitle = "Shell: " + string.Format(_context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value),
|
SubTitle = "Shell: " + string.Format(_context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value),
|
||||||
IcoPath = Image,
|
IcoPath = IconPath,
|
||||||
Action = c =>
|
Action = c =>
|
||||||
{
|
{
|
||||||
Execute(Process.Start, PrepareProcessStartInfo(m.Key));
|
Execute(Process.Start, PrepareProcessStartInfo(m.Key));
|
||||||
@ -140,7 +141,7 @@ namespace Microsoft.Plugin.Shell
|
|||||||
Title = cmd,
|
Title = cmd,
|
||||||
Score = 5000,
|
Score = 5000,
|
||||||
SubTitle = "Shell: " + _context.API.GetTranslation("wox_plugin_cmd_execute_through_shell"),
|
SubTitle = "Shell: " + _context.API.GetTranslation("wox_plugin_cmd_execute_through_shell"),
|
||||||
IcoPath = Image,
|
IcoPath = IconPath,
|
||||||
Action = c =>
|
Action = c =>
|
||||||
{
|
{
|
||||||
Execute(Process.Start, PrepareProcessStartInfo(cmd));
|
Execute(Process.Start, PrepareProcessStartInfo(cmd));
|
||||||
@ -158,7 +159,7 @@ namespace Microsoft.Plugin.Shell
|
|||||||
{
|
{
|
||||||
Title = m.Key,
|
Title = m.Key,
|
||||||
SubTitle = "Shell: " + string.Format(_context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value),
|
SubTitle = "Shell: " + string.Format(_context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value),
|
||||||
IcoPath = Image,
|
IcoPath = IconPath,
|
||||||
Action = c =>
|
Action = c =>
|
||||||
{
|
{
|
||||||
Execute(Process.Start, PrepareProcessStartInfo(m.Key));
|
Execute(Process.Start, PrepareProcessStartInfo(m.Key));
|
||||||
@ -290,6 +291,24 @@ namespace Microsoft.Plugin.Shell
|
|||||||
{
|
{
|
||||||
this._context = context;
|
this._context = context;
|
||||||
context.API.GlobalKeyboardEvent += API_GlobalKeyboardEvent;
|
context.API.GlobalKeyboardEvent += API_GlobalKeyboardEvent;
|
||||||
|
context.API.ThemeChanged += OnThemeChanged;
|
||||||
|
ResetCalculatorIconPath(context.API.GetCurrentTheme());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetCalculatorIconPath(Theme theme)
|
||||||
|
{
|
||||||
|
string ThemeString;
|
||||||
|
if (theme == Theme.Light || theme == Theme.HighContrastWhite)
|
||||||
|
ThemeString = "light";
|
||||||
|
else
|
||||||
|
ThemeString = "dark";
|
||||||
|
|
||||||
|
IconPath = "Images/shell." + ThemeString + ".png";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnThemeChanged(Theme _, Theme newTheme)
|
||||||
|
{
|
||||||
|
ResetCalculatorIconPath(newTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool API_GlobalKeyboardEvent(int keyevent, int vkcode, SpecialKeyState state)
|
bool API_GlobalKeyboardEvent(int keyevent, int vkcode, SpecialKeyState state)
|
||||||
|
@ -7,8 +7,8 @@ namespace Microsoft.Plugin.WindowWalker
|
|||||||
{
|
{
|
||||||
public class Main : IPlugin, IPluginI18n
|
public class Main : IPlugin, IPluginI18n
|
||||||
{
|
{
|
||||||
private static List<SearchResult> _results = new List<SearchResult>();
|
private static List<SearchResult> _results = new List<SearchResult>();
|
||||||
private static string IcoPath = "Images/windowwalker.dark.png";
|
private string IconPath { get; set; }
|
||||||
private PluginInitContext Context { get; set; }
|
private PluginInitContext Context { get; set; }
|
||||||
|
|
||||||
static Main()
|
static Main()
|
||||||
@ -24,7 +24,7 @@ namespace Microsoft.Plugin.WindowWalker
|
|||||||
return _results.Select(x => new Result()
|
return _results.Select(x => new Result()
|
||||||
{
|
{
|
||||||
Title = x.Result.Title,
|
Title = x.Result.Title,
|
||||||
IcoPath = IcoPath,
|
IcoPath = IconPath,
|
||||||
SubTitle = "Running: " + x.Result.ProcessName,
|
SubTitle = "Running: " + x.Result.ProcessName,
|
||||||
Action = c =>
|
Action = c =>
|
||||||
{
|
{
|
||||||
@ -37,7 +37,25 @@ namespace Microsoft.Plugin.WindowWalker
|
|||||||
|
|
||||||
public void Init(PluginInitContext context)
|
public void Init(PluginInitContext context)
|
||||||
{
|
{
|
||||||
Context = context;
|
Context = context;
|
||||||
|
Context.API.ThemeChanged += OnThemeChanged;
|
||||||
|
ResetCalculatorIconPath(context.API.GetCurrentTheme());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetCalculatorIconPath(Theme theme)
|
||||||
|
{
|
||||||
|
string ThemeString;
|
||||||
|
if (theme == Theme.Light || theme == Theme.HighContrastWhite)
|
||||||
|
ThemeString = "light";
|
||||||
|
else
|
||||||
|
ThemeString = "dark";
|
||||||
|
|
||||||
|
IconPath = "Images/windowwalker." + ThemeString + ".png";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnThemeChanged(Theme _, Theme newTheme)
|
||||||
|
{
|
||||||
|
ResetCalculatorIconPath(newTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetTranslatedPluginTitle()
|
public string GetTranslatedPluginTitle()
|
||||||
|
Loading…
Reference in New Issue
Block a user