2025-12-23 21:07:44 +08:00
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
|
// 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.Collections.Generic;
|
|
|
|
|
using Microsoft.CommandPalette.Extensions;
|
|
|
|
|
using Microsoft.CommandPalette.Extensions.Toolkit;
|
|
|
|
|
using PowerToysExtension.Helpers;
|
2026-01-04 15:18:27 +08:00
|
|
|
using PowerToysExtension.Properties;
|
2025-12-23 21:07:44 +08:00
|
|
|
|
|
|
|
|
namespace PowerToysExtension;
|
|
|
|
|
|
|
|
|
|
public partial class PowerToysExtensionCommandsProvider : CommandProvider
|
|
|
|
|
{
|
|
|
|
|
private readonly ICommandItem[] _commands;
|
|
|
|
|
|
|
|
|
|
public PowerToysExtensionCommandsProvider()
|
|
|
|
|
{
|
2026-01-04 15:18:27 +08:00
|
|
|
DisplayName = Resources.PowerToys_DisplayName;
|
2025-12-23 21:07:44 +08:00
|
|
|
Icon = PowerToysResourcesHelper.IconFromSettingsIcon("PowerToys.png");
|
|
|
|
|
_commands = [
|
|
|
|
|
new CommandItem(new Pages.PowerToysListPage())
|
|
|
|
|
{
|
2026-01-04 15:18:27 +08:00
|
|
|
Title = Resources.PowerToys_DisplayName,
|
|
|
|
|
Subtitle = Resources.PowerToys_Subtitle,
|
2025-12-23 21:07:44 +08:00
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override ICommandItem[] TopLevelCommands()
|
|
|
|
|
{
|
|
|
|
|
return _commands;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IFallbackCommandItem[] FallbackCommands()
|
|
|
|
|
{
|
|
|
|
|
var items = ModuleCommandCatalog.GetAllItems();
|
|
|
|
|
var fallbacks = new List<IFallbackCommandItem>(items.Length);
|
|
|
|
|
foreach (var item in items)
|
|
|
|
|
{
|
|
|
|
|
if (item?.Command is not ICommand cmd)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fallbacks.Add(new PowerToysFallbackCommandItem(cmd, item.Title, item.Subtitle, item.Icon, item.MoreCommands));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fallbacks.ToArray();
|
|
|
|
|
}
|
|
|
|
|
}
|