fix names

This commit is contained in:
bao-qian
2016-06-23 22:53:30 +01:00
parent 04275cd702
commit d84ac0df9c
5 changed files with 24 additions and 27 deletions

View File

@@ -12,19 +12,19 @@ using Application = System.Windows.Application;
using Control = System.Windows.Controls.Control; using Control = System.Windows.Controls.Control;
using Keys = System.Windows.Forms.Keys; 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 const string Image = "Images/shell.png";
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());
private readonly Settings _settings; private readonly Settings _settings;
private readonly PluginJsonStorage<Settings> _storage; private readonly PluginJsonStorage<Settings> _storage;
public CMD() public Main()
{ {
_storage = new PluginJsonStorage<Settings>(); _storage = new PluginJsonStorage<Settings>();
_settings = _storage.Load(); _settings = _storage.Load();
@@ -104,14 +104,14 @@ namespace Wox.Plugin.CMD
{ {
if (m.Key == 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; return null;
} }
var ret = new Result var ret = new Result
{ {
Title = m.Key, 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, IcoPath = Image,
Action = c => Action = c =>
{ {
@@ -130,7 +130,7 @@ namespace Wox.Plugin.CMD
{ {
Title = cmd, Title = cmd,
Score = 5000, Score = 5000,
SubTitle = context.API.GetTranslation("wox_plugin_cmd_execute_through_shell"), SubTitle = _context.API.GetTranslation("wox_plugin_cmd_execute_through_shell"),
IcoPath = Image, IcoPath = Image,
Action = c => Action = c =>
{ {
@@ -148,7 +148,7 @@ namespace Wox.Plugin.CMD
.Select(m => new Result .Select(m => new Result
{ {
Title = m.Key, 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, IcoPath = Image,
Action = c => Action = c =>
{ {
@@ -165,7 +165,7 @@ namespace Wox.Plugin.CMD
command = Environment.ExpandEnvironmentVariables(command); command = Environment.ExpandEnvironmentVariables(command);
ProcessStartInfo info; ProcessStartInfo info;
if (_settings.Shell == Shell.CMD) if (_settings.Shell == Shell.Cmd)
{ {
var arguments = _settings.LeaveShellOpen ? $"/k \"{command}\"" : $"/c \"{command}\" & pause"; var arguments = _settings.LeaveShellOpen ? $"/k \"{command}\"" : $"/c \"{command}\" & pause";
info = new ProcessStartInfo info = new ProcessStartInfo
@@ -268,7 +268,7 @@ namespace Wox.Plugin.CMD
public void Init(PluginInitContext context) public void Init(PluginInitContext context)
{ {
this.context = context; this._context = context;
context.API.GlobalKeyboardEvent += API_GlobalKeyboardEvent; 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) if (keyevent == (int)KeyEvent.WM_KEYDOWN && vkcode == (int)Keys.R && state.WinPressed)
{ {
WinRStroked = true; _winRStroked = true;
OnWinRPressed(); OnWinRPressed();
return false; 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; return false;
} }
} }
@@ -293,7 +293,7 @@ namespace Wox.Plugin.CMD
private void OnWinRPressed() 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; Application.Current.MainWindow.Visibility = Visibility.Visible;
} }
@@ -304,12 +304,12 @@ namespace Wox.Plugin.CMD
public string GetTranslatedPluginTitle() public string GetTranslatedPluginTitle()
{ {
return context.API.GetTranslation("wox_plugin_cmd_plugin_name"); return _context.API.GetTranslation("wox_plugin_cmd_plugin_name");
} }
public string GetTranslatedPluginDescription() public string GetTranslatedPluginDescription()
{ {
return context.API.GetTranslation("wox_plugin_cmd_plugin_description"); return _context.API.GetTranslation("wox_plugin_cmd_plugin_description");
} }
public List<Result> LoadContextMenus(Result selectedResult) public List<Result> LoadContextMenus(Result selectedResult)
@@ -318,7 +318,7 @@ namespace Wox.Plugin.CMD
{ {
new Result new Result
{ {
Title = context.API.GetTranslation("wox_plugin_cmd_run_as_administrator"), Title = _context.API.GetTranslation("wox_plugin_cmd_run_as_administrator"),
Action = c => Action = c =>
{ {
Execute(selectedResult.Title, true); Execute(selectedResult.Title, true);

View File

@@ -1,10 +1,10 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace Wox.Plugin.CMD namespace Wox.Plugin.Shell
{ {
public class Settings 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 ReplaceWinR { get; set; } = true;
public bool LeaveShellOpen { get; set; } public bool LeaveShellOpen { get; set; }
public Dictionary<string, int> Count = new Dictionary<string, int>(); public Dictionary<string, int> Count = new Dictionary<string, int>();
@@ -24,7 +24,7 @@ namespace Wox.Plugin.CMD
public enum Shell public enum Shell
{ {
CMD = 0, Cmd = 0,
Powershell = 1, Powershell = 1,
RunCommand = 2, RunCommand = 2,

View File

@@ -1,4 +1,4 @@
<UserControl x:Class="Wox.Plugin.CMD.CMDSetting" <UserControl x:Class="Wox.Plugin.Shell.CMDSetting"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

View File

@@ -1,7 +1,7 @@
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
namespace Wox.Plugin.CMD namespace Wox.Plugin.Shell
{ {
public partial class CMDSetting : UserControl public partial class CMDSetting : UserControl
{ {

View File

@@ -70,9 +70,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Calculator", "Plugins\Wox.Plugin.Calculator\Wox.Plugin.Calculator.csproj", "{59BD9891-3837-438A-958D-ADC7F91F6F7E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Calculator", "Plugins\Wox.Plugin.Calculator\Wox.Plugin.Calculator.csproj", "{59BD9891-3837-438A-958D-ADC7F91F6F7E}"
EndProject EndProject
Global Global
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64