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

@@ -0,0 +1,24 @@
// 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.WinGet;
internal sealed class Icons
{
internal static IconInfo WinGetIcon { get; } = IconHelpers.FromRelativePath("Assets\\WinGet.svg");
internal static IconInfo ExtensionsIcon { get; } = IconHelpers.FromRelativePath("Assets\\Extension.svg");
internal static IconInfo StoreIcon { get; } = IconHelpers.FromRelativePaths("Assets\\Store.light.svg", "Assets\\Store.dark.svg");
internal static IconInfo CompletedIcon { get; } = new("\uE930"); // Completed
internal static IconInfo UpdateIcon { get; } = new("\uE74A"); // Up
internal static IconInfo DownloadIcon { get; } = new("\uE896"); // Download
internal static IconInfo DeleteIcon { get; } = new("\uE74D"); // Delete
}

View File

@@ -24,14 +24,6 @@ public partial class InstallPackageCommand : InvokableCommand
public PackageInstallCommandState InstallCommandState { get; private set; }
public static IconInfo CompletedIcon { get; } = new("\uE930"); // Completed
public static IconInfo UpdateIcon { get; } = new("\uE74A"); // Up
public static IconInfo DownloadIcon { get; } = new("\uE896"); // Download
public static IconInfo DeleteIcon { get; } = new("\uE74D"); // Delete
public event EventHandler<InstallPackageCommand>? InstallStateChanged;
private static readonly CompositeFormat UninstallingPackage = System.Text.CompositeFormat.Parse(Properties.Resources.winget_uninstalling_package);
@@ -69,9 +61,9 @@ public partial class InstallPackageCommand : InvokableCommand
{
Icon = InstallCommandState switch
{
PackageInstallCommandState.Install => DownloadIcon,
PackageInstallCommandState.Update => UpdateIcon,
PackageInstallCommandState.Uninstall => CompletedIcon,
PackageInstallCommandState.Install => Icons.DownloadIcon,
PackageInstallCommandState.Update => Icons.UpdateIcon,
PackageInstallCommandState.Uninstall => Icons.CompletedIcon,
_ => throw new NotImplementedException(),
};
Name = InstallCommandState switch

View File

@@ -190,7 +190,7 @@ public partial class InstallPackageListItem : ListItem
CommandContextItem uninstallContextItem = new(installCommand)
{
IsCritical = true,
Icon = InstallPackageCommand.DeleteIcon,
Icon = Icons.DeleteIcon,
};
if (WinGetStatics.AppSearchCallback != null)

View File

@@ -34,17 +34,13 @@ internal sealed partial class WinGetExtensionPage : DynamicListPage, IDisposable
private IEnumerable<CatalogPackage>? _results;
public static IconInfo WinGetIcon { get; } = IconHelpers.FromRelativePath("Assets\\WinGet.svg");
public static IconInfo ExtensionsIcon { get; } = IconHelpers.FromRelativePath("Assets\\Extension.svg");
public static string ExtensionsTag => "windows-commandpalette-extension";
private readonly StatusMessage _errorMessage = new() { State = MessageState.Error };
public WinGetExtensionPage(string tag = "")
{
Icon = tag == ExtensionsTag ? ExtensionsIcon : WinGetIcon;
Icon = tag == ExtensionsTag ? Icons.ExtensionsIcon : Icons.WinGetIcon;
Name = Properties.Resources.winget_page_name;
_tag = tag;
ShowDetails = true;
@@ -78,7 +74,7 @@ internal sealed partial class WinGetExtensionPage : DynamicListPage, IDisposable
EmptyContent = new CommandItem(new NoOpCommand())
{
Icon = WinGetIcon,
Icon = Icons.WinGetIcon,
Title = (string.IsNullOrEmpty(SearchText) && !HasTag) ?
Properties.Resources.winget_placeholder_text :
Properties.Resources.winget_no_packages_found,
@@ -189,7 +185,7 @@ internal sealed partial class WinGetExtensionPage : DynamicListPage, IDisposable
return [];
}
string searchDebugText = $"{query}{(HasTag ? "+" : string.Empty)}{_tag}";
var searchDebugText = $"{query}{(HasTag ? "+" : string.Empty)}{_tag}";
Logger.LogDebug($"Starting search for '{searchDebugText}'");
HashSet<CatalogPackage> results = new(new PackageIdCompare());

View File

@@ -15,7 +15,7 @@ public partial class WinGetExtensionCommandsProvider : CommandProvider
{
DisplayName = Properties.Resources.winget_display_name;
Id = "WinGet";
Icon = WinGetExtensionPage.WinGetIcon;
Icon = Icons.WinGetIcon;
_ = WinGetStatics.Manager;
}
@@ -34,7 +34,7 @@ public partial class WinGetExtensionCommandsProvider : CommandProvider
new OpenUrlCommand("ms-windows-store://assoc/?Tags=AppExtension-com.microsoft.commandpalette"))
{
Title = Properties.Resources.winget_search_store_title,
Icon = IconHelpers.FromRelativePaths("Assets\\Store.light.svg", "Assets\\Store.dark.svg"),
Icon = Icons.StoreIcon,
},
];