mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 11:17:53 +01:00
structure change
This commit is contained in:
75
WinAlfred.Plugin.System/Sys.cs
Normal file
75
WinAlfred.Plugin.System/Sys.cs
Normal 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";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user