From fcdb9e39c65ed2c6154a082054b13d869db6d087 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Sun, 9 Feb 2014 20:55:18 +0800 Subject: [PATCH] Add modifier key support when user action items. --- Plugins/Wox.Plugin.Doc/Main.cs | 2 +- Plugins/Wox.Plugin.DouBan/main.py | 4 +- Plugins/Wox.Plugin.Everything/Main.cs | 2 +- Plugins/Wox.Plugin.Fanyi/Main.cs | 2 +- Wox.Plugin.System/BrowserBookmarks.cs | 2 +- Wox.Plugin.System/CMD.cs | 6 +- Wox.Plugin.System/DirectoryIndicator.cs | 6 +- Wox.Plugin.System/Programs.cs | 2 +- Wox.Plugin.System/Setting.cs | 2 +- Wox.Plugin.System/Sys.cs | 8 +- .../ThirdpartyPluginIndicator.cs | 4 +- Wox.Plugin.System/WebSearchPlugin.cs | 2 +- Wox.Plugin/ActionContext.cs | 15 ++++ Wox.Plugin/{Plugin.cs => PluginPair.cs} | 0 Wox.Plugin/Result.cs | 8 +- Wox.Plugin/Wox.Plugin.csproj | 3 +- Wox/Helper/DwmDropShadow.cs | 73 ------------------- Wox/Helper/KeyboardListener.cs | 25 +------ Wox/MainWindow.xaml.cs | 6 +- Wox/PluginLoader/PythonPluginWrapper.cs | 33 +++++++-- Wox/ResultItem.xaml.cs | 5 +- Wox/ResultPanel.xaml.cs | 6 +- Wox/Wox.csproj | 1 - 23 files changed, 84 insertions(+), 133 deletions(-) create mode 100644 Wox.Plugin/ActionContext.cs rename Wox.Plugin/{Plugin.cs => PluginPair.cs} (100%) delete mode 100644 Wox/Helper/DwmDropShadow.cs diff --git a/Plugins/Wox.Plugin.Doc/Main.cs b/Plugins/Wox.Plugin.Doc/Main.cs index 92419c8e6a..e437bc4a92 100644 --- a/Plugins/Wox.Plugin.Doc/Main.cs +++ b/Plugins/Wox.Plugin.Doc/Main.cs @@ -135,7 +135,7 @@ namespace Wox.Plugin.Doc Title = name, SubTitle = doc.Name.Replace(".docset", ""), IcoPath = doc.IconPath, - Action = () => + Action = (c) => { string url = string.Format(@"{0}\{1}\Contents\Resources\Documents\{2}#{3}", docsetBasePath, doc.Name, docPath, name); diff --git a/Plugins/Wox.Plugin.DouBan/main.py b/Plugins/Wox.Plugin.DouBan/main.py index e74e852a82..01c855dbb5 100644 --- a/Plugins/Wox.Plugin.DouBan/main.py +++ b/Plugins/Wox.Plugin.DouBan/main.py @@ -25,7 +25,9 @@ def query(key): results.append(res) return json.dumps(results) -def openUrl(url): +def openUrl(context,url): + #shift + enter + #if context["SpecialKeyState"]["ShiftPressed"] == "True": webbrowser.open(url) if __name__ == "__main__": diff --git a/Plugins/Wox.Plugin.Everything/Main.cs b/Plugins/Wox.Plugin.Everything/Main.cs index fc3ccab710..afbb039886 100644 --- a/Plugins/Wox.Plugin.Everything/Main.cs +++ b/Plugins/Wox.Plugin.Everything/Main.cs @@ -22,7 +22,7 @@ namespace Wox.Plugin.Everything Result r = new Result(); r.Title = Path.GetFileName(s); r.SubTitle = s; - r.Action = () => + r.Action = (c) => { context.HideApp(); System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(); diff --git a/Plugins/Wox.Plugin.Fanyi/Main.cs b/Plugins/Wox.Plugin.Fanyi/Main.cs index 2623ab9bf9..6b378d14fd 100644 --- a/Plugins/Wox.Plugin.Fanyi/Main.cs +++ b/Plugins/Wox.Plugin.Fanyi/Main.cs @@ -76,7 +76,7 @@ namespace Wox.Plugin.Fanyi Title = dst, SubTitle = "Copy to clipboard", IcoPath = "Images\\translate.png", - Action = () => + Action = (c) => { Clipboard.SetText(dst); context.ShowMsg("translation has been copyed to your clipboard.", "", diff --git a/Wox.Plugin.System/BrowserBookmarks.cs b/Wox.Plugin.System/BrowserBookmarks.cs index e0dcc307c9..df008e89db 100644 --- a/Wox.Plugin.System/BrowserBookmarks.cs +++ b/Wox.Plugin.System/BrowserBookmarks.cs @@ -33,7 +33,7 @@ namespace Wox.Plugin.System SubTitle = "Bookmark: " + c.Url, IcoPath = Directory.GetCurrentDirectory() + @"\Images\bookmark.png", Score = 5, - Action = () => + Action = (context) => { try { diff --git a/Wox.Plugin.System/CMD.cs b/Wox.Plugin.System/CMD.cs index 6497f40d88..7932d20e3c 100644 --- a/Wox.Plugin.System/CMD.cs +++ b/Wox.Plugin.System/CMD.cs @@ -26,7 +26,7 @@ namespace Wox.Plugin.System Title = m.Key, SubTitle = "this command has been executed " + m.Value + " times", IcoPath = "Images/cmd.png", - Action = () => + Action = (c) => { ExecuteCmd(m.Key); AddCmdHistory(m.Key); @@ -45,7 +45,7 @@ namespace Wox.Plugin.System Score = 5000, SubTitle = "execute command through command shell", IcoPath = "Images/cmd.png", - Action = () => + Action = (c) => { ExecuteCmd(cmd); AddCmdHistory(cmd); @@ -60,7 +60,7 @@ namespace Wox.Plugin.System Title = m.Key, SubTitle = "this command has been executed " + m.Value + " times", IcoPath = "Images/cmd.png", - Action = () => + Action = (c) => { ExecuteCmd(m.Key); AddCmdHistory(m.Key); diff --git a/Wox.Plugin.System/DirectoryIndicator.cs b/Wox.Plugin.System/DirectoryIndicator.cs index a38b94f322..b4d3ce26ad 100644 --- a/Wox.Plugin.System/DirectoryIndicator.cs +++ b/Wox.Plugin.System/DirectoryIndicator.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Text; +using System.Windows.Forms; namespace Wox.Plugin.System { @@ -22,7 +23,10 @@ namespace Wox.Plugin.System SubTitle = string.Format("path: {0}", query.RawQuery), Score = 50, IcoPath = "Images/folder.png", - Action = () => Process.Start(query.RawQuery) + Action = (c) => + { + Process.Start(query.RawQuery); + } }; results.Add(result); } diff --git a/Wox.Plugin.System/Programs.cs b/Wox.Plugin.System/Programs.cs index 4c4d71854c..9ab376aebd 100644 --- a/Wox.Plugin.System/Programs.cs +++ b/Wox.Plugin.System/Programs.cs @@ -46,7 +46,7 @@ namespace Wox.Plugin.System Title = c.Title, IcoPath = c.IcoPath, Score = c.Score, - Action = () => + Action = (context) => { if (string.IsNullOrEmpty(c.ExecutePath)) { diff --git a/Wox.Plugin.System/Setting.cs b/Wox.Plugin.System/Setting.cs index 7459404945..258f674eb3 100644 --- a/Wox.Plugin.System/Setting.cs +++ b/Wox.Plugin.System/Setting.cs @@ -18,7 +18,7 @@ namespace Wox.Plugin.System Title = "Wox Setting Dialog", Score = 100, IcoPath = "Images/app.png", - Action = () => context.OpenSettingDialog() + Action = (contenxt) => context.OpenSettingDialog() }); } diff --git a/Wox.Plugin.System/Sys.cs b/Wox.Plugin.System/Sys.cs index da5c3f7e78..c34efaf704 100644 --- a/Wox.Plugin.System/Sys.cs +++ b/Wox.Plugin.System/Sys.cs @@ -47,7 +47,7 @@ namespace Wox.Plugin.System SubTitle = "Shutdown Computer", Score = 100, IcoPath = "Images\\exit.png", - Action = () => Process.Start("shutdown","/s /t 0") + Action = (c) => Process.Start("shutdown","/s /t 0") }); availableResults.Add(new Result { @@ -55,7 +55,7 @@ namespace Wox.Plugin.System SubTitle = "Log off current user", Score = 20, IcoPath = "Images\\logoff.png", - Action = () => ExitWindowsEx(EWX_LOGOFF, 0) + Action = (c) => ExitWindowsEx(EWX_LOGOFF, 0) }); availableResults.Add(new Result { @@ -63,7 +63,7 @@ namespace Wox.Plugin.System SubTitle = "Lock this computer", Score = 20, IcoPath = "Images\\lock.png", - Action = () => LockWorkStation() + Action = (c) => LockWorkStation() }); availableResults.Add(new Result { @@ -71,7 +71,7 @@ namespace Wox.Plugin.System SubTitle = "Close this app", Score = 110, IcoPath = "Images\\app.png", - Action = () => context.CloseApp() + Action = (c) => context.CloseApp() }); } } diff --git a/Wox.Plugin.System/ThirdpartyPluginIndicator.cs b/Wox.Plugin.System/ThirdpartyPluginIndicator.cs index 363042102c..b7f285789c 100644 --- a/Wox.Plugin.System/ThirdpartyPluginIndicator.cs +++ b/Wox.Plugin.System/ThirdpartyPluginIndicator.cs @@ -27,7 +27,7 @@ namespace Wox.Plugin.System SubTitle = string.Format("Activate {0} plugin", metadata.Name), Score = 50, IcoPath = "Images/work.png", - Action = () => changeQuery(metadataCopy.ActionKeyword + " "), + Action = (c) => changeQuery(metadataCopy.ActionKeyword + " "), DontHideWoxAfterSelect = true }; results.Add(result); @@ -40,7 +40,7 @@ namespace Wox.Plugin.System SubTitle = string.Format("Activate {0} web search", n.ActionWord), Score = 50, IcoPath = "Images/work.png", - Action = () => changeQuery(n.ActionWord + " "), + Action = (c) => changeQuery(n.ActionWord + " "), DontHideWoxAfterSelect = true })); diff --git a/Wox.Plugin.System/WebSearchPlugin.cs b/Wox.Plugin.System/WebSearchPlugin.cs index 35049201af..430cb78542 100644 --- a/Wox.Plugin.System/WebSearchPlugin.cs +++ b/Wox.Plugin.System/WebSearchPlugin.cs @@ -26,7 +26,7 @@ namespace Wox.Plugin.System { Title = string.Format("Search {0} for \"{1}\"", webSearch.Title, keyword), IcoPath = webSearch.IconPath, - Action = () => Process.Start(webSearch.Url.Replace("{q}", keyword)) + Action = (c) => Process.Start(webSearch.Url.Replace("{q}", keyword)) }); } diff --git a/Wox.Plugin/ActionContext.cs b/Wox.Plugin/ActionContext.cs new file mode 100644 index 0000000000..94f6ba252c --- /dev/null +++ b/Wox.Plugin/ActionContext.cs @@ -0,0 +1,15 @@ +namespace Wox.Plugin +{ + public class ActionContext + { + 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; } + } +} \ No newline at end of file diff --git a/Wox.Plugin/Plugin.cs b/Wox.Plugin/PluginPair.cs similarity index 100% rename from Wox.Plugin/Plugin.cs rename to Wox.Plugin/PluginPair.cs diff --git a/Wox.Plugin/Result.cs b/Wox.Plugin/Result.cs index b0f40e99d5..21e539db31 100644 --- a/Wox.Plugin/Result.cs +++ b/Wox.Plugin/Result.cs @@ -9,7 +9,7 @@ namespace Wox.Plugin public string Title { get; set; } public string SubTitle { get; set; } public string IcoPath { get; set; } - public Action Action { get; set; } + public Action Action { get; set; } public int Score { get; set; } public bool DontHideWoxAfterSelect { get; set; } @@ -24,13 +24,9 @@ namespace Wox.Plugin /// Only resulsts that originQuery match with curren query will be displayed in the panel /// public Query OriginQuery { get; set; } - /// - /// context results connected with current reuslt, usually, it can use <- or -> navigate context results - /// - public List ContextResults { get; set; } /// - /// you don't need to set this property if you are developing a plugin + /// Don't set this property if you are developing a plugin /// public string PluginDirectory { get; set; } diff --git a/Wox.Plugin/Wox.Plugin.csproj b/Wox.Plugin/Wox.Plugin.csproj index 18260ef144..4b5c216b61 100644 --- a/Wox.Plugin/Wox.Plugin.csproj +++ b/Wox.Plugin/Wox.Plugin.csproj @@ -59,7 +59,7 @@ - + @@ -67,6 +67,7 @@ +