mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 20:57:22 +02:00
use caculated score for sys plugin item
This commit is contained in:
@@ -39,8 +39,11 @@ namespace Wox.Plugin.Sys
|
|||||||
List<Result> results = new List<Result>();
|
List<Result> results = new List<Result>();
|
||||||
foreach (Result availableResult in availableResults)
|
foreach (Result availableResult in availableResults)
|
||||||
{
|
{
|
||||||
if (StringMatcher.IsMatch(availableResult.Title, query.Search) || StringMatcher.IsMatch(availableResult.SubTitle, query.Search))
|
int titleScore = StringMatcher.Match(availableResult.Title, query.Search);
|
||||||
|
int subTitleScore = StringMatcher.Match(availableResult.SubTitle, query.Search);
|
||||||
|
if (titleScore > 0 || subTitleScore > 0)
|
||||||
{
|
{
|
||||||
|
availableResult.Score = titleScore > 0 ? titleScore : subTitleScore;
|
||||||
results.Add(availableResult);
|
results.Add(availableResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,91 +59,84 @@ namespace Wox.Plugin.Sys
|
|||||||
private void LoadCommands()
|
private void LoadCommands()
|
||||||
{
|
{
|
||||||
availableResults.AddRange(new Result[] {
|
availableResults.AddRange(new Result[] {
|
||||||
new Result
|
new Result
|
||||||
{
|
{
|
||||||
Title = "Shutdown",
|
Title = "Shutdown",
|
||||||
SubTitle = context.API.GetTranslation("wox_plugin_sys_shutdown_computer"),
|
SubTitle = context.API.GetTranslation("wox_plugin_sys_shutdown_computer"),
|
||||||
Score = 100,
|
IcoPath = "Images\\exit.png",
|
||||||
IcoPath = "Images\\exit.png",
|
Action = (c) =>
|
||||||
Action = (c) =>
|
{
|
||||||
{
|
if (MessageBox.Show("Are you sure you want to shut the computer down?","Shutdown Computer?",MessageBoxButtons.YesNo,MessageBoxIcon.Warning) == DialogResult.Yes) {
|
||||||
if (MessageBox.Show("Are you sure you want to shut the computer down?","Shutdown Computer?",MessageBoxButtons.YesNo,MessageBoxIcon.Warning) == DialogResult.Yes) {
|
Process.Start("shutdown", "/s /t 0");
|
||||||
Process.Start("shutdown", "/s /t 0");
|
}
|
||||||
}
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
},
|
||||||
},
|
new Result
|
||||||
new Result
|
{
|
||||||
{
|
Title = "Log off",
|
||||||
Title = "Log off",
|
|
||||||
SubTitle = context.API.GetTranslation("wox_plugin_sys_log_off"),
|
SubTitle = context.API.GetTranslation("wox_plugin_sys_log_off"),
|
||||||
Score = 100,
|
IcoPath = "Images\\logoff.png",
|
||||||
IcoPath = "Images\\logoff.png",
|
Action = (c) => ExitWindowsEx(EWX_LOGOFF, 0)
|
||||||
Action = (c) => ExitWindowsEx(EWX_LOGOFF, 0)
|
},
|
||||||
},
|
new Result
|
||||||
new Result
|
{
|
||||||
{
|
Title = "Lock",
|
||||||
Title = "Lock",
|
|
||||||
SubTitle = context.API.GetTranslation("wox_plugin_sys_lock"),
|
SubTitle = context.API.GetTranslation("wox_plugin_sys_lock"),
|
||||||
Score = 100,
|
IcoPath = "Images\\lock.png",
|
||||||
IcoPath = "Images\\lock.png",
|
Action = (c) =>
|
||||||
Action = (c) =>
|
{
|
||||||
{
|
LockWorkStation();
|
||||||
LockWorkStation();
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
},
|
||||||
},
|
|
||||||
new Result
|
new Result
|
||||||
{
|
{
|
||||||
Title = "Sleep",
|
Title = "Sleep",
|
||||||
SubTitle = context.API.GetTranslation("wox_plugin_sys_sleep"),
|
SubTitle = context.API.GetTranslation("wox_plugin_sys_sleep"),
|
||||||
Score = 100,
|
|
||||||
IcoPath = "Images\\sleep.png",
|
IcoPath = "Images\\sleep.png",
|
||||||
Action = (c) => Application.SetSuspendState(PowerState.Suspend, false, false)
|
Action = (c) => Application.SetSuspendState(PowerState.Suspend, false, false)
|
||||||
},
|
},
|
||||||
new Result
|
new Result
|
||||||
{
|
{
|
||||||
Title = "Exit",
|
Title = "Exit",
|
||||||
SubTitle = context.API.GetTranslation("wox_plugin_sys_exit"),
|
SubTitle = context.API.GetTranslation("wox_plugin_sys_exit"),
|
||||||
Score = 110,
|
IcoPath = "Images\\app.png",
|
||||||
IcoPath = "Images\\app.png",
|
Action = (c) =>
|
||||||
Action = (c) =>
|
{
|
||||||
{
|
context.API.CloseApp();
|
||||||
context.API.CloseApp();
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
},
|
||||||
},
|
new Result
|
||||||
new Result
|
{
|
||||||
{
|
Title = "Restart Wox",
|
||||||
Title = "Restart Wox",
|
|
||||||
SubTitle = context.API.GetTranslation("wox_plugin_sys_restart"),
|
SubTitle = context.API.GetTranslation("wox_plugin_sys_restart"),
|
||||||
Score = 110,
|
IcoPath = "Images\\restart.png",
|
||||||
IcoPath = "Images\\restart.png",
|
Action = (c) =>
|
||||||
Action = (c) =>
|
{
|
||||||
{
|
ProcessStartInfo Info = new ProcessStartInfo();
|
||||||
ProcessStartInfo Info = new ProcessStartInfo();
|
Info.Arguments = "/C ping 127.0.0.1 -n 1 && \"" + Application.ExecutablePath + "\"";
|
||||||
Info.Arguments = "/C ping 127.0.0.1 -n 1 && \"" + Application.ExecutablePath + "\"";
|
Info.WindowStyle = ProcessWindowStyle.Hidden;
|
||||||
Info.WindowStyle = ProcessWindowStyle.Hidden;
|
Info.CreateNoWindow = true;
|
||||||
Info.CreateNoWindow = true;
|
Info.FileName = "cmd.exe";
|
||||||
Info.FileName = "cmd.exe";
|
Process.Start(Info);
|
||||||
Process.Start(Info);
|
context.API.CloseApp();
|
||||||
context.API.CloseApp();
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
},
|
||||||
},
|
new Result
|
||||||
new Result
|
{
|
||||||
{
|
Title = "Settings",
|
||||||
Title = "Settings",
|
|
||||||
SubTitle = context.API.GetTranslation("wox_plugin_sys_setting"),
|
SubTitle = context.API.GetTranslation("wox_plugin_sys_setting"),
|
||||||
Score = 100,
|
IcoPath = "Images\\app.png",
|
||||||
IcoPath = "Images\\app.png",
|
Action = (c) =>
|
||||||
Action = (c) =>
|
{
|
||||||
{
|
context.API.OpenSettingDialog();
|
||||||
context.API.OpenSettingDialog();
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetLanguagesFolder()
|
public string GetLanguagesFolder()
|
||||||
|
|||||||
Reference in New Issue
Block a user