/ src / modules / cmdpal / Microsoft.CmdPal.UI.ViewModels / Commands / BuiltInsCommandProvider.cs
BuiltInsCommandProvider.cs
 1  // Copyright (c) Microsoft Corporation
 2  // The Microsoft Corporation licenses this file to you under the MIT license.
 3  // See the LICENSE file in the project root for more information.
 4  
 5  using Microsoft.CommandPalette.Extensions;
 6  using Microsoft.CommandPalette.Extensions.Toolkit;
 7  
 8  namespace Microsoft.CmdPal.UI.ViewModels.BuiltinCommands;
 9  
10  /// <summary>
11  /// Built-in Provider for a top-level command which can quit the application. Invokes the <see cref="QuitCommand"/>, which sends a <see cref="QuitMessage"/>.
12  /// </summary>
13  public sealed partial class BuiltInsCommandProvider : CommandProvider
14  {
15      private readonly OpenSettingsCommand openSettings = new();
16      private readonly QuitCommand quitCommand = new();
17      private readonly FallbackReloadItem _fallbackReloadItem = new();
18      private readonly FallbackLogItem _fallbackLogItem = new();
19      private readonly NewExtensionPage _newExtension = new();
20  
21      public override ICommandItem[] TopLevelCommands() =>
22          [
23              new CommandItem(openSettings) { },
24              new CommandItem(_newExtension) { Title = _newExtension.Title },
25          ];
26  
27      public override IFallbackCommandItem[] FallbackCommands() =>
28          [
29              new FallbackCommandItem(
30                      quitCommand,
31                      Properties.Resources.builtin_quit_subtitle,
32                      quitCommand.Id)
33              {
34                  Subtitle = Properties.Resources.builtin_quit_subtitle,
35              },
36              _fallbackReloadItem,
37              _fallbackLogItem,
38          ];
39  
40      public BuiltInsCommandProvider()
41      {
42          Id = "com.microsoft.cmdpal.builtin.core";
43          DisplayName = Properties.Resources.builtin_display_name;
44          Icon = IconHelpers.FromRelativePath("Assets\\StoreLogo.scale-200.png");
45      }
46  
47      public override void InitializeWithHost(IExtensionHost host) => BuiltinsExtensionHost.Instance.Initialize(host);
48  }