mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
UI staff
This commit is contained in:
BIN
Plugins/WinAlfred.Plugin.System/Images/lock.png
Normal file
BIN
Plugins/WinAlfred.Plugin.System/Images/lock.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
@@ -1,36 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WinAlfred.Plugin.System
|
||||
{
|
||||
public class Main : IPlugin
|
||||
{
|
||||
List<Result> results = new List<Result>();
|
||||
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)
|
||||
{
|
||||
results.Clear();
|
||||
|
||||
List<Result> results = new List<Result>();
|
||||
if (query.ActionParameters.Count == 0)
|
||||
{
|
||||
results.Add(new Result
|
||||
{
|
||||
Title = "Shutdown",
|
||||
SubTitle = "shutdown your computer",
|
||||
Score = 100,
|
||||
Action = () =>
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
results = availableResults;
|
||||
}
|
||||
else
|
||||
{
|
||||
results.AddRange(availableResults.Where(result => result.Title.ToLower().Contains(query.ActionParameters[0].ToLower())));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
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()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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" />
|
||||
@@ -52,10 +53,14 @@
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Images\lock.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>xcopy /Y $(TargetDir)$(TargetFileName) $(SolutionDir)WinAlfred\bin\Debug\Plugins\System\
|
||||
xcopy /Y $(TargetDir)plugin.ini $(SolutionDir)WinAlfred\bin\Debug\Plugins\System\</PostBuildEvent>
|
||||
xcopy /Y $(TargetDir)plugin.ini $(SolutionDir)WinAlfred\bin\Debug\Plugins\System\
|
||||
xcopy /Y $(ProjectDir)Images\*.* $(SolutionDir)WinAlfred\bin\Debug\Plugins\System\Images\</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.
|
||||
|
||||
Reference in New Issue
Block a user