Changes: Added Sys Folder, Moved Sys into folder, Added SysSettings, Made Sys use an AddRange and added ISettingProvider

This commit is contained in:
Aaron Campf
2014-07-24 17:27:59 -07:00
parent 4ba222f19c
commit 0385662197
2 changed files with 8 additions and 142 deletions

View File

@@ -1,141 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
namespace Wox.Plugin.SystemPlugins
{
public class Sys : BaseSystemPlugin
{
List<Result> availableResults = new List<Result>();
internal const int EWX_LOGOFF = 0x00000000;
internal const int EWX_SHUTDOWN = 0x00000001;
internal const int EWX_REBOOT = 0x00000002;
internal const int EWX_FORCE = 0x00000004;
internal const int EWX_POWEROFF = 0x00000008;
internal const int EWX_FORCEIFHUNG = 0x00000010;
[DllImport("user32")]
public static extern bool ExitWindowsEx(uint uFlags, uint dwReason);
[DllImport("user32")]
public static extern void LockWorkStation();
protected override List<Result> QueryInternal(Query query)
{
if (query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List<Result>();
List<Result> results = new List<Result>();
foreach (Result availableResult in availableResults)
{
if (availableResult.Title.ToLower().StartsWith(query.RawQuery.ToLower()))
{
results.Add(availableResult);
}
}
return results;
}
protected override void InitInternal(PluginInitContext context)
{
availableResults.Add(new Result
{
Title = "Shutdown",
SubTitle = "Shutdown Computer",
Score = 100,
IcoPath = "Images\\exit.png",
Action = (c) =>
{
Process.Start("shutdown", "/s /t 0");
return true;
}
});
availableResults.Add(new Result
{
Title = "Log off",
SubTitle = "Log off current user",
Score = 20,
IcoPath = "Images\\logoff.png",
Action = (c) => ExitWindowsEx(EWX_LOGOFF, 0)
});
availableResults.Add(new Result
{
Title = "Lock",
SubTitle = "Lock this computer",
Score = 20,
IcoPath = "Images\\lock.png",
Action = (c) =>
{
LockWorkStation();
return true;
}
});
availableResults.Add(new Result
{
Title = "Exit",
SubTitle = "Close this app",
Score = 110,
IcoPath = "Images\\app.png",
Action = (c) =>
{
context.API.CloseApp();
return true;
}
});
availableResults.Add(new Result
{
Title = "Restart Wox",
SubTitle = "Restart Wox",
Score = 110,
IcoPath = "Images\\restart.png",
Action = (c) =>
{
ProcessStartInfo Info = new ProcessStartInfo();
Info.Arguments = "/C ping 127.0.0.1 -n 1 && \"" + Application.ExecutablePath + "\"";
Info.WindowStyle = ProcessWindowStyle.Hidden;
Info.CreateNoWindow = true;
Info.FileName = "cmd.exe";
Process.Start(Info);
context.API.CloseApp();
return true;
}
});
availableResults.Add(new Result
{
Title = "Settings",
SubTitle = "Tweak this app",
Score = 40,
IcoPath = "Images\\app.png",
Action = (c) =>
{
context.API.OpenSettingDialog();
return true;
}
});
}
public override string ID
{
get { return "CEA08895D2544B019B2E9C5009600DF4"; }
}
public override string Name
{
get { return "System Commands"; }
}
public override string IcoPath
{
get { return @"Images\lock.png"; }
}
public override string Description
{
get { return "Provide System related commands. e.g. shutdown,lock,setting etc."; }
}
}
}

View File

@@ -81,6 +81,9 @@
<Compile Include="Program\ProgramSources\UserStartMenuProgramSource.cs" /> <Compile Include="Program\ProgramSources\UserStartMenuProgramSource.cs" />
<Compile Include="SuggestionSources\Baidu.cs" /> <Compile Include="SuggestionSources\Baidu.cs" />
<Compile Include="SuggestionSources\SuggestionSourceFactory.cs" /> <Compile Include="SuggestionSources\SuggestionSourceFactory.cs" />
<Compile Include="Sys\SysSettings.xaml.cs">
<DependentUpon>SysSettings.xaml</DependentUpon>
</Compile>
<Compile Include="UrlPlugin.cs" /> <Compile Include="UrlPlugin.cs" />
<Compile Include="WebSearch\WebSearchesSetting.xaml.cs"> <Compile Include="WebSearch\WebSearchesSetting.xaml.cs">
<DependentUpon>WebSearchesSetting.xaml</DependentUpon> <DependentUpon>WebSearchesSetting.xaml</DependentUpon>
@@ -91,7 +94,7 @@
<Compile Include="ISystemPlugin.cs" /> <Compile Include="ISystemPlugin.cs" />
<Compile Include="Program\Programs.cs" /> <Compile Include="Program\Programs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Sys.cs" /> <Compile Include="Sys\Sys.cs" />
<Compile Include="ThirdpartyPluginIndicator.cs" /> <Compile Include="ThirdpartyPluginIndicator.cs" />
<Compile Include="SuggestionSources\Google.cs" /> <Compile Include="SuggestionSources\Google.cs" />
<Compile Include="SuggestionSources\ISuggestionSource.cs" /> <Compile Include="SuggestionSources\ISuggestionSource.cs" />
@@ -126,6 +129,10 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Include="Sys\SysSettings.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="WebSearch\WebSearchesSetting.xaml"> <Page Include="WebSearch\WebSearchesSetting.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>