diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/AwakeCommandsFactory.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/AwakeCommandsFactory.cs index 8e9ceaad20..1322ac6a10 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/AwakeCommandsFactory.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/AwakeCommandsFactory.cs @@ -52,6 +52,8 @@ internal static class AwakeCommandsFactory Toast: "Awake timer set for 2 hours"), ]; + private static readonly IconInfo AwakeIcon = PowerToysResourcesHelper.IconFromSettingsIcon("Awake.png"); + internal static void PopulateModuleCommands(List moreCommands) { ArgumentNullException.ThrowIfNull(moreCommands); @@ -76,7 +78,7 @@ internal static class AwakeCommandsFactory { Title = "Current status", Subtitle = statusSubtitle, - Icon = IconHelpers.FromRelativePath("Assets\\Awake.png"), + Icon = AwakeIcon, }; results.Add(statusItem); @@ -94,7 +96,7 @@ internal static class AwakeCommandsFactory { Title = preset.Title, Subtitle = preset.Subtitle, - Icon = IconHelpers.FromRelativePath("Assets\\Awake.png"), + Icon = AwakeIcon, }; results.Add(item); } @@ -119,7 +121,7 @@ internal static class AwakeCommandsFactory { Title = title, Subtitle = subtitle, - Icon = IconHelpers.FromRelativePath("Assets\\Awake.png"), + Icon = AwakeIcon, }; results.Add(item); } @@ -130,7 +132,7 @@ internal static class AwakeCommandsFactory { Title = "Bind Awake to another process", Subtitle = "Stop automatically when the target process exits", - Icon = IconHelpers.FromRelativePath("Assets\\Awake.png"), + Icon = AwakeIcon, }; results.Add(new ListItem(processPageItem) @@ -148,7 +150,7 @@ internal static class AwakeCommandsFactory { Title = "Set Awake to Off", Subtitle = "Switch Awake to passive mode", - Icon = IconHelpers.FromRelativePath("Assets\\Awake.png"), + Icon = AwakeIcon, }; results.Add(stopItem); } @@ -160,7 +162,7 @@ internal static class AwakeCommandsFactory { Title = "Open Awake settings", Subtitle = "Configure Awake inside PowerToys", - Icon = IconHelpers.FromRelativePath("Assets\\Awake.png"), + Icon = AwakeIcon, }; results.Add(settingsItem); } @@ -207,7 +209,7 @@ internal static class AwakeCommandsFactory { Title = title, Subtitle = "Keep the PC awake while this process is running", - Icon = IconHelpers.FromRelativePath("Assets\\Awake.png"), + Icon = AwakeIcon, }; results.Add(item); } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/PowerToysResourcesHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/PowerToysResourcesHelper.cs index 3f0ecf89ca..91dd3f05b1 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/PowerToysResourcesHelper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/PowerToysResourcesHelper.cs @@ -9,48 +9,52 @@ namespace PowerToysExtension.Helpers; internal static class PowerToysResourcesHelper { - public static IconInfo ProviderIcon() => IconHelpers.FromRelativePath("Assets\\PowerToys.png"); + private const string SettingsIconRoot = "WinUI3Apps\\Assets\\Settings\\Icons\\"; + + internal static IconInfo IconFromSettingsIcon(string fileName) => IconHelpers.FromRelativePath($"{SettingsIconRoot}{fileName}"); + + public static IconInfo ProviderIcon() => IconFromSettingsIcon("PowerToys.png"); public static IconInfo ModuleIcon(this SettingsWindow module) { - var iconPath = module switch + var iconFile = module switch { - SettingsWindow.ColorPicker => "Assets\\ColorPicker.png", - SettingsWindow.FancyZones => "Assets\\FancyZones.png", - SettingsWindow.Hosts => "Assets\\Hosts.png", - SettingsWindow.PowerOCR => "Assets\\TextExtractor.png", - SettingsWindow.RegistryPreview => "Assets\\RegistryPreview.png", - SettingsWindow.MeasureTool => "Assets\\ScreenRuler.png", - SettingsWindow.ShortcutGuide => "Assets\\ShortcutGuide.png", - SettingsWindow.CropAndLock => "Assets\\CropAndLock.png", - SettingsWindow.EnvironmentVariables => "Assets\\EnvironmentVariables.png", - SettingsWindow.Awake => "Assets\\Awake.png", - SettingsWindow.PowerRename => "Assets\\PowerRename.png", - SettingsWindow.Run => "Assets\\PowerToysRun.png", - SettingsWindow.ImageResizer => "Assets\\ImageResizer.png", - SettingsWindow.KBM => "Assets\\KeyboardManager.png", - SettingsWindow.MouseUtils => "Assets\\MouseUtils.png", - SettingsWindow.Workspaces => "Assets\\Workspaces.png", - SettingsWindow.AdvancedPaste => "Assets\\AdvancedPaste.png", - SettingsWindow.CmdPal => "Assets\\CmdPal.png", - SettingsWindow.ZoomIt => "Assets\\ZoomIt.png", - SettingsWindow.FileExplorer => "Assets\\FileExplorerPreview.png", - SettingsWindow.FileLocksmith => "Assets\\FileLocksmith.png", - SettingsWindow.NewPlus => "Assets\\NewPlus.png", - SettingsWindow.Peek => "Assets\\Peek.png", - SettingsWindow.LightSwitch => "Assets\\LightSwitch.png", - SettingsWindow.AlwaysOnTop => "Assets\\AlwaysOnTop.png", - SettingsWindow.CmdNotFound => "Assets\\CommandNotFound.png", - SettingsWindow.MouseWithoutBorders => "Assets\\MouseWithoutBorders.png", - SettingsWindow.PowerAccent => "Assets\\QuickAccent.png", - SettingsWindow.PowerLauncher => "Assets\\PowerToysRun.png", - SettingsWindow.PowerPreview => "Assets\\FileExplorerPreview.png", - SettingsWindow.Overview => "Assets\\PowerToys.png", - SettingsWindow.Dashboard => "Assets\\PowerToys.png", - _ => "Assets\\PowerToys.png", + SettingsWindow.ColorPicker => "ColorPicker.png", + SettingsWindow.FancyZones => "FancyZones.png", + SettingsWindow.Hosts => "Hosts.png", + SettingsWindow.PowerOCR => "TextExtractor.png", + SettingsWindow.RegistryPreview => "RegistryPreview.png", + SettingsWindow.MeasureTool => "ScreenRuler.png", + SettingsWindow.ShortcutGuide => "ShortcutGuide.png", + SettingsWindow.CropAndLock => "CropAndLock.png", + SettingsWindow.EnvironmentVariables => "EnvironmentVariables.png", + SettingsWindow.Awake => "Awake.png", + SettingsWindow.PowerRename => "PowerRename.png", + SettingsWindow.Run => "PowerToysRun.png", + SettingsWindow.ImageResizer => "ImageResizer.png", + SettingsWindow.KBM => "KeyboardManager.png", + SettingsWindow.MouseUtils => "MouseUtils.png", + SettingsWindow.Workspaces => "Workspaces.png", + SettingsWindow.AdvancedPaste => "AdvancedPaste.png", + SettingsWindow.CmdPal => "CmdPal.png", + SettingsWindow.ZoomIt => "ZoomIt.png", + SettingsWindow.FileExplorer => "FileExplorerPreview.png", + SettingsWindow.FileLocksmith => "FileLocksmith.png", + SettingsWindow.NewPlus => "NewPlus.png", + SettingsWindow.Peek => "Peek.png", + SettingsWindow.LightSwitch => "LightSwitch.png", + SettingsWindow.AlwaysOnTop => "AlwaysOnTop.png", + SettingsWindow.CmdNotFound => "CommandNotFound.png", + SettingsWindow.MouseWithoutBorders => "MouseWithoutBorders.png", + SettingsWindow.PowerAccent => "QuickAccent.png", + SettingsWindow.PowerLauncher => "PowerToysRun.png", + SettingsWindow.PowerPreview => "FileExplorerPreview.png", + SettingsWindow.Overview => "PowerToys.png", + SettingsWindow.Dashboard => "PowerToys.png", + _ => "PowerToys.png", }; - return IconHelpers.FromRelativePath(iconPath); + return IconFromSettingsIcon(iconFile); } public static string ModuleDisplayName(this SettingsWindow module) diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/AwakeModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/AwakeModuleCommandProvider.cs index ba4e72fb4d..45ce890ee1 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/AwakeModuleCommandProvider.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/AwakeModuleCommandProvider.cs @@ -17,7 +17,7 @@ internal sealed class AwakeModuleCommandProvider : ModuleCommandProvider public override IEnumerable BuildCommands() { var items = new List(); - var icon = IconHelpers.FromRelativePath("Assets\\Awake.png"); + var icon = PowerToysResourcesHelper.IconFromSettingsIcon("Awake.png"); // Settings entry with quick actions in MoreCommands. var settingsTitle = SettingsDeepLink.SettingsWindow.Awake.ModuleDisplayName(); diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/WorkspacesModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/WorkspacesModuleCommandProvider.cs index 28addb1a43..5356244066 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/WorkspacesModuleCommandProvider.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/WorkspacesModuleCommandProvider.cs @@ -21,6 +21,7 @@ internal sealed class WorkspacesModuleCommandProvider : ModuleCommandProvider public override IEnumerable BuildCommands() { var items = new List(); + var icon = PowerToysResourcesHelper.IconFromSettingsIcon("Workspaces.png"); // Settings entry plus common actions. var title = SettingsDeepLink.SettingsWindow.Workspaces.ModuleDisplayName(); @@ -40,7 +41,7 @@ internal sealed class WorkspacesModuleCommandProvider : ModuleCommandProvider { Title = "Workspaces: Open editor", Subtitle = "Create or edit workspaces", - Icon = IconHelpers.FromRelativePath("Assets\\Workspaces.png"), + Icon = icon, }); // Per-workspace entries via the shared service. @@ -55,7 +56,7 @@ internal sealed class WorkspacesModuleCommandProvider : ModuleCommandProvider { Title = workspace.Name, Subtitle = BuildSubtitle(workspace), - Icon = IconHelpers.FromRelativePath("Assets\\Workspaces.png"), + Icon = icon, Details = BuildDetails(workspace), }); } @@ -104,7 +105,7 @@ internal sealed class WorkspacesModuleCommandProvider : ModuleCommandProvider return new Details { - HeroImage = IconHelpers.FromRelativePath("Assets\\Workspaces.png"), + HeroImage = PowerToysResourcesHelper.IconFromSettingsIcon("Workspaces.png"), Title = workspace.Name, Metadata = BuildAppMetadata(workspace), }; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/AwakeProcessListPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/AwakeProcessListPage.cs index 282452e773..e7fb650848 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/AwakeProcessListPage.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/AwakeProcessListPage.cs @@ -14,7 +14,7 @@ internal sealed partial class AwakeProcessListPage : DynamicListPage public AwakeProcessListPage() { - Icon = IconHelpers.FromRelativePath("Assets\\Awake.png"); + Icon = PowerToysResourcesHelper.IconFromSettingsIcon("Awake.png"); Title = "Bind Awake to process"; Name = "AwakeProcessBinding"; Id = "com.microsoft.powertoys.awake.processBinding"; @@ -23,7 +23,7 @@ internal sealed partial class AwakeProcessListPage : DynamicListPage { Title = "No matching processes", Subtitle = "Try another search.", - Icon = IconHelpers.FromRelativePath("Assets\\Awake.png"), + Icon = PowerToysResourcesHelper.IconFromSettingsIcon("Awake.png"), }; EmptyContent = _emptyContent; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/AwakeSessionsPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/AwakeSessionsPage.cs index e04e8a3273..69fd49a4b4 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/AwakeSessionsPage.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/AwakeSessionsPage.cs @@ -14,7 +14,7 @@ internal sealed partial class AwakeSessionsPage : DynamicListPage public AwakeSessionsPage() { - Icon = IconHelpers.FromRelativePath("Assets\\Awake.png"); + Icon = PowerToysResourcesHelper.IconFromSettingsIcon("Awake.png"); Title = "Awake actions"; Name = "AwakeActions"; Id = "com.microsoft.powertoys.awake.actions"; @@ -23,7 +23,7 @@ internal sealed partial class AwakeSessionsPage : DynamicListPage { Title = "No Awake actions", Subtitle = "Try a different search phrase.", - Icon = IconHelpers.FromRelativePath("Assets\\Awake.png"), + Icon = PowerToysResourcesHelper.IconFromSettingsIcon("Awake.png"), }; EmptyContent = _emptyContent; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/ColorPickerSavedColorsPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/ColorPickerSavedColorsPage.cs index 24eb41e2f9..5e06951794 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/ColorPickerSavedColorsPage.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/ColorPickerSavedColorsPage.cs @@ -19,7 +19,7 @@ internal sealed partial class ColorPickerSavedColorsPage : DynamicListPage public ColorPickerSavedColorsPage() { - Icon = IconHelpers.FromRelativePath("Assets\\ColorPicker.png"); + Icon = PowerToysResourcesHelper.IconFromSettingsIcon("ColorPicker.png"); Title = "Saved colors"; Name = "ColorPickerSavedColors"; Id = "com.microsoft.powertoys.colorpicker.savedColors"; @@ -28,7 +28,7 @@ internal sealed partial class ColorPickerSavedColorsPage : DynamicListPage { Title = "No saved colors", Subtitle = "Pick a color first, then try again.", - Icon = IconHelpers.FromRelativePath("Assets\\ColorPicker.png"), + Icon = PowerToysResourcesHelper.IconFromSettingsIcon("ColorPicker.png"), }; EmptyContent = _emptyContent; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/PowerToysExtensionPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/PowerToysExtensionPage.cs index 4dad6534bf..0d81573280 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/PowerToysExtensionPage.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/PowerToysExtensionPage.cs @@ -13,7 +13,7 @@ internal sealed partial class PowerToysExtensionPage : ListPage { public PowerToysExtensionPage() { - Icon = IconHelpers.FromRelativePath("Assets\\PowerToys.png"); + Icon = Helpers.PowerToysResourcesHelper.IconFromSettingsIcon("PowerToys.png"); Title = "PowerToys"; Name = "PowerToys commands"; } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/PowerToysListPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/PowerToysListPage.cs index ddf6616216..ba6ff87389 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/PowerToysListPage.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/PowerToysListPage.cs @@ -14,12 +14,12 @@ internal sealed partial class PowerToysListPage : DynamicListPage public PowerToysListPage() { - Icon = IconHelpers.FromRelativePath("Assets\\PowerToys.png"); + Icon = PowerToysResourcesHelper.IconFromSettingsIcon("PowerToys.png"); Name = Title = "PowerToys"; Id = "com.microsoft.cmdpal.powertoys"; _empty = new CommandItem() { - Icon = IconHelpers.FromRelativePath("Assets\\PowerToys.png"), + Icon = PowerToysResourcesHelper.IconFromSettingsIcon("PowerToys.png"), Title = "No matching module found", Subtitle = SearchText, }; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/WorkspacesListPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/WorkspacesListPage.cs index fab4f4f897..677114c6ca 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/WorkspacesListPage.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Pages/WorkspacesListPage.cs @@ -5,6 +5,7 @@ using System.Linq; using Microsoft.CommandPalette.Extensions; using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Helpers; using PowerToysExtension.Modules; namespace PowerToysExtension.Pages; @@ -15,12 +16,12 @@ internal sealed partial class WorkspacesListPage : DynamicListPage public WorkspacesListPage() { - Icon = IconHelpers.FromRelativePath("Assets\\Workspaces.png"); + Icon = PowerToysResourcesHelper.IconFromSettingsIcon("Workspaces.png"); Name = Title = "Workspaces"; Id = "com.microsoft.cmdpal.powertoys.workspaces"; _emptyMessage = new CommandItem() { - Icon = IconHelpers.FromRelativePath("Assets\\Workspaces.png"), + Icon = PowerToysResourcesHelper.IconFromSettingsIcon("Workspaces.png"), Title = "No workspaces found", Subtitle = SearchText, }; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/PowerToysCommandsProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/PowerToysCommandsProvider.cs index 074d4d3afd..40993e7063 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/PowerToysCommandsProvider.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/PowerToysCommandsProvider.cs @@ -15,7 +15,7 @@ public sealed partial class PowerToysCommandsProvider : CommandProvider public PowerToysCommandsProvider() { DisplayName = "PowerToys"; - Icon = IconHelpers.FromRelativePath("Assets\\PowerToys.png"); + Icon = PowerToysResourcesHelper.IconFromSettingsIcon("PowerToys.png"); } public override ICommandItem[] TopLevelCommands() => diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/PowerToysExtensionCommandsProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/PowerToysExtensionCommandsProvider.cs index badfbcd55c..a7b6077e56 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/PowerToysExtensionCommandsProvider.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/PowerToysExtensionCommandsProvider.cs @@ -16,7 +16,7 @@ public partial class PowerToysExtensionCommandsProvider : CommandProvider public PowerToysExtensionCommandsProvider() { DisplayName = "PowerToys"; - Icon = IconHelpers.FromRelativePath("Assets\\PowerToys.png"); + Icon = PowerToysResourcesHelper.IconFromSettingsIcon("PowerToys.png"); _commands = [ new CommandItem(new Pages.PowerToysListPage()) {