structure change

This commit is contained in:
qianlifeng
2014-01-03 23:52:36 +08:00
parent 1eb3f449e2
commit dc51bc39ab
27 changed files with 289 additions and 257 deletions

View File

@@ -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<Result> Query(Query query)
{
throw new NotImplementedException();
List<Result> results = new List<Result>();
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.";
}
}
}
}

View File

@@ -7,5 +7,7 @@ namespace WinAlfred.Plugin.System
{
public interface ISystemPlugin : IPlugin
{
string Name { get; }
string Description { get; }
}
}

View File

@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
namespace WinAlfred.Plugin.System
{
public class Sys : ISystemPlugin
{
List<Result> availableResults = new List<Result>();
[DllImport("user32")]
public static extern bool ExitWindowsEx(uint uFlags, uint dwReason);
[DllImport("user32")]
public static extern void LockWorkStation();
public List<Result> Query(Query query)
{
List<Result> results = new List<Result>();
foreach (Result availableResult in availableResults)
{
if (availableResult.Title.ToLower().StartsWith(query.RawQuery.ToLower()))
{
results.Add(availableResult);
}
}
return results;
}
public void Init(PluginInitContext context)
{
availableResults.Add(new Result
{
Title = "Shutdown",
SubTitle = "Shutdown Computer",
Score = 100,
Action = () => MessageBox.Show("shutdown")
});
availableResults.Add(new Result
{
Title = "Log off",
SubTitle = "Log off current user",
Score = 10,
Action = () => MessageBox.Show("Logoff")
});
availableResults.Add(new Result
{
Title = "Lock",
SubTitle = "Lock this computer",
Score = 20,
IcoPath = "Images\\lock.png",
Action = () => LockWorkStation()
});
}
public string Name
{
get
{
return "sys";
}
}
public string Description
{
get
{
return "provide system commands";
}
}
}
}

View File

@@ -32,6 +32,7 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
@@ -41,6 +42,8 @@
<Compile Include="CMD.cs" />
<Compile Include="ISystemPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Sys.cs" />
<Compile Include="ThirdpartyPluginIndicator.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WinAlfred.Plugin\WinAlfred.Plugin.csproj">
@@ -49,6 +52,10 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">