From 1eb3f449e2f239b7df6e58e7a1b66405e5d2ed59 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Fri, 3 Jan 2014 18:16:05 +0800 Subject: [PATCH 01/16] Add system commands --- WinAlfred.Plugin.System/CMD.cs | 20 +++++++ WinAlfred.Plugin.System/ISystemPlugin.cs | 11 ++++ .../Properties/AssemblyInfo.cs | 36 +++++++++++ .../WinAlfred.Plugin.System.csproj | 59 +++++++++++++++++++ WinAlfred.Plugin/PluginMetadata.cs | 1 + WinAlfred.Plugin/PluginType.cs | 13 ++++ WinAlfred.Plugin/WinAlfred.Plugin.csproj | 1 + WinAlfred.sln | 16 +++++ WinAlfred/Commands/CommandDispatcher.cs | 31 ++++++++++ WinAlfred/Commands/PluginCommand.cs | 45 ++++++++++++++ WinAlfred/Commands/SystemCommand.cs | 16 +++++ WinAlfred/MainWindow.xaml.cs | 41 ++----------- WinAlfred/PluginLoader/BasePluginLoader.cs | 39 +++++++++--- WinAlfred/PluginLoader/Plugins.cs | 25 ++++++++ WinAlfred/WinAlfred.csproj | 8 +++ 15 files changed, 317 insertions(+), 45 deletions(-) create mode 100644 WinAlfred.Plugin.System/CMD.cs create mode 100644 WinAlfred.Plugin.System/ISystemPlugin.cs create mode 100644 WinAlfred.Plugin.System/Properties/AssemblyInfo.cs create mode 100644 WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj create mode 100644 WinAlfred.Plugin/PluginType.cs create mode 100644 WinAlfred/Commands/CommandDispatcher.cs create mode 100644 WinAlfred/Commands/PluginCommand.cs create mode 100644 WinAlfred/Commands/SystemCommand.cs create mode 100644 WinAlfred/PluginLoader/Plugins.cs diff --git a/WinAlfred.Plugin.System/CMD.cs b/WinAlfred.Plugin.System/CMD.cs new file mode 100644 index 0000000000..1175f58d7b --- /dev/null +++ b/WinAlfred.Plugin.System/CMD.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace WinAlfred.Plugin.System +{ + public class CMD:IPlugin + { + public List Query(Query query) + { + throw new NotImplementedException(); + } + + public void Init() + { + throw new NotImplementedException(); + } + } +} diff --git a/WinAlfred.Plugin.System/ISystemPlugin.cs b/WinAlfred.Plugin.System/ISystemPlugin.cs new file mode 100644 index 0000000000..3eb6f9dbf6 --- /dev/null +++ b/WinAlfred.Plugin.System/ISystemPlugin.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace WinAlfred.Plugin.System +{ + public interface ISystemPlugin : IPlugin + { + } +} diff --git a/WinAlfred.Plugin.System/Properties/AssemblyInfo.cs b/WinAlfred.Plugin.System/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..4e78f925c4 --- /dev/null +++ b/WinAlfred.Plugin.System/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("WinAlfred.Plugin.System")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Oracle Corporation")] +[assembly: AssemblyProduct("WinAlfred.Plugin.System")] +[assembly: AssemblyCopyright("Copyright © Oracle Corporation 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("bab8d3dc-d6be-42b3-8aa4-24801d667528")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj b/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj new file mode 100644 index 0000000000..ae8c238f6c --- /dev/null +++ b/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj @@ -0,0 +1,59 @@ + + + + + Debug + AnyCPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8} + Library + Properties + WinAlfred.Plugin.System + WinAlfred.Plugin.System + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80} + WinAlfred.Plugin + + + + + \ No newline at end of file diff --git a/WinAlfred.Plugin/PluginMetadata.cs b/WinAlfred.Plugin/PluginMetadata.cs index 23d54b8c24..167e299e51 100644 --- a/WinAlfred.Plugin/PluginMetadata.cs +++ b/WinAlfred.Plugin/PluginMetadata.cs @@ -16,5 +16,6 @@ namespace WinAlfred.Plugin public string ExecuteFileName { get; set; } public string PluginDirecotry { get; set; } public string ActionKeyword { get; set; } + public PluginType PluginType { get; set; } } } diff --git a/WinAlfred.Plugin/PluginType.cs b/WinAlfred.Plugin/PluginType.cs new file mode 100644 index 0000000000..1db293c16a --- /dev/null +++ b/WinAlfred.Plugin/PluginType.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace WinAlfred.Plugin +{ + public enum PluginType + { + System, + ThirdParty + } +} diff --git a/WinAlfred.Plugin/WinAlfred.Plugin.csproj b/WinAlfred.Plugin/WinAlfred.Plugin.csproj index e0b1b3869d..8d13730b5d 100644 --- a/WinAlfred.Plugin/WinAlfred.Plugin.csproj +++ b/WinAlfred.Plugin/WinAlfred.Plugin.csproj @@ -61,6 +61,7 @@ + diff --git a/WinAlfred.sln b/WinAlfred.sln index 1b27e33db8..a90d1236b2 100644 --- a/WinAlfred.sln +++ b/WinAlfred.sln @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred", "WinAlfred\WinA EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PyWinAlfred", "PyWinAlfred\PyWinAlfred.vcxproj", "{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred.Plugin.System", "WinAlfred.Plugin.System\WinAlfred.Plugin.System.csproj", "{69CE0206-CB41-453D-88AF-DF86092EF9B8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -104,6 +106,20 @@ Global {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|x64.Build.0 = Release|x64 {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|x86.ActiveCfg = Release|Win32 {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|x86.Build.0 = Release|Win32 + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Win32.ActiveCfg = Debug|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|x64.ActiveCfg = Debug|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|x86.ActiveCfg = Debug|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Any CPU.Build.0 = Release|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Win32.ActiveCfg = Release|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|x64.ActiveCfg = Release|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/WinAlfred/Commands/CommandDispatcher.cs b/WinAlfred/Commands/CommandDispatcher.cs new file mode 100644 index 0000000000..e6f0f691ce --- /dev/null +++ b/WinAlfred/Commands/CommandDispatcher.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using WinAlfred.Helper; +using WinAlfred.Plugin; + +namespace WinAlfred.Commands +{ + public class CommandDispatcher + { + private PluginCommand pluginCmd = new PluginCommand(); + private SystemCommand systemCmd = new SystemCommand(); + + //public delegate void resultUpdateDelegate(List results); + + //public event resultUpdateDelegate OnResultUpdateEvent; + + //protected virtual void OnOnResultUpdateEvent(List list) + //{ + // resultUpdateDelegate handler = OnResultUpdateEvent; + // if (handler != null) handler(list); + //} + + public void DispatchCommand(Query query) + { + systemCmd.Dispatch(query); + pluginCmd.Dispatch(query); + } + } +} diff --git a/WinAlfred/Commands/PluginCommand.cs b/WinAlfred/Commands/PluginCommand.cs new file mode 100644 index 0000000000..37e1de91d5 --- /dev/null +++ b/WinAlfred/Commands/PluginCommand.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using WinAlfred.Helper; +using WinAlfred.Plugin; +using WinAlfred.PluginLoader; + +namespace WinAlfred.Commands +{ + public class PluginCommand + { + public void Dispatch(Query q) + { + //ThreadPool.QueueUserWorkItem(state => + //{ + foreach (PluginPair pair in Plugins.AllPlugins) + { + if (pair.Metadata.ActionKeyword == q.ActionName) + { + try + { + pair.Plugin.Query(q).ForEach(o => o.PluginDirectory = pair.Metadata.PluginDirecotry); + } + catch (Exception queryException) + { + Log.Error(string.Format("Plugin {0} query failed: {1}", pair.Metadata.Name, + queryException.Message)); +#if (DEBUG) + { + throw; + } +#endif + } + } + } + resultCtrl.Dispatcher.Invoke(new Action(() => + { + resultCtrl.AddResults(results.OrderByDescending(o => o.Score).ToList()); + resultCtrl.SelectFirst(); + })); + //}); + } + } +} diff --git a/WinAlfred/Commands/SystemCommand.cs b/WinAlfred/Commands/SystemCommand.cs new file mode 100644 index 0000000000..4544150694 --- /dev/null +++ b/WinAlfred/Commands/SystemCommand.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using WinAlfred.Plugin; + +namespace WinAlfred.Commands +{ + public class SystemCommand + { + public void Dispatch(Query query) + { + + } + } +} diff --git a/WinAlfred/MainWindow.xaml.cs b/WinAlfred/MainWindow.xaml.cs index 0c3d2aa2c3..9b5dbf78ab 100644 --- a/WinAlfred/MainWindow.xaml.cs +++ b/WinAlfred/MainWindow.xaml.cs @@ -8,6 +8,7 @@ using System.Windows.Controls; using System.Windows.Forms; using System.Windows.Input; using System.Windows.Threading; +using WinAlfred.Commands; using WinAlfred.Helper; using WinAlfred.Plugin; using WinAlfred.PluginLoader; @@ -18,9 +19,9 @@ namespace WinAlfred public partial class MainWindow : Window { private KeyboardHook hook = new KeyboardHook(); - public List plugins = new List(); private List results = new List(); private NotifyIcon notifyIcon = null; + private CommandDispatcher cmdDispatcher = new CommandDispatcher(); public MainWindow() { @@ -67,38 +68,8 @@ namespace WinAlfred private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e) { - string query = tbQuery.Text; - //ThreadPool.QueueUserWorkItem(state => - //{ - results.Clear(); - foreach (PluginPair pair in plugins) - { - var q = new Query(query); - if (pair.Metadata.ActionKeyword == q.ActionName) - { - try - { - results.AddRange(pair.Plugin.Query(q)); - results.ForEach(o => o.PluginDirectory = pair.Metadata.PluginDirecotry); - } - catch (Exception queryException) - { - Log.Error(string.Format("Plugin {0} query failed: {1}", pair.Metadata.Name, - queryException.Message)); -#if (DEBUG) - { - throw; - } -#endif - } - } - } - resultCtrl.Dispatcher.Invoke(new Action(() => - { - resultCtrl.AddResults(results.OrderByDescending(o => o.Score).ToList()); - resultCtrl.SelectFirst(); - })); - //}); + var q = new Query(tbQuery.Text); + cmdDispatcher.DispatchCommand(q); } private void HideWinAlfred() @@ -116,9 +87,7 @@ namespace WinAlfred private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { - plugins.AddRange(new PythonPluginLoader().LoadPlugin()); - plugins.AddRange(new CSharpPluginLoader().LoadPlugin()); - + Plugins.Init(); ShowWinAlfred(); InitialTray(); } diff --git a/WinAlfred/PluginLoader/BasePluginLoader.cs b/WinAlfred/PluginLoader/BasePluginLoader.cs index d16042b494..7aeb83dd04 100644 --- a/WinAlfred/PluginLoader/BasePluginLoader.cs +++ b/WinAlfred/PluginLoader/BasePluginLoader.cs @@ -1,8 +1,11 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; +using System.Reflection; using WinAlfred.Helper; using WinAlfred.Plugin; +using WinAlfred.Plugin.System; namespace WinAlfred.PluginLoader { @@ -21,11 +24,34 @@ namespace WinAlfred.PluginLoader private static void ParsePlugins() { - ParseDirectories(); - ParsePackagedPlugin(); + ParseSystemPlugins(); + ParseThirdPartyPlugins(); } - private static void ParseDirectories() + private static void ParseSystemPlugins() + { + try + { + Assembly asm = Assembly.GetAssembly(typeof (CMD)); + List types = asm.GetTypes().Where(o => o.GetInterfaces().Contains(typeof(ISystemPlugin))).ToList(); + foreach (Type type in types) + { + ISystemPlugin sysPlugin = Activator.CreateInstance(types[0]) as ISystemPlugin; + PluginMetadata metadata = new PluginMetadata(); + } + } + catch (Exception e) + { + Log.Error(string.Format("Cound't load system plugin: {0}", e.Message)); +#if (DEBUG) + { + throw; + } +#endif + } + } + + private static void ParseThirdPartyPlugins() { string[] directories = Directory.GetDirectories(PluginPath); foreach (string directory in directories) @@ -35,11 +61,6 @@ namespace WinAlfred.PluginLoader } } - private static void ParsePackagedPlugin() - { - - } - private static PluginMetadata GetMetadataFromIni(string directory) { string iniPath = directory + "\\" + PluginConfigName; @@ -50,7 +71,6 @@ namespace WinAlfred.PluginLoader return null; } - try { PluginMetadata metadata = new PluginMetadata(); @@ -60,6 +80,7 @@ namespace WinAlfred.PluginLoader metadata.Description = ini.GetSetting("plugin", "Description"); metadata.Language = ini.GetSetting("plugin", "Language"); metadata.Version = ini.GetSetting("plugin", "Version"); + metadata.PluginType = PluginType.ThirdParty; metadata.ActionKeyword = ini.GetSetting("plugin", "ActionKeyword"); metadata.ExecuteFilePath = AppDomain.CurrentDomain.BaseDirectory + directory + "\\" + ini.GetSetting("plugin", "ExecuteFile"); metadata.PluginDirecotry = AppDomain.CurrentDomain.BaseDirectory + directory + "\\"; diff --git a/WinAlfred/PluginLoader/Plugins.cs b/WinAlfred/PluginLoader/Plugins.cs new file mode 100644 index 0000000000..b744b351a5 --- /dev/null +++ b/WinAlfred/PluginLoader/Plugins.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using WinAlfred.Plugin; + +namespace WinAlfred.PluginLoader +{ + public static class Plugins + { + private static List plugins = new List(); + + public static void Init() + { + plugins.Clear(); + plugins.AddRange(new PythonPluginLoader().LoadPlugin()); + plugins.AddRange(new CSharpPluginLoader().LoadPlugin()); + } + + public static List AllPlugins + { + get { return plugins; } + } + } +} diff --git a/WinAlfred/WinAlfred.csproj b/WinAlfred/WinAlfred.csproj index 02dcadb309..5806e4e447 100644 --- a/WinAlfred/WinAlfred.csproj +++ b/WinAlfred/WinAlfred.csproj @@ -64,12 +64,16 @@ MSBuild:Compile Designer + + + + @@ -128,6 +132,10 @@ + + {69ce0206-cb41-453d-88af-df86092ef9b8} + WinAlfred.Plugin.System + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80} WinAlfred.Plugin From dc51bc39abf06af3d1828d44eb9c1a9b7110f1b7 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Fri, 3 Jan 2014 23:52:36 +0800 Subject: [PATCH 02/16] structure change --- .../Properties/AssemblyInfo.cs | 36 --------- .../WinAlfred.Plugin.System.csproj | 72 ------------------ Plugins/WinAlfred.Plugin.System/plugin.ini | 8 -- WinAlfred.Plugin.System/CMD.cs | 47 +++++++++++- WinAlfred.Plugin.System/ISystemPlugin.cs | 2 + .../Main.cs => WinAlfred.Plugin.System/Sys.cs | 35 ++++++--- .../WinAlfred.Plugin.System.csproj | 7 ++ WinAlfred.Plugin/IPlugin.cs | 2 +- WinAlfred.Plugin/PluginInitContext.cs | 13 ++++ WinAlfred.Plugin/Result.cs | 9 +++ WinAlfred.Plugin/WinAlfred.Plugin.csproj | 1 + WinAlfred.sln | 19 ----- WinAlfred/Commands/Command.cs | 27 +++++++ WinAlfred/Commands/CommandDispatcher.cs | 31 -------- WinAlfred/Commands/PluginCommand.cs | 50 +++++++----- WinAlfred/Commands/SystemCommand.cs | 29 ++++++- .../Images/lock.png | Bin WinAlfred/MainWindow.xaml.cs | 38 ++++++++- WinAlfred/PluginLoader/BasePluginLoader.cs | 31 +++----- WinAlfred/PluginLoader/CSharpPluginLoader.cs | 29 +++---- WinAlfred/PluginLoader/Plugins.cs | 16 +++- WinAlfred/PluginLoader/PythonPluginLoader.cs | 4 - WinAlfred/PluginLoader/PythonPluginWrapper.cs | 2 +- WinAlfred/ResultItem.xaml | 2 +- WinAlfred/ResultItem.xaml.cs | 3 +- WinAlfred/ResultPanel.xaml.cs | 25 +++++- WinAlfred/WinAlfred.csproj | 8 +- 27 files changed, 289 insertions(+), 257 deletions(-) delete mode 100644 Plugins/WinAlfred.Plugin.System/Properties/AssemblyInfo.cs delete mode 100644 Plugins/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj delete mode 100644 Plugins/WinAlfred.Plugin.System/plugin.ini rename Plugins/WinAlfred.Plugin.System/Main.cs => WinAlfred.Plugin.System/Sys.cs (70%) create mode 100644 WinAlfred.Plugin/PluginInitContext.cs create mode 100644 WinAlfred/Commands/Command.cs delete mode 100644 WinAlfred/Commands/CommandDispatcher.cs rename {Plugins/WinAlfred.Plugin.System => WinAlfred}/Images/lock.png (100%) diff --git a/Plugins/WinAlfred.Plugin.System/Properties/AssemblyInfo.cs b/Plugins/WinAlfred.Plugin.System/Properties/AssemblyInfo.cs deleted file mode 100644 index 9f1336c2fa..0000000000 --- a/Plugins/WinAlfred.Plugin.System/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// 有关程序集的常规信息通过以下 -// 特性集控制。更改这些特性值可修改 -// 与程序集关联的信息。 -[assembly: AssemblyTitle("WinAlfred.Plugin.System")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("WinAlfred.Plugin.System")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2013")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// 将 ComVisible 设置为 false 使此程序集中的类型 -// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, -// 则将该类型上的 ComVisible 特性设置为 true。 -[assembly: ComVisible(false)] - -// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID -[assembly: Guid("5cdfe514-80c9-4d82-94e7-c6f79a26ccda")] - -// 程序集的版本信息由下面四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, -// 方法是按如下所示使用“*”: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Plugins/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj b/Plugins/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj deleted file mode 100644 index a8dacb8d11..0000000000 --- a/Plugins/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj +++ /dev/null @@ -1,72 +0,0 @@ - - - - - Debug - AnyCPU - {E515011D-A769-418B-8761-ABE6F29827A0} - Library - Properties - WinAlfred.Plugin.System - WinAlfred.Plugin.System - v3.5 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} - WinAlfred.Plugin - - - - - Always - - - - - - - - xcopy /Y $(TargetDir)$(TargetFileName) $(SolutionDir)WinAlfred\bin\Debug\Plugins\System\ -xcopy /Y $(TargetDir)plugin.ini $(SolutionDir)WinAlfred\bin\Debug\Plugins\System\ -xcopy /Y $(ProjectDir)Images\*.* $(SolutionDir)WinAlfred\bin\Debug\Plugins\System\Images\ - - - \ No newline at end of file diff --git a/Plugins/WinAlfred.Plugin.System/plugin.ini b/Plugins/WinAlfred.Plugin.System/plugin.ini deleted file mode 100644 index 5b49554ca6..0000000000 --- a/Plugins/WinAlfred.Plugin.System/plugin.ini +++ /dev/null @@ -1,8 +0,0 @@ -[plugin] -ActionKeyword = sys -Name = System Commands -Author = qianlifeng -Version = 0.1 -Language = csharp -Description = test -ExecuteFile = WinAlfred.Plugin.System.dll diff --git a/WinAlfred.Plugin.System/CMD.cs b/WinAlfred.Plugin.System/CMD.cs index 1175f58d7b..ef7aedd011 100644 --- a/WinAlfred.Plugin.System/CMD.cs +++ b/WinAlfred.Plugin.System/CMD.cs @@ -1,20 +1,59 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; +using System.Windows.Forms; namespace WinAlfred.Plugin.System { - public class CMD:IPlugin + public class CMD : ISystemPlugin { public List Query(Query query) { - throw new NotImplementedException(); + List results = new List(); + if (query.RawQuery.StartsWith(">") && query.RawQuery.Length > 1) + { + string cmd = query.RawQuery.Substring(1); + Result result = new Result + { + Title = cmd, + SubTitle = "execute command through command shell" , + IcoPath = "Images/cmd.png", + Action = () => + { + Process process = new Process(); + ProcessStartInfo startInfo = new ProcessStartInfo(); + startInfo.WindowStyle = ProcessWindowStyle.Hidden; + startInfo.FileName = "cmd.exe"; + startInfo.Arguments = "/C " + cmd; + process.StartInfo = startInfo; + process.Start(); + } + }; + results.Add(result); + } + return results; } - public void Init() + public void Init(PluginInitContext context) { - throw new NotImplementedException(); + } + + public string Name + { + get + { + return "CMD"; + } + } + + public string Description + { + get + { + return "Execute shell commands."; + } } } } diff --git a/WinAlfred.Plugin.System/ISystemPlugin.cs b/WinAlfred.Plugin.System/ISystemPlugin.cs index 3eb6f9dbf6..dcb428d352 100644 --- a/WinAlfred.Plugin.System/ISystemPlugin.cs +++ b/WinAlfred.Plugin.System/ISystemPlugin.cs @@ -7,5 +7,7 @@ namespace WinAlfred.Plugin.System { public interface ISystemPlugin : IPlugin { + string Name { get; } + string Description { get; } } } diff --git a/Plugins/WinAlfred.Plugin.System/Main.cs b/WinAlfred.Plugin.System/Sys.cs similarity index 70% rename from Plugins/WinAlfred.Plugin.System/Main.cs rename to WinAlfred.Plugin.System/Sys.cs index 9cd5d7d9ea..5dceba034b 100644 --- a/Plugins/WinAlfred.Plugin.System/Main.cs +++ b/WinAlfred.Plugin.System/Sys.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text; @@ -8,7 +7,7 @@ using System.Windows.Forms; namespace WinAlfred.Plugin.System { - public class Main : IPlugin + public class Sys : ISystemPlugin { List availableResults = new List(); @@ -20,18 +19,18 @@ namespace WinAlfred.Plugin.System public List Query(Query query) { List results = new List(); - if (query.ActionParameters.Count == 0) + + foreach (Result availableResult in availableResults) { - results = availableResults; - } - else - { - results.AddRange(availableResults.Where(result => result.Title.ToLower().Contains(query.ActionParameters[0].ToLower()))); + if (availableResult.Title.ToLower().StartsWith(query.RawQuery.ToLower())) + { + results.Add(availableResult); + } } return results; } - public void Init() + public void Init(PluginInitContext context) { availableResults.Add(new Result { @@ -54,7 +53,23 @@ namespace WinAlfred.Plugin.System Score = 20, IcoPath = "Images\\lock.png", Action = () => LockWorkStation() - }); + }); + } + + public string Name + { + get + { + return "sys"; + } + } + + public string Description + { + get + { + return "provide system commands"; + } } } } diff --git a/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj b/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj index ae8c238f6c..b822bafe1d 100644 --- a/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj +++ b/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj @@ -32,6 +32,7 @@ + @@ -41,6 +42,8 @@ + + @@ -49,6 +52,10 @@ + + + + + \ No newline at end of file diff --git a/Plugins/WinAlfred.Plugin.Fanyi/packages.config b/Plugins/WinAlfred.Plugin.Fanyi/packages.config new file mode 100644 index 0000000000..9fdfb3d132 --- /dev/null +++ b/Plugins/WinAlfred.Plugin.Fanyi/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Plugins/WinAlfred.Plugin.Fanyi/plugin.ini b/Plugins/WinAlfred.Plugin.Fanyi/plugin.ini new file mode 100644 index 0000000000..6d2c6eaa27 --- /dev/null +++ b/Plugins/WinAlfred.Plugin.Fanyi/plugin.ini @@ -0,0 +1,8 @@ +[plugin] +ActionKeyword = fy +Name = Translator +Author = qianlifeng +Version = 0.1 +Language = csharp +Description = Chinese and English Translator +ExecuteFile = WinAlfred.Plugin.Fanyi.dll diff --git a/WinAlfred.Plugin.System/Common/ChineseToPinYin.cs b/WinAlfred.Plugin.System/Common/ChineseToPinYin.cs new file mode 100644 index 0000000000..1f3d7f9480 --- /dev/null +++ b/WinAlfred.Plugin.System/Common/ChineseToPinYin.cs @@ -0,0 +1,127 @@ +using System.Collections.Generic; +using System.Text; + +//From:http://blog.csdn.net/chamychen/article/details/7976125 +namespace WinAlfred.Plugin.System.Common +{ + public static class ChineseToPinYin + { + private static readonly Dictionary CodeCollections = new Dictionary { + { -20319, "a" }, { -20317, "ai" }, { -20304, "an" }, { -20295, "ang" }, { -20292, "ao" }, { -20283, "ba" }, { -20265, "bai" }, +{ -20257, "ban" }, { -20242, "bang" }, { -20230, "bao" }, { -20051, "bei" }, { -20036, "ben" }, { -20032, "beng" }, { -20026, "bi" } +, { -20002, "bian" }, { -19990, "biao" }, { -19986, "bie" }, { -19982, "bin" }, { -19976, "bing" }, { -19805, "bo" }, +{ -19784, "bu" }, { -19775, "ca" }, { -19774, "cai" }, { -19763, "can" }, { -19756, "cang" }, { -19751, "cao" }, { -19746, "ce" }, + { -19741, "ceng" }, { -19739, "cha" }, { -19728, "chai" }, { -19725, "chan" }, { -19715, "chang" }, { -19540, "chao" }, +{ -19531, "che" }, { -19525, "chen" }, { -19515, "cheng" }, { -19500, "chi" }, { -19484, "chong" }, { -19479, "chou" }, +{ -19467, "chu" }, { -19289, "chuai" }, { -19288, "chuan" }, { -19281, "chuang" }, { -19275, "chui" }, { -19270, "chun" }, + { -19263, "chuo" }, { -19261, "ci" }, { -19249, "cong" }, { -19243, "cou" }, { -19242, "cu" }, { -19238, "cuan" }, +{ -19235, "cui" }, { -19227, "cun" }, { -19224, "cuo" }, { -19218, "da" }, { -19212, "dai" }, { -19038, "dan" }, { -19023, "dang" }, + { -19018, "dao" }, { -19006, "de" }, { -19003, "deng" }, { -18996, "di" }, { -18977, "dian" }, { -18961, "diao" }, { -18952, "die" } +, { -18783, "ding" }, { -18774, "diu" }, { -18773, "dong" }, { -18763, "dou" }, { -18756, "du" }, { -18741, "duan" }, +{ -18735, "dui" }, { -18731, "dun" }, { -18722, "duo" }, { -18710, "e" }, { -18697, "en" }, { -18696, "er" }, { -18526, "fa" }, + { -18518, "fan" }, { -18501, "fang" }, { -18490, "fei" }, { -18478, "fen" }, { -18463, "feng" }, { -18448, "fo" }, { -18447, "fou" } +, { -18446, "fu" }, { -18239, "ga" }, { -18237, "gai" }, { -18231, "gan" }, { -18220, "gang" }, { -18211, "gao" }, { -18201, "ge" }, + { -18184, "gei" }, { -18183, "gen" }, { -18181, "geng" }, { -18012, "gong" }, { -17997, "gou" }, { -17988, "gu" }, { -17970, "gua" } +, { -17964, "guai" }, { -17961, "guan" }, { -17950, "guang" }, { -17947, "gui" }, { -17931, "gun" }, { -17928, "guo" }, +{ -17922, "ha" }, { -17759, "hai" }, { -17752, "han" }, { -17733, "hang" }, { -17730, "hao" }, { -17721, "he" }, { -17703, "hei" }, + { -17701, "hen" }, { -17697, "heng" }, { -17692, "hong" }, { -17683, "hou" }, { -17676, "hu" }, { -17496, "hua" }, +{ -17487, "huai" }, { -17482, "huan" }, { -17468, "huang" }, { -17454, "hui" }, { -17433, "hun" }, { -17427, "huo" }, +{ -17417, "ji" }, { -17202, "jia" }, { -17185, "jian" }, { -16983, "jiang" }, { -16970, "jiao" }, { -16942, "jie" }, +{ -16915, "jin" }, { -16733, "jing" }, { -16708, "jiong" }, { -16706, "jiu" }, { -16689, "ju" }, { -16664, "juan" }, +{ -16657, "jue" }, { -16647, "jun" }, { -16474, "ka" }, { -16470, "kai" }, { -16465, "kan" }, { -16459, "kang" }, { -16452, "kao" }, + { -16448, "ke" }, { -16433, "ken" }, { -16429, "keng" }, { -16427, "kong" }, { -16423, "kou" }, { -16419, "ku" }, { -16412, "kua" } +, { -16407, "kuai" }, { -16403, "kuan" }, { -16401, "kuang" }, { -16393, "kui" }, { -16220, "kun" }, { -16216, "kuo" }, +{ -16212, "la" }, { -16205, "lai" }, { -16202, "lan" }, { -16187, "lang" }, { -16180, "lao" }, { -16171, "le" }, { -16169, "lei" }, +{ -16158, "leng" }, { -16155, "li" }, { -15959, "lia" }, { -15958, "lian" }, { -15944, "liang" }, { -15933, "liao" }, +{ -15920, "lie" }, { -15915, "lin" }, { -15903, "ling" }, { -15889, "liu" }, { -15878, "long" }, { -15707, "lou" }, { -15701, "lu" }, + { -15681, "lv" }, { -15667, "luan" }, { -15661, "lue" }, { -15659, "lun" }, { -15652, "luo" }, { -15640, "ma" }, { -15631, "mai" }, + { -15625, "man" }, { -15454, "mang" }, { -15448, "mao" }, { -15436, "me" }, { -15435, "mei" }, { -15419, "men" }, +{ -15416, "meng" }, { -15408, "mi" }, { -15394, "mian" }, { -15385, "miao" }, { -15377, "mie" }, { -15375, "min" }, +{ -15369, "ming" }, { -15363, "miu" }, { -15362, "mo" }, { -15183, "mou" }, { -15180, "mu" }, { -15165, "na" }, { -15158, "nai" }, +{ -15153, "nan" }, { -15150, "nang" }, { -15149, "nao" }, { -15144, "ne" }, { -15143, "nei" }, { -15141, "nen" }, { -15140, "neng" } +, { -15139, "ni" }, { -15128, "nian" }, { -15121, "niang" }, { -15119, "niao" }, { -15117, "nie" }, { -15110, "nin" }, +{ -15109, "ning" }, { -14941, "niu" }, { -14937, "nong" }, { -14933, "nu" }, { -14930, "nv" }, { -14929, "nuan" }, { -14928, "nue" } +, { -14926, "nuo" }, { -14922, "o" }, { -14921, "ou" }, { -14914, "pa" }, { -14908, "pai" }, { -14902, "pan" }, { -14894, "pang" }, + { -14889, "pao" }, { -14882, "pei" }, { -14873, "pen" }, { -14871, "peng" }, { -14857, "pi" }, { -14678, "pian" }, +{ -14674, "piao" }, { -14670, "pie" }, { -14668, "pin" }, { -14663, "ping" }, { -14654, "po" }, { -14645, "pu" }, { -14630, "qi" }, + { -14594, "qia" }, { -14429, "qian" }, { -14407, "qiang" }, { -14399, "qiao" }, { -14384, "qie" }, { -14379, "qin" }, + { -14368, "qing" }, { -14355, "qiong" }, { -14353, "qiu" }, { -14345, "qu" }, { -14170, "quan" }, { -14159, "que" }, +{ -14151, "qun" }, { -14149, "ran" }, { -14145, "rang" }, { -14140, "rao" }, { -14137, "re" }, { -14135, "ren" }, { -14125, "reng" } +, { -14123, "ri" }, { -14122, "rong" }, { -14112, "rou" }, { -14109, "ru" }, { -14099, "ruan" }, { -14097, "rui" }, { -14094, "run" } +, { -14092, "ruo" }, { -14090, "sa" }, { -14087, "sai" }, { -14083, "san" }, { -13917, "sang" }, { -13914, "sao" }, { -13910, "se" } +, { -13907, "sen" }, { -13906, "seng" }, { -13905, "sha" }, { -13896, "shai" }, { -13894, "shan" }, { -13878, "shang" }, +{ -13870, "shao" }, { -13859, "she" }, { -13847, "shen" }, { -13831, "sheng" }, { -13658, "shi" }, { -13611, "shou" }, + { -13601, "shu" }, { -13406, "shua" }, { -13404, "shuai" }, { -13400, "shuan" }, { -13398, "shuang" }, { -13395, "shui" }, + { -13391, "shun" }, { -13387, "shuo" }, { -13383, "si" }, { -13367, "song" }, { -13359, "sou" }, { -13356, "su" }, +{ -13343, "suan" }, { -13340, "sui" }, { -13329, "sun" }, { -13326, "suo" }, { -13318, "ta" }, { -13147, "tai" }, { -13138, "tan" }, + { -13120, "tang" }, { -13107, "tao" }, { -13096, "te" }, { -13095, "teng" }, { -13091, "ti" }, { -13076, "tian" }, +{ -13068, "tiao" }, { -13063, "tie" }, { -13060, "ting" }, { -12888, "tong" }, { -12875, "tou" }, { -12871, "tu" }, +{ -12860, "tuan" }, { -12858, "tui" }, { -12852, "tun" }, { -12849, "tuo" }, { -12838, "wa" }, { -12831, "wai" }, { -12829, "wan" } +, { -12812, "wang" }, { -12802, "wei" }, { -12607, "wen" }, { -12597, "weng" }, { -12594, "wo" }, { -12585, "wu" }, { -12556, "xi" } +, { -12359, "xia" }, { -12346, "xian" }, { -12320, "xiang" }, { -12300, "xiao" }, { -12120, "xie" }, { -12099, "xin" }, +{ -12089, "xing" }, { -12074, "xiong" }, { -12067, "xiu" }, { -12058, "xu" }, { -12039, "xuan" }, { -11867, "xue" }, +{ -11861, "xun" }, { -11847, "ya" }, { -11831, "yan" }, { -11798, "yang" }, { -11781, "yao" }, { -11604, "ye" }, { -11589, "yi" }, + { -11536, "yin" }, { -11358, "ying" }, { -11340, "yo" }, { -11339, "yong" }, { -11324, "you" }, { -11303, "yu" }, +{ -11097, "yuan" }, { -11077, "yue" }, { -11067, "yun" }, { -11055, "za" }, { -11052, "zai" }, { -11045, "zan" }, + { -11041, "zang" }, { -11038, "zao" }, { -11024, "ze" }, { -11020, "zei" }, { -11019, "zen" }, { -11018, "zeng" }, +{ -11014, "zha" }, { -10838, "zhai" }, { -10832, "zhan" }, { -10815, "zhang" }, { -10800, "zhao" }, { -10790, "zhe" }, +{ -10780, "zhen" }, { -10764, "zheng" }, { -10587, "zhi" }, { -10544, "zhong" }, { -10533, "zhou" }, { -10519, "zhu" }, +{ -10331, "zhua" }, { -10329, "zhuai" }, { -10328, "zhuan" }, { -10322, "zhuang" }, { -10315, "zhui" }, { -10309, "zhun" }, +{ -10307, "zhuo" }, { -10296, "zi" }, { -10281, "zong" }, { -10274, "zou" }, { -10270, "zu" }, { -10262, "zuan" }, { -10260, "zui" } +, { -10256, "zun" }, { -10254, "zuo" } }; + /// + /// 汉字转拼音 + /// + /// 需要转换的汉字 + /// 返回汉字对应的拼音 + public static string ToPinYin(string txt) + { + txt = txt.Trim(); + byte[] arr = new byte[2]; //每个汉字为2字节 + StringBuilder result = new StringBuilder();//使用StringBuilder优化字符串连接 + int charCode = 0; + int arr1 = 0; + int arr2 = 0; + char[] arrChar = txt.ToCharArray(); + for (int j = 0; j < arrChar.Length; j++) //遍历输入的字符 + { + arr = Encoding.Default.GetBytes(arrChar[j].ToString());//根据系统默认编码得到字节码 + if (arr.Length == 1)//如果只有1字节说明该字符不是汉字,结束本次循环 + { + result.Append(arrChar[j].ToString()); + continue; + + } + arr1 = (short)(arr[0]); //取字节1 + arr2 = (short)(arr[1]); //取字节2 + charCode = arr1 * 256 + arr2 - 65536;//计算汉字的编码 + + if (charCode > -10254 || charCode < -20319) //如果不在汉字编码范围内则不改变 + { + result.Append(arrChar[j]); + } + else + { + //根据汉字编码范围查找对应的拼音并保存到结果中 + //由于charCode的键不一定存在,所以要找比他更小的键上一个键 + if (!CodeCollections.ContainsKey(charCode)) + { + for (int i = charCode; i <= 0; --i) + { + if (CodeCollections.ContainsKey(i)) + { + result.Append(" " + CodeCollections[i] + " "); + break; + } + } + } + else + { + result.Append(" " + CodeCollections[charCode] + " "); + } + } + } + return result.ToString(); + } + } +} diff --git a/WinAlfred.Plugin.System/Programs.cs b/WinAlfred.Plugin.System/Programs.cs index 72f9991ccf..556932af07 100644 --- a/WinAlfred.Plugin.System/Programs.cs +++ b/WinAlfred.Plugin.System/Programs.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using System.Windows.Forms; using Microsoft.Win32; +using WinAlfred.Plugin.System.Common; namespace WinAlfred.Plugin.System { @@ -14,21 +15,30 @@ namespace WinAlfred.Plugin.System public string Title { get; set; } public string IcoPath { get; set; } public string ExecutePath { get; set; } + public int Score { get; set; } } public class Programs : ISystemPlugin { + //TODO:add score for MRU program + + private List indexDirectory = new List(); + private List indexPostfix = new List { "lnk", "exe" }; + List installedList = new List(); public List Query(Query query) { - if (string.IsNullOrEmpty(query.RawQuery) || query.RawQuery.Length <= 1) return new List(); + if (string.IsNullOrEmpty(query.RawQuery) || query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List(); - return installedList.Where(o => o.Title.ToLower().Contains(query.RawQuery.ToLower())).Select(c => new Result() + List returnList = installedList.Where(o => MatchProgram(o, query)).ToList(); + returnList.ForEach(ScoreFilter); + + return returnList.Select(c => new Result() { Title = c.Title, IcoPath = c.IcoPath, - Score = 10, + Score = c.Score, Action = () => { if (string.IsNullOrEmpty(c.ExecutePath)) @@ -43,18 +53,27 @@ namespace WinAlfred.Plugin.System }).ToList(); } + private bool MatchProgram(Program program, Query query) + { + if (program.Title.ToLower().Contains(query.RawQuery.ToLower())) return true; + if (ChineseToPinYin.ToPinYin(program.Title).Replace(" ", "").ToLower().Contains(query.RawQuery.ToLower())) return true; + + return false; + } + public void Init(PluginInitContext context) { + indexDirectory.Add(Environment.GetFolderPath(Environment.SpecialFolder.Programs)); + indexDirectory.Add(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\Microsoft\Windows\Start Menu\Programs"); + GetAppFromStartMenu(); } private void GetAppFromStartMenu() { - List path = - Directory.GetDirectories(Environment.GetFolderPath(Environment.SpecialFolder.Programs)).ToList(); - foreach (string s in path) + foreach (string directory in indexDirectory) { - GetAppFromDirectory(s); + GetAppFromDirectory(directory); } } @@ -62,12 +81,13 @@ namespace WinAlfred.Plugin.System { foreach (string file in Directory.GetFiles(path)) { - if (file.EndsWith(".lnk") || file.EndsWith(".exe")) + if (indexPostfix.Any(o => file.EndsWith("." + o))) { Program p = new Program() { Title = getAppNameFromAppPath(file), IcoPath = file, + Score = 10, ExecutePath = file }; installedList.Add(p); @@ -80,6 +100,18 @@ namespace WinAlfred.Plugin.System } } + private void ScoreFilter(Program p) + { + if (p.Title.Contains("启动") || p.Title.ToLower().Contains("start")) + { + p.Score += 10; + } + if (p.Title.Contains("卸载") || p.Title.ToLower().Contains("uninstall")) + { + p.Score -= 5; + } + } + private string getAppNameFromAppPath(string app) { string temp = app.Substring(app.LastIndexOf('\\') + 1); diff --git a/WinAlfred.Plugin.System/Sys.cs b/WinAlfred.Plugin.System/Sys.cs index f167099643..9919ca6c39 100644 --- a/WinAlfred.Plugin.System/Sys.cs +++ b/WinAlfred.Plugin.System/Sys.cs @@ -62,6 +62,14 @@ namespace WinAlfred.Plugin.System IcoPath = "Images\\lock.png", Action = () => LockWorkStation() }); + availableResults.Add(new Result + { + Title = "Exit", + SubTitle = "Close this app", + Score = 110, + IcoPath = "Images\\exit.png", + Action = () => context.CloseApp() + }); } public string Name diff --git a/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj b/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj index 7da37c9292..f7d8449ea4 100644 --- a/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj +++ b/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj @@ -40,6 +40,7 @@ + diff --git a/WinAlfred.Plugin/PluginInitContext.cs b/WinAlfred.Plugin/PluginInitContext.cs index c010ae25f5..70025c2584 100644 --- a/WinAlfred.Plugin/PluginInitContext.cs +++ b/WinAlfred.Plugin/PluginInitContext.cs @@ -8,6 +8,11 @@ namespace WinAlfred.Plugin public class PluginInitContext { public List Plugins { get; set; } + public Action ChangeQuery { get; set; } + public Action CloseApp { get; set; } + public Action HideApp { get; set; } + public Action ShowApp { get; set; } + public Action ShowMsg { get; set; } } } diff --git a/WinAlfred.Plugin/Result.cs b/WinAlfred.Plugin/Result.cs index 3d328df540..05565fea73 100644 --- a/WinAlfred.Plugin/Result.cs +++ b/WinAlfred.Plugin/Result.cs @@ -12,6 +12,8 @@ namespace WinAlfred.Plugin public Action Action { get; set; } public int Score { get; set; } + public bool DontHideWinAlfredAfterAction { get; set; } + //todo: this should be controlled by system, not visible to users /// /// Only resulsts that originQuery match with curren query will be displayed in the panel diff --git a/WinAlfred.sln b/WinAlfred.sln index 22df5a02b1..eca79e1fa0 100644 --- a/WinAlfred.sln +++ b/WinAlfred.sln @@ -9,10 +9,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugin", "Plugin", "{3A73F5 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred", "WinAlfred\WinAlfred.csproj", "{DB90F671-D861-46BB-93A3-F1304F5BA1C5}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PyWinAlfred", "PyWinAlfred\PyWinAlfred.vcxproj", "{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred.Plugin.System", "WinAlfred.Plugin.System\WinAlfred.Plugin.System.csproj", "{69CE0206-CB41-453D-88AF-DF86092EF9B8}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred.Plugin.Fanyi", "Plugins\WinAlfred.Plugin.Fanyi\WinAlfred.Plugin.Fanyi.csproj", "{353769D3-D11C-4D86-BD06-AC8C1D68642B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -52,8 +52,8 @@ Global {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|x86.Build.0 = Debug|Any CPU {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Any CPU.ActiveCfg = Release|Any CPU {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Any CPU.Build.0 = Release|Any CPU - {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Mixed Platforms.Build.0 = Release|x86 + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Mixed Platforms.Build.0 = Release|Any CPU {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Win32.ActiveCfg = Release|x86 {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Win32.Build.0 = Release|x86 {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|x64.ActiveCfg = Release|Any CPU @@ -72,24 +72,6 @@ Global {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Win32.ActiveCfg = Release|Any CPU {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x64.ActiveCfg = Release|Any CPU {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x86.ActiveCfg = Release|Any CPU - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Debug|Win32.ActiveCfg = Debug|Win32 - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Debug|Win32.Build.0 = Debug|Win32 - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Debug|x64.ActiveCfg = Debug|x64 - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Debug|x64.Build.0 = Debug|x64 - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Debug|x86.ActiveCfg = Debug|Win32 - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Debug|x86.Build.0 = Debug|Win32 - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|Any CPU.ActiveCfg = Release|Win32 - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|Mixed Platforms.Build.0 = Release|Win32 - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|Win32.ActiveCfg = Release|Win32 - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|Win32.Build.0 = Release|Win32 - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|x64.ActiveCfg = Release|x64 - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|x64.Build.0 = Release|x64 - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|x86.ActiveCfg = Release|Win32 - {D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|x86.Build.0 = Release|Win32 {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Any CPU.Build.0 = Debug|Any CPU {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -104,8 +86,25 @@ Global {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Win32.ActiveCfg = Release|Any CPU {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|x64.ActiveCfg = Release|Any CPU {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|x86.ActiveCfg = Release|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|Win32.ActiveCfg = Debug|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|x64.ActiveCfg = Debug|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|x86.ActiveCfg = Debug|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|Any CPU.Build.0 = Release|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|Win32.ActiveCfg = Release|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|x64.ActiveCfg = Release|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {353769D3-D11C-4D86-BD06-AC8C1D68642B} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87} + EndGlobalSection EndGlobal diff --git a/WinAlfred/Commands/PluginCommand.cs b/WinAlfred/Commands/PluginCommand.cs index cb0a764de3..f30b667ac3 100644 --- a/WinAlfred/Commands/PluginCommand.cs +++ b/WinAlfred/Commands/PluginCommand.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading; using WinAlfred.Helper; using WinAlfred.Plugin; diff --git a/WinAlfred/Helper/KeyboardHook.cs b/WinAlfred/Helper/KeyboardHook.cs index 97a7755341..be717a541a 100644 --- a/WinAlfred/Helper/KeyboardHook.cs +++ b/WinAlfred/Helper/KeyboardHook.cs @@ -85,6 +85,7 @@ namespace WinAlfred.Helper if (!RegisterHotKey(window.Handle, currentId, (uint)xModifier, (uint)key)) { Log.Error("Couldn’t register the hot key."); + MessageBox.Show("Couldn’t register the hot key."); #if (DEBUG) { throw new InvalidOperationException("Couldn’t register the hot key."); diff --git a/WinAlfred/MainWindow.xaml.cs b/WinAlfred/MainWindow.xaml.cs index fd2099fb02..fa91201f4c 100644 --- a/WinAlfred/MainWindow.xaml.cs +++ b/WinAlfred/MainWindow.xaml.cs @@ -6,6 +6,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Forms; using System.Windows.Input; +using Noesis.Javascript; using WinAlfred.Commands; using WinAlfred.Helper; using WinAlfred.Plugin; @@ -39,11 +40,7 @@ namespace WinAlfred System.Windows.Forms.MenuItem open = new System.Windows.Forms.MenuItem("Open"); open.Click += (o, e) => ShowWinAlfred(); System.Windows.Forms.MenuItem exit = new System.Windows.Forms.MenuItem("Exit"); - exit.Click += (o, e) => - { - notifyIcon.Visible = false; - Close(); - }; + exit.Click += (o, e) => CloseApp(); System.Windows.Forms.MenuItem[] childen = { open, exit }; notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(childen); } @@ -68,6 +65,30 @@ namespace WinAlfred private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e) { + + // Initialize a context + using (JavascriptContext context = new JavascriptContext()) + { + + // Setting external parameters for the context + context.SetParameter("message", "Hello World !"); + context.SetParameter("number", 1); + + // Script + string script = @" + var i; + for (i = 0; i < 5; i++) + console.Print(message + ' (' + i + ')'); + number += i; + "; + + // Running the script + context.Run(script); + + // Getting a parameter + MessageBox.Show("number: " + context.GetParameter("number")); + } + //MessageBox.Show("s"); resultCtrl.Dirty = true; ////auto clear results after 50ms if there are any results returned by plugins @@ -91,7 +112,7 @@ namespace WinAlfred Hide(); } - public void ShowWinAlfred() + private void ShowWinAlfred() { Show(); //FocusManager.SetFocusedElement(this, tbQuery); @@ -104,6 +125,9 @@ namespace WinAlfred Plugins.Init(this); cmdDispatcher = new Command(this); InitialTray(); + + + } private void TbQuery_OnPreviewKeyDown(object sender, KeyEventArgs e) @@ -126,8 +150,7 @@ namespace WinAlfred break; case Key.Enter: - resultCtrl.AcceptSelect(); - HideWinAlfred(); + if (resultCtrl.AcceptSelect()) HideWinAlfred(); e.Handled = true; break; } @@ -141,5 +164,39 @@ namespace WinAlfred resultCtrl.AddResults(l); })); } + + #region Public API + + //Those method can be invoked by plugins + + public void ChangeQuery(string query) + { + tbQuery.Text = query; + tbQuery.CaretIndex = tbQuery.Text.Length; + } + + public void CloseApp() + { + notifyIcon.Visible = false; + Close(); + } + + public void HideApp() + { + HideWinAlfred(); + } + + public void ShowApp() + { + ShowWinAlfred(); + } + + public void ShowMsg(string title, string subTitle, string iconPath) + { + Msg m = new Msg { Owner = GetWindow(this) }; + m.Show(title, subTitle, iconPath); + } + + #endregion } } \ No newline at end of file diff --git a/WinAlfred/Msg.xaml b/WinAlfred/Msg.xaml new file mode 100644 index 0000000000..ef17b34532 --- /dev/null +++ b/WinAlfred/Msg.xaml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + Title + sdfdsf + + + + diff --git a/WinAlfred/Msg.xaml.cs b/WinAlfred/Msg.xaml.cs new file mode 100644 index 0000000000..353279de68 --- /dev/null +++ b/WinAlfred/Msg.xaml.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Forms; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using Timer = System.Threading.Timer; + +namespace WinAlfred +{ + public partial class Msg : Window + { + Storyboard fadeOutStoryboard = new Storyboard(); + private bool closing = false; + + public Msg() + { + InitializeComponent(); + + Left = Screen.PrimaryScreen.WorkingArea.Right - this.Width; + Top = Screen.PrimaryScreen.Bounds.Bottom; + showAnimation.From = Screen.PrimaryScreen.Bounds.Bottom; + showAnimation.To = Screen.PrimaryScreen.WorkingArea.Bottom - Height; + + // Create the fade out storyboard + fadeOutStoryboard.Completed += new EventHandler(fadeOutStoryboard_Completed); + DoubleAnimation fadeOutAnimation = new DoubleAnimation(Screen.PrimaryScreen.WorkingArea.Bottom - Height, Screen.PrimaryScreen.Bounds.Bottom, new Duration(TimeSpan.FromSeconds(0.3))) + { + AccelerationRatio = 0.2 + }; + Storyboard.SetTarget(fadeOutAnimation, this); + Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(TopProperty)); + fadeOutStoryboard.Children.Add(fadeOutAnimation); + + imgClose.Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "\\Images\\close.png")); + imgClose.MouseUp += imgClose_MouseUp; + } + + void imgClose_MouseUp(object sender, MouseButtonEventArgs e) + { + if (!closing) + { + closing = true; + fadeOutStoryboard.Begin(); + } + } + + private void fadeOutStoryboard_Completed(object sender, EventArgs e) + { + Close(); + } + + public void Show(string title, string subTitle, string icopath) + { + tbTitle.Text = title; + tbSubTitle.Text = subTitle; + if (!File.Exists(icopath)) + { + icopath = AppDomain.CurrentDomain.BaseDirectory + "Images\\ico.png"; + } + imgIco.Source = new BitmapImage(new Uri(icopath)); + Show(); + new Timer(o => + { + if (!closing) + { + closing = true; + Dispatcher.Invoke(new Action(fadeOutStoryboard.Begin)); + } + }, null, TimeSpan.FromSeconds(3), TimeSpan.FromMilliseconds(-1)); + } + } +} diff --git a/WinAlfred/PluginLoader/Plugins.cs b/WinAlfred/PluginLoader/Plugins.cs index 1b1b840bf5..42f527bf09 100644 --- a/WinAlfred/PluginLoader/Plugins.cs +++ b/WinAlfred/PluginLoader/Plugins.cs @@ -22,11 +22,11 @@ namespace WinAlfred.PluginLoader ThreadPool.QueueUserWorkItem(o => plugin1.Init(new PluginInitContext() { Plugins = plugins, - ChangeQuery = s => - { - window.tbQuery.Text = s; - window.ShowWinAlfred(); - } + ChangeQuery = s => window.ChangeQuery(s), + CloseApp = window.CloseApp, + HideApp = window.HideApp, + ShowApp = window.ShowApp, + ShowMsg = (title,subTitle,iconPath) => window.ShowMsg(title,subTitle,iconPath) })); } } diff --git a/WinAlfred/ResultPanel.xaml.cs b/WinAlfred/ResultPanel.xaml.cs index 420cb7774f..6cf568da4f 100644 --- a/WinAlfred/ResultPanel.xaml.cs +++ b/WinAlfred/ResultPanel.xaml.cs @@ -192,14 +192,21 @@ namespace WinAlfred Select(0); } - public void AcceptSelect() + public bool AcceptSelect() { int index = GetCurrentSelectedResultIndex(); var resultItemControl = pnlContainer.Children[index] as ResultItem; if (resultItemControl != null) { - if (resultItemControl.Result.Action != null) resultItemControl.Result.Action(); + if (resultItemControl.Result.Action != null) + { + resultItemControl.Result.Action(); + } + + return !resultItemControl.Result.DontHideWinAlfredAfterAction; } + + return true; } public ResultPanel() diff --git a/WinAlfred/WinAlfred.csproj b/WinAlfred/WinAlfred.csproj index 6fe06be122..0d76b8b281 100644 --- a/WinAlfred/WinAlfred.csproj +++ b/WinAlfred/WinAlfred.csproj @@ -39,22 +39,50 @@ app.ico + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + + ..\packages\log4net.2.0.3\lib\net35-full\log4net.dll ..\packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll + + C:\Users\Scott\Desktop\x64\Noesis.Javascript.dll + + + + + + + @@ -71,6 +99,9 @@ + + Msg.xaml + @@ -95,6 +126,10 @@ MainWindow.xaml Code + + Designer + MSBuild:Compile + Designer MSBuild:Compile From 2db21361178fcc3ec3d3f491eb7618f430438f1e Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Sun, 5 Jan 2014 19:33:36 +0800 Subject: [PATCH 06/16] remove unused codes --- WinAlfred/MainWindow.xaml.cs | 28 ---------------------------- WinAlfred/WinAlfred.csproj | 3 --- 2 files changed, 31 deletions(-) diff --git a/WinAlfred/MainWindow.xaml.cs b/WinAlfred/MainWindow.xaml.cs index fa91201f4c..02dea99755 100644 --- a/WinAlfred/MainWindow.xaml.cs +++ b/WinAlfred/MainWindow.xaml.cs @@ -6,7 +6,6 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Forms; using System.Windows.Input; -using Noesis.Javascript; using WinAlfred.Commands; using WinAlfred.Helper; using WinAlfred.Plugin; @@ -65,30 +64,6 @@ namespace WinAlfred private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e) { - - // Initialize a context - using (JavascriptContext context = new JavascriptContext()) - { - - // Setting external parameters for the context - context.SetParameter("message", "Hello World !"); - context.SetParameter("number", 1); - - // Script - string script = @" - var i; - for (i = 0; i < 5; i++) - console.Print(message + ' (' + i + ')'); - number += i; - "; - - // Running the script - context.Run(script); - - // Getting a parameter - MessageBox.Show("number: " + context.GetParameter("number")); - } - //MessageBox.Show("s"); resultCtrl.Dirty = true; ////auto clear results after 50ms if there are any results returned by plugins @@ -125,9 +100,6 @@ namespace WinAlfred Plugins.Init(this); cmdDispatcher = new Command(this); InitialTray(); - - - } private void TbQuery_OnPreviewKeyDown(object sender, KeyEventArgs e) diff --git a/WinAlfred/WinAlfred.csproj b/WinAlfred/WinAlfred.csproj index 0d76b8b281..f77fec5eab 100644 --- a/WinAlfred/WinAlfred.csproj +++ b/WinAlfred/WinAlfred.csproj @@ -65,9 +65,6 @@ ..\packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll - - C:\Users\Scott\Desktop\x64\Noesis.Javascript.dll - From 3901422a54a6cca6b04c97a961f2e6c46a8f8eb5 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Mon, 6 Jan 2014 19:03:20 +0800 Subject: [PATCH 07/16] Add missed changes --- .../ThirdpartyPluginIndicator.cs | 61 ++++++++++++++++++ WinAlfred/Commands/BaseCommand.cs | 29 +++++++++ WinAlfred/Images/close.png | Bin 0 -> 139 bytes WinAlfred/Images/cmd.png | Bin 0 -> 1633 bytes WinAlfred/Images/exit.png | Bin 0 -> 2724 bytes WinAlfred/Images/logoff.png | Bin 0 -> 613 bytes WinAlfred/Images/work.png | Bin 0 -> 4841 bytes WinAlfred/MainWindow.xaml.cs | 3 + WinAlfred/WinAlfred.csproj | 3 + 9 files changed, 96 insertions(+) create mode 100644 WinAlfred.Plugin.System/ThirdpartyPluginIndicator.cs create mode 100644 WinAlfred/Commands/BaseCommand.cs create mode 100644 WinAlfred/Images/close.png create mode 100644 WinAlfred/Images/cmd.png create mode 100644 WinAlfred/Images/exit.png create mode 100644 WinAlfred/Images/logoff.png create mode 100644 WinAlfred/Images/work.png diff --git a/WinAlfred.Plugin.System/ThirdpartyPluginIndicator.cs b/WinAlfred.Plugin.System/ThirdpartyPluginIndicator.cs new file mode 100644 index 0000000000..ca10dfa486 --- /dev/null +++ b/WinAlfred.Plugin.System/ThirdpartyPluginIndicator.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace WinAlfred.Plugin.System +{ + public class ThirdpartyPluginIndicator : ISystemPlugin + { + private List allPlugins = new List(); + private Action changeQuery; + + public List Query(Query query) + { + List results = new List(); + if (string.IsNullOrEmpty(query.RawQuery)) return results; + + foreach (PluginMetadata metadata in allPlugins.Select(o=>o.Metadata)) + { + if (metadata.ActionKeyword.StartsWith(query.RawQuery)) + { + PluginMetadata metadataCopy = metadata; + Result result = new Result + { + Title = metadata.ActionKeyword, + SubTitle = string.Format("press space to active {0} workflow",metadata.Name), + Score = 50, + IcoPath = "Images/work.png", + Action = () => changeQuery(metadataCopy.ActionKeyword + " "), + DontHideWinAlfredAfterAction = true + }; + results.Add(result); + } + } + return results; + } + + public void Init(PluginInitContext context) + { + allPlugins = context.Plugins; + changeQuery = context.ChangeQuery; + } + + public string Name { + get + { + return "ThirdpartyPluginIndicator"; + } + } + + public string Description + { + get + { + return "ThirdpartyPluginIndicator"; + } + } + + + } +} diff --git a/WinAlfred/Commands/BaseCommand.cs b/WinAlfred/Commands/BaseCommand.cs new file mode 100644 index 0000000000..aa3dfbdb75 --- /dev/null +++ b/WinAlfred/Commands/BaseCommand.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using WinAlfred.Plugin; + +namespace WinAlfred.Commands +{ + public abstract class BaseCommand + { + private MainWindow window; + + public abstract void Dispatch(Query query); + + //TODO:Ugly, we should subscribe events here, instead of just use usercontrol as the parameter + protected BaseCommand(MainWindow window) + { + this.window = window; + } + + protected void UpdateResultView(List results) + { + if (results.Count > 0) + { + window.OnUpdateResultView(results); + } + } + } +} diff --git a/WinAlfred/Images/close.png b/WinAlfred/Images/close.png new file mode 100644 index 0000000000000000000000000000000000000000..5ddfe20b8f3f9541bad8e9a6be5e208eba50244b GIT binary patch literal 139 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`L7py-Ar`&K2@|z=9CLhAz6IL1a->h*YA2k~jgAU^{-zNWm$}Th{q$$7=!YgH|p8br|O5BHzfdY0B~KGjEsy-PEAey zWLcJNjDa!c<7P^B)2h{K(f#}Pze=T2f3#XH!vR2RO)8a2CYem0t<`GI*47r3Qa#Au zC(DD3bB=sI565x*jZ$e;O8FeXJ^&>pgb;Loex5EYEI>*L08mPGz;ru5Y8_v9uM>#` zu3o*0OP4MY5JD-X=#&5e3;-!5eBVbHhA0#Y*xA`ZyWNKG`v`)d1FAc~Vds7zsZ1?!a|jT)%!D=gyr2A*9D)x8wLY zYR?!0&N-WynD}C2W8?Eiy-s@=&|MFXkB?(!W(Gq;L%4VE9@f^@005NIo*)O&eONiP z)&M}2Qe<;;bG^}M^p>C-bvm8K{QNv#zI=&xyA7>1a=9Eh=a5pO(P*I2Xdn#3zomg# z%t|Q}hM_K(%YXVopnF6Z2M>Y(ckkW>00<#KDaFN$7cn0%AWFc`uS#d2Y_O+NVC~&(HKJyaux@UhtOeT_%J{{t*De~ zHJh7J6q$VnJdY+4iL)I5doRZIJ!twJ7W6me4g62T{Hltl#)y)1K0B)q6nrp1@z~26bt=( zi9`bFbQ*jA0Vcl3hqGDA7%NIC31`gAUA|0aXJ?_i+N|R+24eOo-QSIG9wI*i%i_ke zZM0i0Bc<#-$ZNHlezv?!gCM9FV2A*eF-93v9>5Mhlg<+u)o*MiD@O zDD+XUR`BgNUmGFC*0pQbW@@$C^H!@B?Q*j(5<&F{jQmOQ&Q-UtR7-NiyqDV(kBmsl~ntRwv<#PG=m6a9B7~_mFn=v-P7&|eP z$&7tEI$CsHw-~eLdfwPbE;oEK`w3^1Qp>WaQcAC_t*r_n{9bi@fW@rYwoNU|Vw6&g zbDm_3rILxn$y_dXW;CBK7Cdi!WMstqb#d{RrKP1GtJP}sQ2-o=jdM;c%VL~!W{k14 z)=CKBM^U8zp}7A+`wL@BoR9x#)=mHb03~!qSaf7zbY(hYa%Ew3WdJfTF)%GKGA%JN zR536*Gch_fI4v+XIxsLq5ff(s001R)MObuXVRU6WZEs|0W_bWIFfceRFfuJNH&ih= fIyE#pG&C(RHaajcNaF4900000NkvXXu0mjfN!jGN literal 0 HcmV?d00001 diff --git a/WinAlfred/Images/exit.png b/WinAlfred/Images/exit.png new file mode 100644 index 0000000000000000000000000000000000000000..523c3d5197db3825be40fa89af1c943ec37dbcbd GIT binary patch literal 2724 zcmV;V3S0GwP)yt5dvX`KvN%sn06G!T3WQ#NEJ(}Qc_SWH5eO_#zb2aznPX; zA5CMynAS7|+c2rEVtJJs%Z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G`>N%B=bBoqyvT^Ro;tLHCcYCjdjCeb=Z{JAj^M1SJly5xL=k5XSSxChH{_zQ&A8+@3 e@f^ literal 0 HcmV?d00001 diff --git a/WinAlfred/Images/logoff.png b/WinAlfred/Images/logoff.png new file mode 100644 index 0000000000000000000000000000000000000000..73c1379b2e233a3f3cdeb8d62dfcfa9db43e1be6 GIT binary patch literal 613 zcmV-r0-F7aP)i&;aWI*Ri`asL#i^wz4kCiM=^zwW7ad$Wv|y)# z9W;uI3T?zeLQ^C41*sU5l4@dVnukLvdTGhMA=WH8<2m0s|KE4c<(^OA=6sbVnyQ)N zEr1q43jjblhNw9LyFp8!%SNtPVs`1vj(9+{ za=riK_HRIQ!MW+b*A6R^%Dno%~cAa=toq~O#e1d zyBVXVwnWVie8?84RI40vn9!?L{3=%@@r7iTyRSY;e8V1*c9V|hpVt_gj`Fi4&8Z7u zePffwWR~Om+c>)5}!+?m`kK2zF@bVx0xJ6(@}E8a!qlN8-XBjXL0L>lVLZa zSua~~`{qi-3udL}Wq8304pat+7vlFRrw4{x100000NkvXXu0mjfH;)=D literal 0 HcmV?d00001 diff --git a/WinAlfred/Images/work.png b/WinAlfred/Images/work.png new file mode 100644 index 0000000000000000000000000000000000000000..aa447afd8df40dca7123ee13c89f8016cc83b14c GIT binary patch literal 4841 zcmVKLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_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W`{VRbWpY_OPTyh!r!l&VMbOTQSk4`NJ1Em!fl9G}DW->wd zf#=wLbf~EA(%QAIzMj5-#*6f@JoXyF4mOQC)o5KJfUo&P+?B z@1c|;QfyLWCm8B?NsMVKE)TN!hbxK9-%sk~YpM3;!L6?A|HQP+{H#i|^MnW73+z&g zd(d2M+R~JMo`7YtU~v&jniPpB|B``Ylr`w`ov zum7DG39c`xh^(_ic0(?w<{O4>hQel|3*jJOm>G^T0HF7MY}p8t0MqZSetJgpw% P00000NkvXXu0mjfuuw*Q literal 0 HcmV?d00001 diff --git a/WinAlfred/MainWindow.xaml.cs b/WinAlfred/MainWindow.xaml.cs index 02dea99755..4a12ba4f75 100644 --- a/WinAlfred/MainWindow.xaml.cs +++ b/WinAlfred/MainWindow.xaml.cs @@ -100,6 +100,9 @@ namespace WinAlfred Plugins.Init(this); cmdDispatcher = new Command(this); InitialTray(); + + //var engine = new Jurassic.ScriptEngine(); + //MessageBox.Show(engine.Evaluate("5 * 10 + 2").ToString()); } private void TbQuery_OnPreviewKeyDown(object sender, KeyEventArgs e) diff --git a/WinAlfred/WinAlfred.csproj b/WinAlfred/WinAlfred.csproj index f77fec5eab..722066c294 100644 --- a/WinAlfred/WinAlfred.csproj +++ b/WinAlfred/WinAlfred.csproj @@ -59,6 +59,9 @@ + + C:\Users\Scott\Desktop\Jurassic.dll + ..\packages\log4net.2.0.3\lib\net35-full\log4net.dll From 97b5526cc1e5373e024391199b9e6385e63eed38 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Mon, 6 Jan 2014 21:25:24 +0800 Subject: [PATCH 08/16] fix program plugin doesn't work in XP issue. --- WinAlfred.2010.sln | 110 +++++++++++++ WinAlfred.Plugin.System/DirectoryIndicator.cs | 58 +++++++ WinAlfred.Plugin.System/Programs.cs | 12 +- .../WinAlfred.Plugin.System.csproj | 1 + WinAlfred/App.config | 2 +- WinAlfred/App.xaml | 1 - WinAlfred/Images/folder.png | Bin 0 -> 4260 bytes WinAlfred/MainWindow.xaml.cs | 6 + WinAlfred/Properties/Resources.Designer.cs | 146 +++++++++--------- WinAlfred/Properties/Settings.Designer.cs | 52 +++---- WinAlfred/ResultPanel.xaml.cs | 2 + WinAlfred/WinAlfred.csproj | 5 +- WinAlfred/packages.config | 4 +- 13 files changed, 291 insertions(+), 108 deletions(-) create mode 100644 WinAlfred.2010.sln create mode 100644 WinAlfred.Plugin.System/DirectoryIndicator.cs create mode 100644 WinAlfred/Images/folder.png diff --git a/WinAlfred.2010.sln b/WinAlfred.2010.sln new file mode 100644 index 0000000000..1fa6a84748 --- /dev/null +++ b/WinAlfred.2010.sln @@ -0,0 +1,110 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred.Test", "WinAlfred.Test\WinAlfred.Test.csproj", "{FF742965-9A80-41A5-B042-D6C7D3A21708}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred.Plugin", "WinAlfred.Plugin\WinAlfred.Plugin.csproj", "{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugin", "Plugin", "{3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred", "WinAlfred\WinAlfred.csproj", "{DB90F671-D861-46BB-93A3-F1304F5BA1C5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred.Plugin.System", "WinAlfred.Plugin.System\WinAlfred.Plugin.System.csproj", "{69CE0206-CB41-453D-88AF-DF86092EF9B8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred.Plugin.Fanyi", "Plugins\WinAlfred.Plugin.Fanyi\WinAlfred.Plugin.Fanyi.csproj", "{353769D3-D11C-4D86-BD06-AC8C1D68642B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|Win32.ActiveCfg = Debug|Any CPU + {FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|x64.ActiveCfg = Debug|Any CPU + {FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|x86.ActiveCfg = Debug|Any CPU + {FF742965-9A80-41A5-B042-D6C7D3A21708}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FF742965-9A80-41A5-B042-D6C7D3A21708}.Release|Any CPU.Build.0 = Release|Any CPU + {FF742965-9A80-41A5-B042-D6C7D3A21708}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {FF742965-9A80-41A5-B042-D6C7D3A21708}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {FF742965-9A80-41A5-B042-D6C7D3A21708}.Release|Win32.ActiveCfg = Release|Any CPU + {FF742965-9A80-41A5-B042-D6C7D3A21708}.Release|x64.ActiveCfg = Release|Any CPU + {FF742965-9A80-41A5-B042-D6C7D3A21708}.Release|x86.ActiveCfg = Release|Any CPU + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|Win32.ActiveCfg = Debug|x86 + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|Win32.Build.0 = Debug|x86 + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|x64.ActiveCfg = Debug|Any CPU + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|x86.ActiveCfg = Debug|Any CPU + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|x86.Build.0 = Debug|Any CPU + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Any CPU.Build.0 = Release|Any CPU + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Win32.ActiveCfg = Release|x86 + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Win32.Build.0 = Release|x86 + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|x64.ActiveCfg = Release|Any CPU + {8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|x86.ActiveCfg = Release|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Win32.ActiveCfg = Debug|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x64.ActiveCfg = Debug|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x86.ActiveCfg = Debug|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Any CPU.Build.0 = Release|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Win32.ActiveCfg = Release|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x64.ActiveCfg = Release|Any CPU + {DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x86.ActiveCfg = Release|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Win32.ActiveCfg = Debug|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|x64.ActiveCfg = Debug|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|x86.ActiveCfg = Debug|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Any CPU.Build.0 = Release|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Win32.ActiveCfg = Release|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|x64.ActiveCfg = Release|Any CPU + {69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|x86.ActiveCfg = Release|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|Win32.ActiveCfg = Debug|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|x64.ActiveCfg = Debug|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|x86.ActiveCfg = Debug|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|Any CPU.Build.0 = Release|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|Win32.ActiveCfg = Release|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|x64.ActiveCfg = Release|Any CPU + {353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|x86.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {353769D3-D11C-4D86-BD06-AC8C1D68642B} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87} + EndGlobalSection +EndGlobal diff --git a/WinAlfred.Plugin.System/DirectoryIndicator.cs b/WinAlfred.Plugin.System/DirectoryIndicator.cs new file mode 100644 index 0000000000..79e4ae3f03 --- /dev/null +++ b/WinAlfred.Plugin.System/DirectoryIndicator.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; + +namespace WinAlfred.Plugin.System +{ + public class DirectoryIndicator : ISystemPlugin + { + public List Query(Query query) + { + List results = new List(); + if (string.IsNullOrEmpty(query.RawQuery)) return results; + + if (CheckIfDirectory(query.RawQuery)) + { + Result result = new Result + { + Title = "Open this directory", + SubTitle = string.Format("path: {0}", query.RawQuery), + Score = 50, + IcoPath = "Images/folder.png", + Action = () => Process.Start(query.RawQuery) + }; + results.Add(result); + } + + return results; + } + + private bool CheckIfDirectory(string path) + { + return Directory.Exists(path); + } + + public void Init(PluginInitContext context) + { + } + + public string Name + { + get + { + return "DirectoryIndicator"; + } + } + + public string Description + { + get + { + return "DirectoryIndicator"; + } + } + } +} diff --git a/WinAlfred.Plugin.System/Programs.cs b/WinAlfred.Plugin.System/Programs.cs index 556932af07..7a2d31b865 100644 --- a/WinAlfred.Plugin.System/Programs.cs +++ b/WinAlfred.Plugin.System/Programs.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Windows.Forms; using Microsoft.Win32; @@ -27,6 +28,12 @@ namespace WinAlfred.Plugin.System List installedList = new List(); + + [DllImport("shell32.dll")] + static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner,[Out] StringBuilder lpszPath, int nFolder, bool fCreate); + const int CSIDL_COMMON_STARTMENU = 0x16; // \Windows\Start Menu\Programs + const int CSIDL_COMMON_PROGRAMS = 0x17; + public List Query(Query query) { if (string.IsNullOrEmpty(query.RawQuery) || query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List(); @@ -64,7 +71,10 @@ namespace WinAlfred.Plugin.System public void Init(PluginInitContext context) { indexDirectory.Add(Environment.GetFolderPath(Environment.SpecialFolder.Programs)); - indexDirectory.Add(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\Microsoft\Windows\Start Menu\Programs"); + + StringBuilder commonStartMenuPath = new StringBuilder(560); + SHGetSpecialFolderPath(IntPtr.Zero, commonStartMenuPath, CSIDL_COMMON_PROGRAMS, false); + indexDirectory.Add(commonStartMenuPath.ToString()); GetAppFromStartMenu(); } diff --git a/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj b/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj index f7d8449ea4..779af70e42 100644 --- a/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj +++ b/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj @@ -41,6 +41,7 @@ + diff --git a/WinAlfred/App.config b/WinAlfred/App.config index 01c0f5391e..e1eb5518f6 100644 --- a/WinAlfred/App.config +++ b/WinAlfred/App.config @@ -17,4 +17,4 @@ - + diff --git a/WinAlfred/App.xaml b/WinAlfred/App.xaml index ba0967d5dc..9acfef20e1 100644 --- a/WinAlfred/App.xaml +++ b/WinAlfred/App.xaml @@ -14,7 +14,6 @@ - diff --git a/WinAlfred/Images/folder.png b/WinAlfred/Images/folder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l-E< zP#oF`QwI!1EA@H^us#4u;s^%08a{S6sTkG=pxgWOKkMlYFg#EJh9lzwv?73h2E20& zrAfg+CkKdPRum^SjqOw{7j6&$!*?o_!viD0XmrC(Ad4*YhvDPDI{l5m|8x1N(UGB8 zlZp@%HL2Aq;m-YIj8w~%O9>uu7OQ7ZpXV_0U_5sLZnP}%j`0XW;+-LEUk%}@XP#Sl zw%N*?4}JXopKfeqIB(P&S^X!!e(`5>Gn1uv-!pOF14pax%0*^}E9FwH5I4?>_wncX+7~`@s#+gZU8I5E5MJw^zA>)j@E|mfA2e|K79OvgC{@u zp6O#>{?6~e`i~c{JPm9N+I%+v03P}J5C77>@7_B;CBh59xm%M-9B)MX;}^gA+wYaq zq?+Y&W2Z~&wg66j|JmNJ-#T{x>@T#qeA+HRx1#Mh{yzX~hW#;ZfI(gW0000eRN literal 0 HcmV?d00001 diff --git a/WinAlfred/MainWindow.xaml.cs b/WinAlfred/MainWindow.xaml.cs index 4a12ba4f75..d231c8c9ea 100644 --- a/WinAlfred/MainWindow.xaml.cs +++ b/WinAlfred/MainWindow.xaml.cs @@ -91,8 +91,14 @@ namespace WinAlfred { Show(); //FocusManager.SetFocusedElement(this, tbQuery); + tbQuery.Focusable = true; Keyboard.Focus(tbQuery); tbQuery.SelectAll(); + + if (!tbQuery.IsKeyboardFocused) + { + MessageBox.Show("didnt focus"); + } } private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) diff --git a/WinAlfred/Properties/Resources.Designer.cs b/WinAlfred/Properties/Resources.Designer.cs index 5b4270b0d5..c04e7374ec 100644 --- a/WinAlfred/Properties/Resources.Designer.cs +++ b/WinAlfred/Properties/Resources.Designer.cs @@ -1,73 +1,73 @@ -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本:4.0.30319.18052 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 -// -//------------------------------------------------------------------------------ - -namespace WinAlfred.Properties { - using System; - - - /// - /// 一个强类型的资源类,用于查找本地化的字符串等。 - /// - // 此类是由 StronglyTypedResourceBuilder - // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 - // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen - // (以 /str 作为命令选项),或重新生成 VS 项目。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// 返回此类使用的缓存的 ResourceManager 实例。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinAlfred.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// 使用此强类型资源类,为所有资源查找 - /// 重写当前线程的 CurrentUICulture 属性。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// 查找类似于 (Icon) 的 System.Drawing.Icon 类型的本地化资源。 - /// - internal static System.Drawing.Icon app { - get { - object obj = ResourceManager.GetObject("app", resourceCulture); - return ((System.Drawing.Icon)(obj)); - } - } - } -} +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.18052 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace WinAlfred.Properties { + using System; + + + /// + /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// 返回此类使用的缓存的 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinAlfred.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 使用此强类型资源类,为所有资源查找 + /// 重写当前线程的 CurrentUICulture 属性。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// 查找类似于 (Icon) 的 System.Drawing.Icon 类型的本地化资源。 + /// + internal static System.Drawing.Icon app { + get { + object obj = ResourceManager.GetObject("app", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + } +} diff --git a/WinAlfred/Properties/Settings.Designer.cs b/WinAlfred/Properties/Settings.Designer.cs index d6abbf65e1..caf9c18c10 100644 --- a/WinAlfred/Properties/Settings.Designer.cs +++ b/WinAlfred/Properties/Settings.Designer.cs @@ -1,26 +1,26 @@ -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本:4.0.30319.18052 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 -// -//------------------------------------------------------------------------------ - -namespace WinAlfred.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.18052 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace WinAlfred.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/WinAlfred/ResultPanel.xaml.cs b/WinAlfred/ResultPanel.xaml.cs index 6cf568da4f..35af12e2ac 100644 --- a/WinAlfred/ResultPanel.xaml.cs +++ b/WinAlfred/ResultPanel.xaml.cs @@ -195,6 +195,8 @@ namespace WinAlfred public bool AcceptSelect() { int index = GetCurrentSelectedResultIndex(); + if (index < 0) return false; + var resultItemControl = pnlContainer.Children[index] as ResultItem; if (resultItemControl != null) { diff --git a/WinAlfred/WinAlfred.csproj b/WinAlfred/WinAlfred.csproj index 722066c294..c695a139c8 100644 --- a/WinAlfred/WinAlfred.csproj +++ b/WinAlfred/WinAlfred.csproj @@ -9,7 +9,7 @@ Properties WinAlfred WinAlfred - v4.0 + v3.5 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 @@ -59,9 +59,6 @@ - - C:\Users\Scott\Desktop\Jurassic.dll - ..\packages\log4net.2.0.3\lib\net35-full\log4net.dll diff --git a/WinAlfred/packages.config b/WinAlfred/packages.config index e25e951af7..0db9c4556d 100644 --- a/WinAlfred/packages.config +++ b/WinAlfred/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file From 13f00edefd80139655235f5a1ffc0fecc02a3004 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Mon, 6 Jan 2014 22:21:08 +0800 Subject: [PATCH 09/16] fix shutdown didn't work issue --- WinAlfred.Plugin.System/Sys.cs | 3 ++- WinAlfred/App.xaml | 2 +- WinAlfred/App.xaml.cs | 39 ++++++++++++++++++++++++---------- WinAlfred/MainWindow.xaml.cs | 23 +++++++++++++++++++- WinAlfred/WinAlfred.csproj | 11 ++++++++++ 5 files changed, 64 insertions(+), 14 deletions(-) diff --git a/WinAlfred.Plugin.System/Sys.cs b/WinAlfred.Plugin.System/Sys.cs index 9919ca6c39..a2badb7ceb 100644 --- a/WinAlfred.Plugin.System/Sys.cs +++ b/WinAlfred.Plugin.System/Sys.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Runtime.InteropServices; using System.Text; @@ -44,7 +45,7 @@ namespace WinAlfred.Plugin.System SubTitle = "Shutdown Computer", Score = 100, IcoPath = "Images\\exit.png", - Action = () => ExitWindowsEx(EWX_SHUTDOWN,0) + Action = () => Process.Start("shutdown","/s /t 0") }); availableResults.Add(new Result { diff --git a/WinAlfred/App.xaml b/WinAlfred/App.xaml index 9acfef20e1..1a43596b7a 100644 --- a/WinAlfred/App.xaml +++ b/WinAlfred/App.xaml @@ -1,7 +1,7 @@  + > + diff --git a/WinAlfred/Commands/BaseCommand.cs b/WinAlfred/Commands/BaseCommand.cs index aa3dfbdb75..fd16c8ab55 100644 --- a/WinAlfred/Commands/BaseCommand.cs +++ b/WinAlfred/Commands/BaseCommand.cs @@ -20,10 +20,7 @@ namespace WinAlfred.Commands protected void UpdateResultView(List results) { - if (results.Count > 0) - { - window.OnUpdateResultView(results); - } + window.OnUpdateResultView(results); } } } diff --git a/WinAlfred/Commands/SystemCommand.cs b/WinAlfred/Commands/SystemCommand.cs index 52ff2d5d6e..7ecad98203 100644 --- a/WinAlfred/Commands/SystemCommand.cs +++ b/WinAlfred/Commands/SystemCommand.cs @@ -31,7 +31,7 @@ namespace WinAlfred.Commands result.PluginDirectory = pair1.Metadata.PluginDirecotry; result.OriginQuery = query; } - UpdateResultView(results); + if(results.Count > 0) UpdateResultView(results); }); } } diff --git a/WinAlfred/DispatcherExtensions.cs b/WinAlfred/DispatcherExtensions.cs index 72f5be8edf..15a56bfa71 100644 --- a/WinAlfred/DispatcherExtensions.cs +++ b/WinAlfred/DispatcherExtensions.cs @@ -13,7 +13,14 @@ namespace WinAlfred private static readonly object syncRoot = new object(); public static string DelayInvoke(this Dispatcher dispatcher, string namedInvocation, - Action action, TimeSpan delay, + Action action, TimeSpan delay, + DispatcherPriority priority = DispatcherPriority.Normal) + { + return DelayInvoke(dispatcher, namedInvocation, action, delay, string.Empty, priority); + } + + public static string DelayInvoke(this Dispatcher dispatcher, string namedInvocation, + Action action, TimeSpan delay, string arg, DispatcherPriority priority = DispatcherPriority.Normal) { lock (syncRoot) @@ -29,7 +36,7 @@ namespace WinAlfred var timer = new DispatcherTimer(delay, priority, (s, e) => { RemoveTimer(namedInvocation); - action(); + action(arg); }, dispatcher); timer.Start(); timers.Add(namedInvocation, timer); diff --git a/WinAlfred/Helper/SelectedRecords.cs b/WinAlfred/Helper/SelectedRecords.cs new file mode 100644 index 0000000000..8e773cfcbd --- /dev/null +++ b/WinAlfred/Helper/SelectedRecords.cs @@ -0,0 +1,38 @@ +using WinAlfred.Plugin; + +namespace WinAlfred.Helper +{ + public class SelectedRecords + { + private int hasAddedCount = 0; + + public void LoadSelectedRecords() + { + + } + + public void AddSelect(Result result) + { + hasAddedCount++; + if (hasAddedCount == 10) + { + SaveSelectedRecords(); + hasAddedCount = 0; + } + + + + + } + + public int GetSelectedCount(Result result) + { + return 0; + } + + public void SaveSelectedRecords() + { + + } + } +} diff --git a/WinAlfred/Images/enter.png b/WinAlfred/Images/enter.png new file mode 100644 index 0000000000000000000000000000000000000000..0999b37cd721455c0e0d80e2ba1e575e36c5c416 GIT binary patch literal 367 zcmV-#0g(QQP)kdg0003tNklP9G&dyU!;qxWJwVO zF?2II7kk*6)DVX*{q66=o8!1JbV7)gbtxk;hJF7+3iL}&`z|Tsaiz#FIi874k;Eu4 z3TQ5A4Gd^ukS3c}h0g&2wM-vra7>p2{u`ahfXeDade!wdH696N>mByRqH8?JWA%=6 z1UfGZ03a`rvAr>~UC|>$I5SR;Yq9`zn8OK{)RWoZ@9~MWSK|giw>iN9tFFOppowzD z1|f7+&M<7EO+F|Bev;BWyBq+qHbBnr_Xx`AkH+^A&M*ZKH((Nrv#BQeL|0i?OQ)#T ztE%8737EuP8wVryCm6T9vqmVJI97?IaQP2c3MFexTO?wBZ9{$1z5v=RREDvw-r@iN N002ovPDHLkV1h7Ho7VsU literal 0 HcmV?d00001 diff --git a/WinAlfred/Images/exit.png b/WinAlfred/Images/exit.png index 523c3d5197db3825be40fa89af1c943ec37dbcbd..af7c738244dfc50d7e896fdf41adad6283ba3d7f 100644 GIT binary patch delta 1697 zcmV;S244B36~hf7iBL{Q4GJ0x0000DNk~Le0000W0000W2nGNE0CReJ^pPPqe+E@a zL_t(og}s(th+Wkc$A4?>eeZl;O;a-H1d}!)A(;_1RGOEmB_K_)$p|8f526x?w&_Dj zq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y80rt7AUExlp`9on2A=xSiMZF6p@xFDM|D5 z$UtG;Xc`9WW*I_(mXfTnWSPOZz+^q3)G!0-U_dR=gb`4dI|i90j=|Z{A-pHeitRIC ztRwh>4I{*BalA}vr-Qi>Hy3bYi%dl4A6 zp*fE>%yUZ!Lt>=_-a#BGgb>7I5^F4n|8$J~m+eCRxQ=sy_1rSQlo5i* zS%-6u!U&4O5j;5O$g(XmFcJzmf+>IJ%lilYjn!m)=Ps(%7ExSA>k#3O*o&U?hqN0l5jo6ZwGg0q2JGl@cN)kYcEwh~a(#NFfkH+J#=_ zL0~^{5?BJv<|j}Im;hQp1t^c8N~7#-?o%V1I?c9ukv(96Z1g;Ox5Wa*Xr(|8SOq#E z1bg~Npct*qa;P%`onERl{WgPnz?}wgI)oejhs_m2;GY8kWfZ}gNT>J100000NkvXX Hu0mjf9Dlqa diff --git a/WinAlfred/MainWindow.xaml b/WinAlfred/MainWindow.xaml index d07aa89fd4..02da826d89 100644 --- a/WinAlfred/MainWindow.xaml +++ b/WinAlfred/MainWindow.xaml @@ -19,7 +19,7 @@ - + diff --git a/WinAlfred/MainWindow.xaml.cs b/WinAlfred/MainWindow.xaml.cs index 00e00e86ca..35fd1f2992 100644 --- a/WinAlfred/MainWindow.xaml.cs +++ b/WinAlfred/MainWindow.xaml.cs @@ -26,6 +26,8 @@ namespace WinAlfred private NotifyIcon notifyIcon; private Command cmdDispatcher; Storyboard progressBarStoryboard = new Storyboard(); + private bool queryHasReturn = false; + SelectedRecords selectedRecords = new SelectedRecords(); public MainWindow() { @@ -40,10 +42,10 @@ namespace WinAlfred private void InitProgressbarAnimation() { - DoubleAnimation da = new DoubleAnimation(progressBar.X2, Width + 100, new Duration(new TimeSpan(0, 0, 0,0,1600))); - DoubleAnimation da1 = new DoubleAnimation(progressBar.X1, Width, new Duration(new TimeSpan(0, 0, 0, 0,1600))); - Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X1)")); - Storyboard.SetTargetProperty(da1, new PropertyPath("(Line.X2)")); + DoubleAnimation da = new DoubleAnimation(progressBar.X2, Width + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600))); + DoubleAnimation da1 = new DoubleAnimation(progressBar.X1, Width, new Duration(new TimeSpan(0, 0, 0, 0, 1600))); + Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X2)")); + Storyboard.SetTargetProperty(da1, new PropertyPath("(Line.X1)")); progressBarStoryboard.Children.Add(da); progressBarStoryboard.Children.Add(da1); progressBarStoryboard.RepeatBehavior = RepeatBehavior.Forever; @@ -81,20 +83,45 @@ namespace WinAlfred } } + protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) + { + base.OnMouseLeftButtonDown(e); + + // Begin dragging the window + this.DragMove(); + } + private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e) { resultCtrl.Dirty = true; Dispatcher.DelayInvoke("UpdateSearch", - () => + o => { - resultCtrl.Clear(); + Dispatcher.DelayInvoke("ClearResults", i => + { + // first try to use clear method inside resultCtrl, which is more closer to the add new results + // and this will not bring splash issues.After waiting 30ms, if there still no results added, we + // must clear the result. otherwise, it will be confused why the query changed, but the results + // didn't. + if (resultCtrl.Dirty) resultCtrl.Clear(); + }, TimeSpan.FromMilliseconds(30), null); var q = new Query(tbQuery.Text); cmdDispatcher.DispatchCommand(q); + queryHasReturn = false; + if (Plugins.HitThirdpartyKeyword(q)) + { + Dispatcher.DelayInvoke("ShowProgressbar", originQuery => + { + if (!queryHasReturn && originQuery == tbQuery.Text) + { + StartProgress(); + } + }, TimeSpan.FromSeconds(1), tbQuery.Text); + } + }, TimeSpan.FromMilliseconds(300)); - } - private void StartProgress() { progressBar.Visibility = Visibility.Visible; @@ -124,7 +151,7 @@ namespace WinAlfred } } - public void SetAutoStart(bool IsAtuoRun) + private void SetAutoStart(bool IsAtuoRun) { string LnkPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "//WinAlfred.lnk"; if (IsAtuoRun) @@ -148,10 +175,10 @@ namespace WinAlfred Plugins.Init(this); cmdDispatcher = new Command(this); InitialTray(); + selectedRecords.LoadSelectedRecords(); SetAutoStart(true); //var engine = new Jurassic.ScriptEngine(); //MessageBox.Show(engine.Evaluate("5 * 10 + 2").ToString()); - StartProgress(); } private void TbQuery_OnPreviewKeyDown(object sender, KeyEventArgs e) @@ -174,7 +201,15 @@ namespace WinAlfred break; case Key.Enter: - if (resultCtrl.AcceptSelect()) HideWinAlfred(); + Result result = resultCtrl.AcceptSelect(); + if (result != null) + { + selectedRecords.AddSelect(result); + if (!result.DontHideWinAlfredAfterAction) + { + HideWinAlfred(); + } + } e.Handled = true; break; } @@ -182,11 +217,20 @@ namespace WinAlfred public void OnUpdateResultView(List list) { - resultCtrl.Dispatcher.Invoke(new Action(() => + queryHasReturn = true; + progressBar.Dispatcher.Invoke(new Action(StopProgress)); + if (list.Count > 0) { - List l = list.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == tbQuery.Text).OrderByDescending(o => o.Score).ToList(); - resultCtrl.AddResults(l); - })); + list.ForEach(o => + { + o.Score += selectedRecords.GetSelectedCount(o); + }); + resultCtrl.Dispatcher.Invoke(new Action(() => + { + List l = list.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == tbQuery.Text).OrderByDescending(o => o.Score).ToList(); + resultCtrl.AddResults(l); + })); + } } #region Public API diff --git a/WinAlfred/PluginLoader/Plugins.cs b/WinAlfred/PluginLoader/Plugins.cs index 42f527bf09..06bbceb65b 100644 --- a/WinAlfred/PluginLoader/Plugins.cs +++ b/WinAlfred/PluginLoader/Plugins.cs @@ -24,9 +24,9 @@ namespace WinAlfred.PluginLoader Plugins = plugins, ChangeQuery = s => window.ChangeQuery(s), CloseApp = window.CloseApp, - HideApp = window.HideApp, + HideApp = window.HideApp, ShowApp = window.ShowApp, - ShowMsg = (title,subTitle,iconPath) => window.ShowMsg(title,subTitle,iconPath) + ShowMsg = (title, subTitle, iconPath) => window.ShowMsg(title, subTitle, iconPath) })); } } @@ -35,5 +35,12 @@ namespace WinAlfred.PluginLoader { get { return plugins; } } + + public static bool HitThirdpartyKeyword(Query query) + { + if (string.IsNullOrEmpty(query.ActionName)) return false; + + return plugins.Any(o => o.Metadata.PluginType == PluginType.ThirdParty && o.Metadata.ActionKeyword == query.ActionName); + } } } diff --git a/WinAlfred/ResultItem.xaml b/WinAlfred/ResultItem.xaml index 50235dc9a4..34d3ef4d25 100644 --- a/WinAlfred/ResultItem.xaml +++ b/WinAlfred/ResultItem.xaml @@ -22,8 +22,8 @@ sdfdsf - - + + diff --git a/WinAlfred/ResultItem.xaml.cs b/WinAlfred/ResultItem.xaml.cs index 63cdba5678..389ee3af3a 100644 --- a/WinAlfred/ResultItem.xaml.cs +++ b/WinAlfred/ResultItem.xaml.cs @@ -27,6 +27,15 @@ namespace WinAlfred selected = value; BrushConverter bc = new BrushConverter(); Background = selected ? (Brush)(bc.ConvertFrom("#d1d1d1")) : (Brush)(bc.ConvertFrom("#ebebeb")); + if (selected) + { + img.Visibility = Visibility.Visible; + img.Source = new BitmapImage(new Uri(Directory.GetCurrentDirectory()+"\\Images\\enter.png")); + } + else + { + img.Visibility = Visibility.Hidden; + } } } diff --git a/WinAlfred/ResultPanel.xaml.cs b/WinAlfred/ResultPanel.xaml.cs index 35af12e2ac..26aa8f9598 100644 --- a/WinAlfred/ResultPanel.xaml.cs +++ b/WinAlfred/ResultPanel.xaml.cs @@ -192,10 +192,10 @@ namespace WinAlfred Select(0); } - public bool AcceptSelect() + public Result AcceptSelect() { int index = GetCurrentSelectedResultIndex(); - if (index < 0) return false; + if (index < 0) return null; var resultItemControl = pnlContainer.Children[index] as ResultItem; if (resultItemControl != null) @@ -205,10 +205,10 @@ namespace WinAlfred resultItemControl.Result.Action(); } - return !resultItemControl.Result.DontHideWinAlfredAfterAction; + return resultItemControl.Result; } - return true; + return null; } public ResultPanel() diff --git a/WinAlfred/WinAlfred.csproj b/WinAlfred/WinAlfred.csproj index 197c21d9ef..66418b728f 100644 --- a/WinAlfred/WinAlfred.csproj +++ b/WinAlfred/WinAlfred.csproj @@ -112,6 +112,7 @@ ResultItem.xaml + MSBuild:Compile Designer From 881d265579745aa5f5a38a68f9f275d579ebae1b Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Wed, 8 Jan 2014 19:08:48 +0800 Subject: [PATCH 12/16] update msg window --- WinAlfred/Msg.xaml | 4 ++-- WinAlfred/Msg.xaml.cs | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/WinAlfred/Msg.xaml b/WinAlfred/Msg.xaml index ef17b34532..06d7a65d60 100644 --- a/WinAlfred/Msg.xaml +++ b/WinAlfred/Msg.xaml @@ -7,7 +7,7 @@ ResizeMode="NoResize" WindowStyle="None" ShowInTaskbar="False" - Title="Msg" Height="60" Width="382.978"> + Title="Msg" Height="60" Width="420"> @@ -22,7 +22,7 @@ - + diff --git a/WinAlfred/Msg.xaml.cs b/WinAlfred/Msg.xaml.cs index 353279de68..5959f72862 100644 --- a/WinAlfred/Msg.xaml.cs +++ b/WinAlfred/Msg.xaml.cs @@ -69,14 +69,16 @@ namespace WinAlfred } imgIco.Source = new BitmapImage(new Uri(icopath)); Show(); - new Timer(o => - { - if (!closing) - { - closing = true; - Dispatcher.Invoke(new Action(fadeOutStoryboard.Begin)); - } - }, null, TimeSpan.FromSeconds(3), TimeSpan.FromMilliseconds(-1)); + + Dispatcher.DelayInvoke("ShowMsg", + o => + { + if (!closing) + { + closing = true; + Dispatcher.Invoke(new Action(fadeOutStoryboard.Begin)); + } + }, TimeSpan.FromSeconds(3)); } } } From 3f377d4efc2050b1f3cdf27fcc9ff361b199ea49 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Wed, 8 Jan 2014 23:21:37 +0800 Subject: [PATCH 13/16] add browser bookmark (chrome) plugin --- WinAlfred.Plugin.System/BrowserBookmarks.cs | 141 ++++++++++++++++++ .../WinAlfred.Plugin.System.csproj | 10 ++ WinAlfred.Plugin.System/packages.config | 4 + WinAlfred.Plugin/Result.cs | 5 + WinAlfred/Helper/SelectedRecords.cs | 49 +++++- WinAlfred/Images/bookmark.png | Bin 0 -> 4497 bytes 6 files changed, 202 insertions(+), 7 deletions(-) create mode 100644 WinAlfred.Plugin.System/BrowserBookmarks.cs create mode 100644 WinAlfred.Plugin.System/packages.config create mode 100644 WinAlfred/Images/bookmark.png diff --git a/WinAlfred.Plugin.System/BrowserBookmarks.cs b/WinAlfred.Plugin.System/BrowserBookmarks.cs new file mode 100644 index 0000000000..d7c86eeba4 --- /dev/null +++ b/WinAlfred.Plugin.System/BrowserBookmarks.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using Newtonsoft.Json; +using WinAlfred.Plugin.System.Common; + +namespace WinAlfred.Plugin.System +{ + public class BrowserBookmarks : ISystemPlugin + { + + private List bookmarks = new List(); + + [DllImport("shell32.dll")] + static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner, [Out] StringBuilder lpszPath, int nFolder, bool fCreate); + const int CSIDL_LOCAL_APPDATA = 0x001c; + + public List Query(Query query) + { + if (string.IsNullOrEmpty(query.RawQuery) || query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List(); + + List returnList = bookmarks.Where(o => MatchProgram(o, query)).ToList(); + + return returnList.Select(c => new Result() + { + Title = c.Name, + SubTitle = "Bookmark: " + c.Url, + IcoPath = Directory.GetCurrentDirectory() + @"\Images\bookmark.png", + Score = 5, + Action = () => + { + try + { + Process.Start(c.Url); + } + catch (Exception e) + { + MessageBox.Show("open url failed:" + c.Url); + } + } + }).ToList(); + } + + private bool MatchProgram(Bookmark bookmark, Query query) + { + if (bookmark.Name.ToLower().Contains(query.RawQuery.ToLower()) || bookmark.Url.ToLower().Contains(query.RawQuery.ToLower())) return true; + if (ChineseToPinYin.ToPinYin(bookmark.Name).Replace(" ", "").ToLower().Contains(query.RawQuery.ToLower())) return true; + + return false; + } + + public void Init(PluginInitContext context) + { + LoadChromeBookmarks(); + } + + private void LoadChromeBookmarks() + { + StringBuilder platformPath = new StringBuilder(560); + SHGetSpecialFolderPath(IntPtr.Zero, platformPath, CSIDL_LOCAL_APPDATA, false); + + string path = platformPath + @"\Google\Chrome\User Data\Default\Bookmarks"; + if (File.Exists(path)) + { + string all = File.ReadAllText(path); + Regex nameRegex = new Regex("\"name\": \"(?.*?)\""); + MatchCollection nameCollection = nameRegex.Matches(all); + Regex typeRegex = new Regex("\"type\": \"(?.*?)\""); + MatchCollection typeCollection = typeRegex.Matches(all); + Regex urlRegex = new Regex("\"url\": \"(?.*?)\""); + MatchCollection urlCollection = urlRegex.Matches(all); + + List names = (from Match match in nameCollection select match.Groups["name"].Value).ToList(); + List types = (from Match match in typeCollection select match.Groups["type"].Value).ToList(); + List urls = (from Match match in urlCollection select match.Groups["url"].Value).ToList(); + + int urlIndex = 0; + for (int i = 0; i < names.Count; i++) + { + string name = DecodeUnicode(names[i]); + string type = types[i]; + if (type == "url") + { + string url = urls[urlIndex]; + urlIndex++; + + bookmarks.Add(new Bookmark() + { + Name = name, + Url = url, + Source = "Chrome" + }); + } + } + } + else + { +#if (DEBUG) + { + MessageBox.Show("load chrome bookmark failed"); + } +#endif + } + } + + private String DecodeUnicode(String dataStr) + { + Regex reg = new Regex(@"(?i)\\[uU]([0-9a-f]{4})"); + return reg.Replace(dataStr, m => ((char)Convert.ToInt32(m.Groups[1].Value, 16)).ToString()); + } + + public string Name + { + get + { + return "BrowserBookmark"; + } + } + + public string Description + { + get + { + return "BrowserBookmark"; + } + } + } + + public class Bookmark + { + public string Name { get; set; } + public string Url { get; set; } + public string Source { get; set; } + } +} diff --git a/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj b/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj index 779af70e42..9119d543e2 100644 --- a/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj +++ b/WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj @@ -11,6 +11,8 @@ WinAlfred.Plugin.System v3.5 512 + ..\ + true true @@ -30,6 +32,9 @@ 4 + + ..\packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll + @@ -39,6 +44,7 @@ + @@ -54,11 +60,15 @@ WinAlfred.Plugin + + + +