Standardizing built-in extension icon handling (#40606)

Just standardizing built-in extensions to use a `internal sealed class
Icons` for all their non-dynamic icons.

Looks like a LOT of changes, but it's icons all the way down.
This commit is contained in:
Michael Jolley
2025-07-15 14:33:25 -05:00
committed by GitHub
parent cc16b61eb7
commit b552f2ac1e
93 changed files with 371 additions and 245 deletions

View File

@@ -21,19 +21,19 @@ internal sealed partial class CopyRegistryInfoCommand : InvokableCommand
if (typeToCopy == CopyType.Key)
{
Name = Resources.CopyKeyNamePath;
Icon = new IconInfo("\xE8C8"); // Copy Icon
Icon = Icons.CopyIcon;
_stringToCopy = entry.GetRegistryKey();
}
else if (typeToCopy == CopyType.ValueData)
{
Name = Resources.CopyValueData;
Icon = new IconInfo("\xF413"); // CopyTo Icon
Icon = Icons.CopyToIcon;
_stringToCopy = entry.GetValueData();
}
else if (typeToCopy == CopyType.ValueName)
{
Name = Resources.CopyValueName;
Icon = new IconInfo("\xE8C8"); // Copy Icon
Icon = Icons.CopyIcon;
_stringToCopy = entry.GetValueNameWithKey();
}

View File

@@ -27,7 +27,7 @@ internal sealed partial class OpenKeyInEditorCommand : InvokableCommand
internal OpenKeyInEditorCommand(RegistryEntry entry)
{
Name = Resources.OpenKeyInRegistryEditor;
Icon = new IconInfo("\xE8A7"); // OpenInNewWindow icon
Icon = Icons.OpenInNewWindowIcon;
_entry = entry;
}

View File

@@ -101,7 +101,7 @@ internal static class ResultHelper
resultList.Add(new ListItem(new OpenKeyInEditorCommand(registryEntry))
{
Icon = RegistryListPage.RegistryIcon,
Icon = Icons.RegistryIcon,
Subtitle = GetTruncatedText(valueException.Message, MaxTextLength.MaximumSubTitleLengthWithThreeSymbols, TruncateSide.OnlyFromRight),
Title = GetTruncatedText(key.Name, MaxTextLength.MaximumTitleLengthWithThreeSymbols),
MoreCommands = ContextMenuHelper.GetContextMenu(registryEntry).ToArray(),
@@ -130,7 +130,7 @@ internal static class ResultHelper
resultList.Add(new ListItem(new OpenKeyInEditorCommand(registryEntry))
{
Icon = RegistryListPage.RegistryIcon,
Icon = Icons.RegistryIcon,
Subtitle = GetTruncatedText(GetSubTileForRegistryValue(key, valueEntry), MaxTextLength.MaximumSubTitleLengthWithThreeSymbols, TruncateSide.OnlyFromRight),
Title = GetTruncatedText(valueName, MaxTextLength.MaximumTitleLengthWithThreeSymbols),
MoreCommands = ContextMenuHelper.GetContextMenu(registryEntry).ToArray(),
@@ -145,7 +145,7 @@ internal static class ResultHelper
resultList.Add(new ListItem(new OpenKeyInEditorCommand(registryEntry))
{
Icon = RegistryListPage.RegistryIcon,
Icon = Icons.RegistryIcon,
Subtitle = GetTruncatedText(exception.Message, MaxTextLength.MaximumSubTitleLengthWithThreeSymbols, TruncateSide.OnlyFromRight),
Title = GetTruncatedText(key.Name, MaxTextLength.MaximumTitleLengthWithThreeSymbols),
});

View File

@@ -0,0 +1,18 @@
// 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 Microsoft.CommandPalette.Extensions.Toolkit;
namespace Microsoft.CmdPal.Ext.Registry;
internal sealed class Icons
{
internal static IconInfo RegistryIcon { get; } = IconHelpers.FromRelativePath("Assets\\Registry.svg");
internal static IconInfo OpenInNewWindowIcon { get; } = new IconInfo("\xE8A7"); // OpenInNewWindow icon
internal static IconInfo CopyIcon { get; } = new IconInfo("\xE8C8"); // Copy icon
internal static IconInfo CopyToIcon { get; } = new IconInfo("\xF413"); // CopyTo Icon
}

View File

@@ -21,12 +21,12 @@ internal sealed partial class RegistryListPage : DynamicListPage
public RegistryListPage()
{
Icon = IconHelpers.FromRelativePath("Assets\\Registry.svg");
Icon = Icons.RegistryIcon;
Name = Title = Resources.Registry_Page_Title;
Id = "com.microsoft.cmdpal.registry";
_emptyMessage = new CommandItem()
{
Icon = IconHelpers.FromRelativePath("Assets\\Registry.svg"),
Icon = Icons.RegistryIcon,
Title = Resources.Registry_Key_Not_Found,
Subtitle = SearchText,
};

View File

@@ -14,7 +14,7 @@ public partial class RegistryCommandsProvider : CommandProvider
{
Id = "Windows.Registry";
DisplayName = Resources.RegistryProvider_DisplayName;
Icon = IconHelpers.FromRelativePath("Assets\\Registry.svg");
Icon = Icons.RegistryIcon;
}
public override ICommandItem[] TopLevelCommands()