make toplevelcommand a single object that lives over the lifetime of the app

This commit is contained in:
Jordi Adoumie
2024-12-13 11:23:21 -05:00
parent 7e512565df
commit 35f4416fe2

View File

@@ -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];
}