mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-01-12 23:36:19 +01:00
make toplevelcommand a single object that lives over the lifetime of the app
This commit is contained in:
@@ -2,11 +2,6 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Versioning;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Components;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Helpers;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Pages;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Properties;
|
||||
@@ -17,6 +12,7 @@ namespace Microsoft.CmdPal.Ext.WindowWalker;
|
||||
|
||||
public partial class WindowWalkerCommandsProvider : CommandProvider
|
||||
{
|
||||
private readonly CommandItem _windowWalkerPageItem;
|
||||
private readonly SettingsManager _settingsManager = new();
|
||||
|
||||
internal static readonly VirtualDesktopHelper VirtualDesktopHelperInstance = new();
|
||||
@@ -24,19 +20,16 @@ public partial class WindowWalkerCommandsProvider : CommandProvider
|
||||
public WindowWalkerCommandsProvider()
|
||||
{
|
||||
DisplayName = Resources.windowwalker_name;
|
||||
_windowWalkerPageItem = new CommandItem(new WindowWalkerListPage())
|
||||
{
|
||||
Icon = new("\uE8B0"), // Window icon
|
||||
Title = Resources.window_walker_top_level_command_title,
|
||||
Subtitle = Resources.windowwalker_name,
|
||||
MoreCommands = [
|
||||
new CommandContextItem(new SettingsPage()),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
public override ICommandItem[] TopLevelCommands()
|
||||
{
|
||||
return [
|
||||
new CommandItem(new WindowWalkerListPage())
|
||||
{
|
||||
Title = Resources.window_walker_top_level_command_title,
|
||||
Subtitle = Resources.windowwalker_name,
|
||||
MoreCommands = [
|
||||
new CommandContextItem(new SettingsPage()),
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
public override ICommandItem[] TopLevelCommands() => [_windowWalkerPageItem];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user