diff --git a/Plugins/Wox.Plugin.Shell/Main.cs b/Plugins/Wox.Plugin.Shell/Main.cs index 1504b0befd..ad72b16431 100644 --- a/Plugins/Wox.Plugin.Shell/Main.cs +++ b/Plugins/Wox.Plugin.Shell/Main.cs @@ -12,19 +12,19 @@ using Application = System.Windows.Application; using Control = System.Windows.Controls.Control; using Keys = System.Windows.Forms.Keys; -namespace Wox.Plugin.CMD +namespace Wox.Plugin.Shell { - public class CMD : IPlugin, ISettingProvider, IPluginI18n, IContextMenu, ISavable + public class Main : IPlugin, ISettingProvider, IPluginI18n, IContextMenu, ISavable { private const string Image = "Images/shell.png"; - private PluginInitContext context; - private bool WinRStroked; - private readonly KeyboardSimulator keyboardSimulator = new KeyboardSimulator(new InputSimulator()); + private PluginInitContext _context; + private bool _winRStroked; + private readonly KeyboardSimulator _keyboardSimulator = new KeyboardSimulator(new InputSimulator()); private readonly Settings _settings; private readonly PluginJsonStorage _storage; - public CMD() + public Main() { _storage = new PluginJsonStorage(); _settings = _storage.Load(); @@ -104,14 +104,14 @@ namespace Wox.Plugin.CMD { if (m.Key == cmd) { - result.SubTitle = string.Format(context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value); + result.SubTitle = string.Format(_context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value); return null; } var ret = new Result { Title = m.Key, - SubTitle = string.Format(context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value), + SubTitle = string.Format(_context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value), IcoPath = Image, Action = c => { @@ -130,7 +130,7 @@ namespace Wox.Plugin.CMD { Title = cmd, Score = 5000, - SubTitle = context.API.GetTranslation("wox_plugin_cmd_execute_through_shell"), + SubTitle = _context.API.GetTranslation("wox_plugin_cmd_execute_through_shell"), IcoPath = Image, Action = c => { @@ -148,7 +148,7 @@ namespace Wox.Plugin.CMD .Select(m => new Result { Title = m.Key, - SubTitle = string.Format(context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value), + SubTitle = string.Format(_context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value), IcoPath = Image, Action = c => { @@ -165,7 +165,7 @@ namespace Wox.Plugin.CMD command = Environment.ExpandEnvironmentVariables(command); ProcessStartInfo info; - if (_settings.Shell == Shell.CMD) + if (_settings.Shell == Shell.Cmd) { var arguments = _settings.LeaveShellOpen ? $"/k \"{command}\"" : $"/c \"{command}\" & pause"; info = new ProcessStartInfo @@ -268,7 +268,7 @@ namespace Wox.Plugin.CMD public void Init(PluginInitContext context) { - this.context = context; + this._context = context; context.API.GlobalKeyboardEvent += API_GlobalKeyboardEvent; } @@ -278,13 +278,13 @@ namespace Wox.Plugin.CMD { if (keyevent == (int)KeyEvent.WM_KEYDOWN && vkcode == (int)Keys.R && state.WinPressed) { - WinRStroked = true; + _winRStroked = true; OnWinRPressed(); return false; } - if (keyevent == (int)KeyEvent.WM_KEYUP && WinRStroked && vkcode == (int)Keys.LWin) + if (keyevent == (int)KeyEvent.WM_KEYUP && _winRStroked && vkcode == (int)Keys.LWin) { - WinRStroked = false; + _winRStroked = false; return false; } } @@ -293,7 +293,7 @@ namespace Wox.Plugin.CMD private void OnWinRPressed() { - context.API.ChangeQuery($"{context.CurrentPluginMetadata.ActionKeywords[0]}{Plugin.Query.TermSeperater}"); + _context.API.ChangeQuery($"{_context.CurrentPluginMetadata.ActionKeywords[0]}{Plugin.Query.TermSeperater}"); Application.Current.MainWindow.Visibility = Visibility.Visible; } @@ -304,12 +304,12 @@ namespace Wox.Plugin.CMD public string GetTranslatedPluginTitle() { - return context.API.GetTranslation("wox_plugin_cmd_plugin_name"); + return _context.API.GetTranslation("wox_plugin_cmd_plugin_name"); } public string GetTranslatedPluginDescription() { - return context.API.GetTranslation("wox_plugin_cmd_plugin_description"); + return _context.API.GetTranslation("wox_plugin_cmd_plugin_description"); } public List LoadContextMenus(Result selectedResult) @@ -318,7 +318,7 @@ namespace Wox.Plugin.CMD { new Result { - Title = context.API.GetTranslation("wox_plugin_cmd_run_as_administrator"), + Title = _context.API.GetTranslation("wox_plugin_cmd_run_as_administrator"), Action = c => { Execute(selectedResult.Title, true); diff --git a/Plugins/Wox.Plugin.Shell/Settings.cs b/Plugins/Wox.Plugin.Shell/Settings.cs index 2734097395..62eb31f4e3 100644 --- a/Plugins/Wox.Plugin.Shell/Settings.cs +++ b/Plugins/Wox.Plugin.Shell/Settings.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; -namespace Wox.Plugin.CMD +namespace Wox.Plugin.Shell { public class Settings { - public Shell Shell { get; set; } = Shell.CMD; + public Shell Shell { get; set; } = Shell.Cmd; public bool ReplaceWinR { get; set; } = true; public bool LeaveShellOpen { get; set; } public Dictionary Count = new Dictionary(); @@ -24,7 +24,7 @@ namespace Wox.Plugin.CMD public enum Shell { - CMD = 0, + Cmd = 0, Powershell = 1, RunCommand = 2, diff --git a/Plugins/Wox.Plugin.Shell/ShellSetting.xaml b/Plugins/Wox.Plugin.Shell/ShellSetting.xaml index a0d4ae7d96..f631f6e228 100644 --- a/Plugins/Wox.Plugin.Shell/ShellSetting.xaml +++ b/Plugins/Wox.Plugin.Shell/ShellSetting.xaml @@ -1,4 +1,4 @@ -