diff --git a/Wox.Plugin.SystemPlugins/ControlPanel/ControlPanel.cs b/Wox.Plugin.SystemPlugins/ControlPanel/ControlPanel.cs new file mode 100644 index 000000000..e693ed78b --- /dev/null +++ b/Wox.Plugin.SystemPlugins/ControlPanel/ControlPanel.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Wox.Infrastructure; +using Wox.Infrastructure.Storage.UserSettings; +using WindowsControlPanelItems; +using System.Diagnostics; +using System.IO; + +namespace Wox.Plugin.SystemPlugins.ControlPanel +{ + public class ControlPanel : BaseSystemPlugin + { + #region Properties + + private PluginInitContext context; + + public override string Description + { + get + { + return "Search within the Control Panel."; + } + } + + public override string ID + { + get { return "209621585B9B4D81813913C507C058C6"; } + } + + public override string Name { get { return "Control Panel"; } } + + public override string IcoPath { get { return @"Images\ControlPanel.png"; } } + + private List controlPanelItems; + private string iconFolder; + private string fileType; + + #endregion Properties + + protected override void InitInternal(PluginInitContext context) + { + this.context = context; + controlPanelItems = WindowsControlPanelItems.List.Create(48); + iconFolder = @"Images\ControlPanelIcons\"; + fileType = ".bmp"; + + foreach (ControlPanelItem item in controlPanelItems) + { + if (!File.Exists(iconFolder + item.ApplicationName + fileType)) + { + item.Icon.ToBitmap().Save(iconFolder + item.ApplicationName + fileType); + } + } + } + + protected override List QueryInternal(Query query) + { + if (query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List(); + string myQuery = query.RawQuery.Trim(); + + List results = new List(); + List filteredResults = new List(); + + foreach (var item in controlPanelItems) + { + if (item.LocalizedString.IndexOf(myQuery, StringComparison.OrdinalIgnoreCase) >= 0) + { + results.Insert(0, new Result() + { + Title = item.LocalizedString, + SubTitle = item.InfoTip, + IcoPath = "Images\\ControlPanelIcons\\" + item.ApplicationName + fileType, + Action = e => + { + try + { + Process.Start(item.ExecutablePath); + } + catch (Exception) + { + //Silently Fail for now.. + } + return true; + } + }); + } + else if (item.InfoTip.IndexOf(myQuery, StringComparison.OrdinalIgnoreCase) >= 0) + { + results.Add(new Result() + { + Title = item.LocalizedString, + SubTitle = item.InfoTip, + IcoPath = "Images\\ControlPanelIcons\\" + item.ApplicationName + fileType, + Action = e => + { + try + { + Process.Start(item.ExecutablePath); + } + catch (Exception) + { + //Silently Fail for now.. + } + return true; + } + }); + } + } + for (int i = 0; i < 2 && i < results.Count; i++) + { + filteredResults.Add(results[i]); + } + + return filteredResults; + } + } +} diff --git a/Wox.Plugin.SystemPlugins/Sys.cs b/Wox.Plugin.SystemPlugins/Sys.cs index 5d1360dc7..ceeaf4dde 100644 --- a/Wox.Plugin.SystemPlugins/Sys.cs +++ b/Wox.Plugin.SystemPlugins/Sys.cs @@ -105,7 +105,7 @@ namespace Wox.Plugin.SystemPlugins }); availableResults.Add(new Result { - Title = "Setting", + Title = "Settings", SubTitle = "Tweak this app", Score = 40, IcoPath = "Images\\app.png", diff --git a/Wox.Plugin.SystemPlugins/Wox.Plugin.SystemPlugins.csproj b/Wox.Plugin.SystemPlugins/Wox.Plugin.SystemPlugins.csproj index 809178144..38a88dd56 100644 --- a/Wox.Plugin.SystemPlugins/Wox.Plugin.SystemPlugins.csproj +++ b/Wox.Plugin.SystemPlugins/Wox.Plugin.SystemPlugins.csproj @@ -41,6 +41,9 @@ + + ..\packages\WindowsControlPanelItems.dll.1.0.0\lib\net35\WindowsControlPanelItems.dll + ..\packages\YAMP.1.3.0\lib\net35\YAMP.dll @@ -59,6 +62,7 @@ + FolderPluginSettings.xaml @@ -130,6 +134,9 @@ Designer + + + diff --git a/Wox.Plugin.SystemPlugins/packages.config b/Wox.Plugin.SystemPlugins/packages.config index 7cc723c82..5166ffa5c 100644 --- a/Wox.Plugin.SystemPlugins/packages.config +++ b/Wox.Plugin.SystemPlugins/packages.config @@ -2,5 +2,6 @@ + \ No newline at end of file diff --git a/Wox/Images/ControlPanel.png b/Wox/Images/ControlPanel.png new file mode 100644 index 000000000..09c9849c4 Binary files /dev/null and b/Wox/Images/ControlPanel.png differ diff --git a/Wox/SettingWindow.xaml b/Wox/SettingWindow.xaml index 99a1c9bbd..ac66cc1dc 100644 --- a/Wox/SettingWindow.xaml +++ b/Wox/SettingWindow.xaml @@ -7,7 +7,7 @@ xmlns:system="clr-namespace:Wox.Plugin.SystemPlugins;assembly=Wox.Plugin.SystemPlugins" xmlns:converters="clr-namespace:Wox.Converters" Icon="Images\app.png" - Title="Wox Setting" + Title="Wox Settings" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Height="600" Width="800">