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

@@ -26,17 +26,17 @@ internal sealed partial class ExecuteItem : InvokableCommand
if (type == RunAsType.Administrator)
{
Name = Properties.Resources.cmd_run_as_administrator;
Icon = new IconInfo("\xE7EF"); // Admin Icon
Icon = Icons.AdminIcon;
}
else if (type == RunAsType.OtherUser)
{
Name = Properties.Resources.cmd_run_as_user;
Icon = new IconInfo("\xE7EE"); // User Icon
Icon = Icons.UserIcon;
}
else
{
Name = Properties.Resources.generic_run_command;
Icon = new IconInfo("\uE751"); // Return Key Icon
Icon = Icons.ReturnIcon;
}
Cmd = cmd;

View File

@@ -24,7 +24,7 @@ internal sealed partial class FallbackExecuteItem : FallbackCommandItem
Title = string.Empty;
_executeItem.Name = string.Empty;
Subtitle = Properties.Resources.generic_run_command;
Icon = Icons.RunV2; // Defined in Icons.cs and contains the execute command icon.
Icon = Icons.RunV2Icon; // Defined in Icons.cs and contains the execute command icon.
}
public override void UpdateQuery(string query)

View File

@@ -55,7 +55,7 @@ public class ShellListPageHelpers
// Using CurrentCulture since this is user facing
Subtitle = Properties.Resources.cmd_plugin_name + ": " + string.Format(CultureInfo.CurrentCulture, CmdHasBeenExecutedTimes, m.Value),
Icon = new IconInfo("\uE81C"),
Icon = Icons.HistoryIcon,
};
return ret;
}).Where(o => o != null).Take(4);
@@ -108,7 +108,7 @@ public class ShellListPageHelpers
// Using CurrentCulture since this is user facing
Subtitle = Properties.Resources.cmd_plugin_name + ": " + string.Format(CultureInfo.CurrentCulture, CmdHasBeenExecutedTimes, m.Value),
Icon = new IconInfo("\uE81C"),
Icon = Icons.HistoryIcon,
}).Take(5);
return history.ToList();

View File

@@ -8,5 +8,13 @@ namespace Microsoft.CmdPal.Ext.Shell;
internal sealed class Icons
{
internal static IconInfo RunV2 { get; } = IconHelpers.FromRelativePath("Assets\\Run.svg");
internal static IconInfo RunV2Icon { get; } = IconHelpers.FromRelativePath("Assets\\Run.svg");
internal static IconInfo HistoryIcon { get; } = new IconInfo("\uE81C"); // History
internal static IconInfo AdminIcon { get; } = new IconInfo("\xE7EF"); // Admin Icon
internal static IconInfo UserIcon { get; } = new IconInfo("\xE7EE"); // User Icon
internal static IconInfo ReturnIcon { get; } = new IconInfo("\uE751"); // Return Key Icon
}

View File

@@ -15,7 +15,7 @@ internal sealed partial class ShellListPage : DynamicListPage
public ShellListPage(SettingsManager settingsManager)
{
Icon = Icons.RunV2;
Icon = Icons.RunV2Icon;
Id = "com.microsoft.cmdpal.shell";
Name = Resources.cmd_plugin_name;
PlaceholderText = Resources.list_placeholder_text;

View File

@@ -20,14 +20,14 @@ public partial class ShellCommandsProvider : CommandProvider
{
Id = "Run";
DisplayName = Resources.cmd_plugin_name;
Icon = Icons.RunV2;
Icon = Icons.RunV2Icon;
Settings = _settingsManager.Settings;
_fallbackItem = new FallbackExecuteItem(_settingsManager);
_shellPageItem = new CommandItem(new ShellListPage(_settingsManager))
{
Icon = Icons.RunV2,
Icon = Icons.RunV2Icon,
Title = Resources.shell_command_name,
Subtitle = Resources.cmd_plugin_description,
MoreCommands = [