Merge pull request #119 from CoenraadS/master

Added Control Panel
This commit is contained in:
qianlifeng 2014-07-18 09:43:16 +08:00
commit 3cfa4f9cb7
6 changed files with 129 additions and 2 deletions

View file

@ -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<ControlPanelItem> 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<Result> QueryInternal(Query query)
{
if (query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List<Result>();
string myQuery = query.RawQuery.Trim();
List<Result> results = new List<Result>();
List<Result> filteredResults = new List<Result>();
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;
}
}
}

View file

@ -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",

View file

@ -41,6 +41,9 @@
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="WindowsBase" />
<Reference Include="WindowsControlPanelItems">
<HintPath>..\packages\WindowsControlPanelItems.dll.1.0.0\lib\net35\WindowsControlPanelItems.dll</HintPath>
</Reference>
<Reference Include="YAMP">
<HintPath>..\packages\YAMP.1.3.0\lib\net35\YAMP.dll</HintPath>
</Reference>
@ -59,6 +62,7 @@
</Compile>
<Compile Include="CMD\CMDStorage.cs" />
<Compile Include="ColorsPlugin.cs" />
<Compile Include="ControlPanel\ControlPanel.cs" />
<Compile Include="Folder\FolderPluginSettings.xaml.cs">
<DependentUpon>FolderPluginSettings.xaml</DependentUpon>
</Compile>
@ -130,6 +134,9 @@
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>

View file

@ -2,5 +2,6 @@
<packages>
<package id="ini-parser" version="2.0.2" targetFramework="net35" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net35" />
<package id="WindowsControlPanelItems.dll" version="1.0.0" targetFramework="net35" />
<package id="YAMP" version="1.3.0" targetFramework="net35" />
</packages>

BIN
Wox/Images/ControlPanel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View file

@ -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">