diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt
index 0aac81d407..7e4a24841b 100644
--- a/.github/actions/spell-check/expect.txt
+++ b/.github/actions/spell-check/expect.txt
@@ -218,6 +218,7 @@ coclass
CODENAME
codereview
Codespaces
+Coen
COINIT
colid
colorconv
@@ -1383,6 +1384,7 @@ RIGHTSCROLLBAR
riid
RKey
RNumber
+Rns
rop
ROUNDSMALL
ROWSETEXT
diff --git a/.pipelines/v2/release.yml b/.pipelines/v2/release.yml
index 227dd1cf71..18163e899a 100644
--- a/.pipelines/v2/release.yml
+++ b/.pipelines/v2/release.yml
@@ -38,6 +38,11 @@ parameters:
displayName: "Build Using Visual Studio Preview"
default: false
+ - name: enableAOT
+ type: boolean
+ displayName: "Enable AOT (Ahead-of-Time) Compilation for CmdPal"
+ default: true
+
name: $(BuildDefinitionName)_$(date:yyMM).$(date:dd)$(rev:rrr)
variables:
@@ -95,7 +100,7 @@ extends:
useManagedIdentity: $(SigningUseManagedIdentity)
clientId: $(SigningOriginalClientId)
# Have msbuild use the release nuget config profile
- additionalBuildOptions: /p:RestoreConfigFile="$(Build.SourcesDirectory)\.pipelines\release-nuget.config"
+ additionalBuildOptions: /p:RestoreConfigFile="$(Build.SourcesDirectory)\.pipelines\release-nuget.config" /p:EnableCmdPalAOT=${{ parameters.enableAOT }}
beforeBuildSteps:
# Sets versions for all PowerToy created DLLs
- pwsh: |-
diff --git a/.pipelines/verifyDepsJsonLibraryVersions.ps1 b/.pipelines/verifyDepsJsonLibraryVersions.ps1
index 085e1e439a..6123316b5f 100644
--- a/.pipelines/verifyDepsJsonLibraryVersions.ps1
+++ b/.pipelines/verifyDepsJsonLibraryVersions.ps1
@@ -19,7 +19,7 @@ Get-ChildItem $targetDir -Recurse -Filter *.deps.json -Exclude *UITest*,MouseJum
# Temporarily exclude All UI-Test, Fuzzer-Test projects because of Appium.WebDriver dependencies
$depsJsonFullFileName = $_.FullName
- if ($depsJsonFullFileName -like "*CmdPal*") {
+ if ($depsJsonFullFileName -like "*CmdPal*" -or $depsJsonFullFileName -like "*CommandPalette*") {
return
}
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 5ebced2715..23575616fe 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -9,6 +9,7 @@
+
@@ -21,6 +22,7 @@
+
diff --git a/NOTICE.md b/NOTICE.md
index 2b1201bc50..4dcc82579d 100644
--- a/NOTICE.md
+++ b/NOTICE.md
@@ -1496,7 +1496,9 @@ SOFTWARE.
- AdaptiveCards.Templating 2.0.5
- Appium.WebDriver 4.4.5
- Azure.AI.OpenAI 1.0.0-beta.17
+- CoenM.ImageSharp.ImageHash 1.3.6
- CommunityToolkit.Common 8.4.0
+- CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock 0.1.250703-build.2173
- CommunityToolkit.Mvvm 8.4.0
- CommunityToolkit.WinUI.Animations 8.2.250402
- CommunityToolkit.WinUI.Collections 8.2.250402
@@ -1579,4 +1581,3 @@ SOFTWARE.
- WinUIEx 2.2.0
- WPF-UI 3.0.5
- WyHash 1.0.5
-
diff --git a/PowerToys.sln b/PowerToys.sln
index 26b254bc69..f65feb8c6b 100644
--- a/PowerToys.sln
+++ b/PowerToys.sln
@@ -737,6 +737,9 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerRenameUITest", "src\modules\powerrename\PowerRenameUITest\PowerRenameUITest.csproj", "{9D3F3793-EFE3-4525-8782-238015DABA62}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Peek.UITests", "src\modules\peek\Peek.UITests\Peek.UITests.csproj", "{BCDC7246-F4F8-4EED-8DE6-037AA2E7C6D1}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CmdPal.Core.ViewModels", "src\modules\cmdpal\Microsoft.CmdPal.Core.ViewModels\Microsoft.CmdPal.Core.ViewModels.csproj", "{24133F7F-C1D1-DE04-EFA8-F5D5467FE027}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -2720,6 +2723,14 @@ Global
{14AFD976-B4D2-49D0-9E6C-AA93CC061B8A}.Release|ARM64.Build.0 = Release|ARM64
{14AFD976-B4D2-49D0-9E6C-AA93CC061B8A}.Release|x64.ActiveCfg = Release|x64
{14AFD976-B4D2-49D0-9E6C-AA93CC061B8A}.Release|x64.Build.0 = Release|x64
+ {24133F7F-C1D1-DE04-EFA8-F5D5467FE027}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {24133F7F-C1D1-DE04-EFA8-F5D5467FE027}.Debug|ARM64.Build.0 = Debug|ARM64
+ {24133F7F-C1D1-DE04-EFA8-F5D5467FE027}.Debug|x64.ActiveCfg = Debug|x64
+ {24133F7F-C1D1-DE04-EFA8-F5D5467FE027}.Debug|x64.Build.0 = Debug|x64
+ {24133F7F-C1D1-DE04-EFA8-F5D5467FE027}.Release|ARM64.ActiveCfg = Release|ARM64
+ {24133F7F-C1D1-DE04-EFA8-F5D5467FE027}.Release|ARM64.Build.0 = Release|ARM64
+ {24133F7F-C1D1-DE04-EFA8-F5D5467FE027}.Release|x64.ActiveCfg = Release|x64
+ {24133F7F-C1D1-DE04-EFA8-F5D5467FE027}.Release|x64.Build.0 = Release|x64
{9D3F3793-EFE3-4525-8782-238015DABA62}.Debug|ARM64.ActiveCfg = Debug|ARM64
{9D3F3793-EFE3-4525-8782-238015DABA62}.Debug|ARM64.Build.0 = Debug|ARM64
{9D3F3793-EFE3-4525-8782-238015DABA62}.Debug|x64.ActiveCfg = Debug|x64
@@ -3020,6 +3031,8 @@ Global
{43E779F3-D83C-48B1-BA8D-1912DBD76FC9} = {A2221D7E-55E7-4BEA-90D1-4F162D670BBF}
{2CF78CF7-8FEB-4BE1-9591-55FA25B48FC6} = {1AFB6476-670D-4E80-A464-657E01DFF482}
{14AFD976-B4D2-49D0-9E6C-AA93CC061B8A} = {1AFB6476-670D-4E80-A464-657E01DFF482}
+ {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {3846508C-77EB-4034-A702-F8BB263C4F79}
+ {24133F7F-C1D1-DE04-EFA8-F5D5467FE027} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{9D3F3793-EFE3-4525-8782-238015DABA62} = {89E20BCE-EB9C-46C8-8B50-E01A82E6FDC3}
{BCDC7246-F4F8-4EED-8DE6-037AA2E7C6D1} = {17B4FA70-001E-4D33-BBBB-0D142DBC2E20}
EndGlobalSection
diff --git a/nuget.config b/nuget.config
index e6a17ffdfe..51f9b3b3f7 100644
--- a/nuget.config
+++ b/nuget.config
@@ -2,10 +2,10 @@
-
+
-
+
diff --git a/src/Common.Dotnet.AotCompatibility.props b/src/Common.Dotnet.AotCompatibility.props
index 82988104dd..bebb88428c 100644
--- a/src/Common.Dotnet.AotCompatibility.props
+++ b/src/Common.Dotnet.AotCompatibility.props
@@ -7,6 +7,7 @@
2
- IL2081;CsWinRT1028;$(WarningsNotAsErrors)
+
+ IL2081;CsWinRT1028;CA1416;$(WarningsNotAsErrors)
diff --git a/src/common/UITestAutomation/UITestAutomation.csproj b/src/common/UITestAutomation/UITestAutomation.csproj
index fc9da3b983..17841e0a60 100644
--- a/src/common/UITestAutomation/UITestAutomation.csproj
+++ b/src/common/UITestAutomation/UITestAutomation.csproj
@@ -20,6 +20,7 @@
+
diff --git a/src/common/UITestAutomation/VisualAssert.cs b/src/common/UITestAutomation/VisualAssert.cs
index 692090440a..844db5b027 100644
--- a/src/common/UITestAutomation/VisualAssert.cs
+++ b/src/common/UITestAutomation/VisualAssert.cs
@@ -6,7 +6,11 @@ using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.IO;
+using CoenM.ImageHash;
+using CoenM.ImageHash.HashAlgorithms;
using Microsoft.VisualStudio.TestTools.UnitTesting;
+using SixLabors.ImageSharp;
+using SixLabors.ImageSharp.PixelFormats;
namespace Microsoft.PowerToys.UITest
{
@@ -127,34 +131,75 @@ namespace Microsoft.PowerToys.UITest
}
///
- /// Test if two images are equal bit-by-bit
+ /// Test if two images are equal using ImageHash comparison
///
/// baseline image
/// test image
/// true if are equal,otherwise false
private static bool AreEqual(Bitmap baselineImage, Bitmap testImage)
{
- if (baselineImage.Width != testImage.Width || baselineImage.Height != testImage.Height)
+ try
{
- return false;
+ // Define a threshold for similarity percentage
+ const int SimilarityThreshold = 95;
+
+ // Use CoenM.ImageHash for perceptual hash comparison
+ var hashAlgorithm = new AverageHash();
+
+ // Convert System.Drawing.Bitmap to SixLabors.ImageSharp.Image
+ using var baselineImageSharp = ConvertBitmapToImageSharp(baselineImage);
+ using var testImageSharp = ConvertBitmapToImageSharp(testImage);
+
+ // Calculate hashes for both images
+ var baselineHash = hashAlgorithm.Hash(baselineImageSharp);
+ var testHash = hashAlgorithm.Hash(testImageSharp);
+
+ // Compare hashes using CompareHash method
+ // Returns similarity percentage (0-100, where 100 is identical)
+ var similarity = CompareHash.Similarity(baselineHash, testHash);
+
+ // Consider images equal if similarity is very high
+ // Allow for minor rendering differences (threshold can be adjusted)
+ return similarity >= SimilarityThreshold; // 95% similarity threshold
}
-
- // WinAppDriver sometimes adds a border to the screenshot (around 2 pix width), and it is not always consistent.
- // So we exclude the border when comparing the images, and usually it is the edge of the windows, won't affect the comparison.
- int excludeBorderWidth = 5, excludeBorderHeight = 5;
-
- for (int x = excludeBorderWidth; x < baselineImage.Width - excludeBorderWidth; x++)
+ catch
{
- for (int y = excludeBorderHeight; y < baselineImage.Height - excludeBorderHeight; y++)
+ // Fallback to pixel-by-pixel comparison if hash comparison fails
+ if (baselineImage.Width != testImage.Width || baselineImage.Height != testImage.Height)
{
- if (!VisualHelper.PixIsSame(baselineImage.GetPixel(x, y), testImage.GetPixel(x, y)))
+ return false;
+ }
+
+ // WinAppDriver sometimes adds a border to the screenshot (around 2 pix width), and it is not always consistent.
+ // So we exclude the border when comparing the images, and usually it is the edge of the windows, won't affect the comparison.
+ int excludeBorderWidth = 5, excludeBorderHeight = 5;
+
+ for (int x = excludeBorderWidth; x < baselineImage.Width - excludeBorderWidth; x++)
+ {
+ for (int y = excludeBorderHeight; y < baselineImage.Height - excludeBorderHeight; y++)
{
- return false;
+ if (!VisualHelper.PixIsSame(baselineImage.GetPixel(x, y), testImage.GetPixel(x, y)))
+ {
+ return false;
+ }
}
}
- }
- return true;
+ return true;
+ }
+ }
+
+ ///
+ /// Convert System.Drawing.Bitmap to SixLabors.ImageSharp.Image
+ ///
+ /// The bitmap to convert
+ /// ImageSharp Image
+ private static Image ConvertBitmapToImageSharp(Bitmap bitmap)
+ {
+ using var memoryStream = new MemoryStream();
+ bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);
+ memoryStream.Position = 0;
+ return SixLabors.ImageSharp.Image.Load(memoryStream);
}
}
}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/AppExtensionHost.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/AppExtensionHost.cs
new file mode 100644
index 0000000000..3a828a3e5d
--- /dev/null
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/AppExtensionHost.cs
@@ -0,0 +1,168 @@
+// 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.ObjectModel;
+using System.Diagnostics;
+using ManagedCommon;
+using Microsoft.CommandPalette.Extensions;
+using Microsoft.CommandPalette.Extensions.Toolkit;
+using Windows.Foundation;
+
+namespace Microsoft.CmdPal.Core.ViewModels;
+
+public abstract partial class AppExtensionHost : IExtensionHost
+{
+ private static readonly GlobalLogPageContext _globalLogPageContext = new();
+
+ private static ulong _hostingHwnd;
+
+ public static ObservableCollection LogMessages { get; } = [];
+
+ public ulong HostingHwnd => _hostingHwnd;
+
+ public string LanguageOverride => string.Empty;
+
+ public ObservableCollection StatusMessages { get; } = [];
+
+ public static void SetHostHwnd(ulong hostHwnd) => _hostingHwnd = hostHwnd;
+
+ public void DebugLog(string message)
+ {
+#if DEBUG
+ this.ProcessLogMessage(new LogMessage(message));
+#endif
+ }
+
+ public IAsyncAction HideStatus(IStatusMessage? message)
+ {
+ if (message == null)
+ {
+ return Task.CompletedTask.AsAsyncAction();
+ }
+
+ _ = Task.Run(() =>
+ {
+ ProcessHideStatusMessage(message);
+ });
+ return Task.CompletedTask.AsAsyncAction();
+ }
+
+ public void Log(string message)
+ {
+ this.ProcessLogMessage(new LogMessage(message));
+ }
+
+ public IAsyncAction LogMessage(ILogMessage? message)
+ {
+ if (message == null)
+ {
+ return Task.CompletedTask.AsAsyncAction();
+ }
+
+ Logger.LogDebug(message.Message);
+
+ _ = Task.Run(() =>
+ {
+ ProcessLogMessage(message);
+ });
+
+ // We can't just make a LogMessageViewModel : ExtensionObjectViewModel
+ // because we don't necessarily know the page context. Butts.
+ return Task.CompletedTask.AsAsyncAction();
+ }
+
+ public void ProcessHideStatusMessage(IStatusMessage message)
+ {
+ Task.Factory.StartNew(
+ () =>
+ {
+ try
+ {
+ var vm = StatusMessages.Where(messageVM => messageVM.Model.Unsafe == message).FirstOrDefault();
+ if (vm != null)
+ {
+ StatusMessages.Remove(vm);
+ }
+ }
+ catch
+ {
+ }
+ },
+ CancellationToken.None,
+ TaskCreationOptions.None,
+ _globalLogPageContext.Scheduler);
+ }
+
+ public void ProcessLogMessage(ILogMessage message)
+ {
+ var vm = new LogMessageViewModel(message, _globalLogPageContext);
+ vm.SafeInitializePropertiesSynchronous();
+
+ Task.Factory.StartNew(
+ () =>
+ {
+ LogMessages.Add(vm);
+ },
+ CancellationToken.None,
+ TaskCreationOptions.None,
+ _globalLogPageContext.Scheduler);
+ }
+
+ public void ProcessStatusMessage(IStatusMessage message, StatusContext context)
+ {
+ // If this message is already in the list of messages, just bring it to the top
+ var oldVm = StatusMessages.Where(messageVM => messageVM.Model.Unsafe == message).FirstOrDefault();
+ if (oldVm != null)
+ {
+ Task.Factory.StartNew(
+ () =>
+ {
+ StatusMessages.Remove(oldVm);
+ StatusMessages.Add(oldVm);
+ },
+ CancellationToken.None,
+ TaskCreationOptions.None,
+ _globalLogPageContext.Scheduler);
+ return;
+ }
+
+ var vm = new StatusMessageViewModel(message, new(_globalLogPageContext));
+ vm.SafeInitializePropertiesSynchronous();
+
+ Task.Factory.StartNew(
+ () =>
+ {
+ StatusMessages.Add(vm);
+ },
+ CancellationToken.None,
+ TaskCreationOptions.None,
+ _globalLogPageContext.Scheduler);
+ }
+
+ public IAsyncAction ShowStatus(IStatusMessage? message, StatusContext context)
+ {
+ if (message == null)
+ {
+ return Task.CompletedTask.AsAsyncAction();
+ }
+
+ Debug.WriteLine(message.Message);
+
+ _ = Task.Run(() =>
+ {
+ ProcessStatusMessage(message, context);
+ });
+
+ return Task.CompletedTask.AsAsyncAction();
+ }
+
+ public abstract string? GetExtensionDisplayName();
+}
+
+public interface IAppHostService
+{
+ AppExtensionHost GetDefaultHost();
+
+ AppExtensionHost GetHostForCommand(object? context, AppExtensionHost? currentHost);
+}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandBarViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/CommandBarViewModel.cs
similarity index 95%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandBarViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/CommandBarViewModel.cs
index e0112acaff..f506c127f2 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandBarViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/CommandBarViewModel.cs
@@ -1,15 +1,15 @@
-// Copyright (c) Microsoft Corporation
+// 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.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
using Microsoft.CommandPalette.Extensions.Toolkit;
using Windows.System;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class CommandBarViewModel : ObservableObject,
IRecipient
@@ -149,6 +149,7 @@ public partial class CommandBarViewModel : ObservableObject,
if (command.HasMoreCommands)
{
+ WeakReferenceMessenger.Default.Send(new(command.Command.Model, command.Model));
return ContextKeybindingResult.KeepOpen;
}
else
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandContextItemViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/CommandContextItemViewModel.cs
similarity index 87%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandContextItemViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/CommandContextItemViewModel.cs
index f1c35b1f50..60fc815a52 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandContextItemViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/CommandContextItemViewModel.cs
@@ -1,13 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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 CommunityToolkit.Mvvm.Messaging;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
-using Microsoft.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class CommandContextItemViewModel(ICommandContextItem contextItem, WeakReference context) : CommandItemViewModel(new(contextItem), context), IContextItemViewModel
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandItemViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/CommandItemViewModel.cs
similarity index 98%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandItemViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/CommandItemViewModel.cs
index 0602abeea2..75a8eb9a56 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandItemViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/CommandItemViewModel.cs
@@ -1,13 +1,13 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Messages;
-using Microsoft.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class CommandItemViewModel : ExtensionObjectViewModel, ICommandBarContext
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/CommandViewModel.cs
similarity index 96%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/CommandViewModel.cs
index c1d3c4e6f9..6e48cef382 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/CommandViewModel.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class CommandViewModel : ExtensionObjectViewModel
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ConfirmResultViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ConfirmResultViewModel.cs
similarity index 91%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ConfirmResultViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ConfirmResultViewModel.cs
index 53466cb1ce..45cd18f4dd 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ConfirmResultViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ConfirmResultViewModel.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class ConfirmResultViewModel(IConfirmationArgs _args, WeakReference context) :
ExtensionObjectViewModel(context)
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentPageViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ContentPageViewModel.cs
similarity index 91%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentPageViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ContentPageViewModel.cs
index 0d37a81112..16611a31ac 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentPageViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ContentPageViewModel.cs
@@ -7,12 +7,12 @@ using System.Diagnostics.CodeAnalysis;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
-using Microsoft.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class ContentPageViewModel : PageViewModel, ICommandBarContext
{
@@ -47,7 +47,7 @@ public partial class ContentPageViewModel : PageViewModel, ICommandBarContext
// Remember - "observable" properties from the model (via PropChanged)
// cannot be marked [ObservableProperty]
- public ContentPageViewModel(IContentPage model, TaskScheduler scheduler, CommandPaletteHost host)
+ public ContentPageViewModel(IContentPage model, TaskScheduler scheduler, AppExtensionHost host)
: base(model, scheduler, host)
{
_model = new(model);
@@ -91,16 +91,12 @@ public partial class ContentPageViewModel : PageViewModel, ICommandBarContext
});
}
- public static ContentViewModel? ViewModelFromContent(IContent content, WeakReference context)
+ public virtual ContentViewModel? ViewModelFromContent(IContent content, WeakReference context)
{
- ContentViewModel? viewModel = content switch
- {
- IFormContent form => new ContentFormViewModel(form, context),
- IMarkdownContent markdown => new ContentMarkdownViewModel(markdown, context),
- ITreeContent tree => new ContentTreeViewModel(tree, context),
- _ => null,
- };
- return viewModel;
+ // The core ContentPageViewModel doesn't actually handle any content,
+ // so we just return null here.
+ // The real content is handled by the derived class CommandPaletteContentPageViewModel
+ return null;
}
public override void InitializeProperties()
@@ -115,15 +111,15 @@ public partial class ContentPageViewModel : PageViewModel, ICommandBarContext
Commands = model.Commands
.ToList()
- .Select(item =>
+ .Select(item =>
{
if (item is CommandContextItem contextItem)
{
- return new CommandContextItemViewModel(contextItem, PageContext) as IContextItemViewModel;
+ return new CommandContextItemViewModel(contextItem, PageContext);
}
else
{
- return new SeparatorContextItemViewModel() as IContextItemViewModel;
+ return new SeparatorContextItemViewModel();
}
})
.ToList();
@@ -182,7 +178,7 @@ public partial class ContentPageViewModel : PageViewModel, ICommandBarContext
}
else
{
- return new SeparatorContextItemViewModel() as IContextItemViewModel;
+ return new SeparatorContextItemViewModel();
}
})
.ToList();
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ContentViewModel.cs
similarity index 79%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ContentViewModel.cs
index 21d2d6748f..42a2e5c6d9 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ContentViewModel.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public abstract partial class ContentViewModel(WeakReference context) :
ExtensionObjectViewModel(context)
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContextMenuViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ContextMenuViewModel.cs
similarity index 87%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContextMenuViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ContextMenuViewModel.cs
index ed95768865..bcc414859a 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContextMenuViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ContextMenuViewModel.cs
@@ -5,13 +5,13 @@
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
using Microsoft.Diagnostics.Utilities;
using Windows.System;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class ContextMenuViewModel : ObservableObject,
IRecipient,
@@ -22,15 +22,8 @@ public partial class ContextMenuViewModel : ObservableObject,
get => field;
set
{
- if (field != null)
- {
- field.PropertyChanged -= SelectedItemPropertyChanged;
- }
-
field = value;
- SetSelectedItem(value);
-
- OnPropertyChanged(nameof(SelectedItem));
+ UpdateContextItems();
}
}
@@ -68,33 +61,6 @@ public partial class ContextMenuViewModel : ObservableObject,
OnPropertyChanged(nameof(FilterOnTop));
}
- private void SetSelectedItem(ICommandBarContext? value)
- {
- if (value != null)
- {
- value.PropertyChanged += SelectedItemPropertyChanged;
- }
- else
- {
- if (SelectedItem != null)
- {
- SelectedItem.PropertyChanged -= SelectedItemPropertyChanged;
- }
- }
-
- UpdateContextItems();
- }
-
- private void SelectedItemPropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
- {
- switch (e.PropertyName)
- {
- case nameof(SelectedItem.HasMoreCommands):
- UpdateContextItems();
- break;
- }
- }
-
public void UpdateContextItems()
{
if (SelectedItem != null)
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsCommandsViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsCommandsViewModel.cs
similarity index 90%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsCommandsViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsCommandsViewModel.cs
index 316209a296..b85aeaba81 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsCommandsViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsCommandsViewModel.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class DetailsCommandsViewModel(
IDetailsElement _detailsElement,
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsDataViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsDataViewModel.cs
similarity index 69%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsDataViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsDataViewModel.cs
index 30084f7c7a..9165dde656 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsDataViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsDataViewModel.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public abstract partial class DetailsDataViewModel(IPageContext context) : ExtensionObjectViewModel(context)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsElementViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsElementViewModel.cs
similarity index 85%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsElementViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsElementViewModel.cs
index e836dbf180..390459f26c 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsElementViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsElementViewModel.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public abstract partial class DetailsElementViewModel(IDetailsElement _detailsElement, WeakReference context) : ExtensionObjectViewModel(context)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsLinkViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsLinkViewModel.cs
similarity index 90%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsLinkViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsLinkViewModel.cs
index 0d600958da..e7aa9b67af 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsLinkViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsLinkViewModel.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class DetailsLinkViewModel(
IDetailsElement _detailsElement,
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsSeparatorViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsSeparatorViewModel.cs
similarity index 82%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsSeparatorViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsSeparatorViewModel.cs
index 44b48f0802..e4c76918c0 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsSeparatorViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsSeparatorViewModel.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class DetailsSeparatorViewModel(
IDetailsElement _detailsElement,
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsTagsViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsTagsViewModel.cs
similarity index 89%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsTagsViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsTagsViewModel.cs
index e188983047..803585c1ce 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsTagsViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsTagsViewModel.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class DetailsTagsViewModel(
IDetailsElement _detailsElement,
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsViewModel.cs
similarity index 94%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsViewModel.cs
index 893a94f86e..034e247519 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/DetailsViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/DetailsViewModel.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class DetailsViewModel(IDetails _details, WeakReference context) : ExtensionObjectViewModel(context)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ExtensionObjectViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ExtensionObjectViewModel.cs
similarity index 96%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ExtensionObjectViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ExtensionObjectViewModel.cs
index 08d1128106..f0bb9de118 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ExtensionObjectViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ExtensionObjectViewModel.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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 CommunityToolkit.Mvvm.ComponentModel;
using ManagedCommon;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public abstract partial class ExtensionObjectViewModel : ObservableObject
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/GlobalLogPageContext.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/GlobalLogPageContext.cs
similarity index 92%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/GlobalLogPageContext.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/GlobalLogPageContext.cs
index fde1a36817..228ccc5f4b 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/GlobalLogPageContext.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/GlobalLogPageContext.cs
@@ -2,7 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public class GlobalLogPageContext : IPageContext
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/IContextItemViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/IContextItemViewModel.cs
similarity index 88%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/IContextItemViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/IContextItemViewModel.cs
index 743687147c..704947c3a8 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/IContextItemViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/IContextItemViewModel.cs
@@ -8,7 +8,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public interface IContextItemViewModel
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.Common/Services/IRootPageService.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/IRootPageService.cs
similarity index 84%
rename from src/modules/cmdpal/Microsoft.CmdPal.Common/Services/IRootPageService.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/IRootPageService.cs
index 24e509b8a4..77eaecae4b 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.Common/Services/IRootPageService.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/IRootPageService.cs
@@ -2,9 +2,7 @@
// 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.Threading.Tasks;
-
-namespace Microsoft.CmdPal.Common.Services;
+namespace Microsoft.CmdPal.Core.ViewModels;
public interface IRootPageService
{
@@ -29,9 +27,11 @@ public interface IRootPageService
Task PostLoadRootPageAsync();
///
- /// Called when a top-level command is performed. The context is the
+ /// Called when a command is performed. The context is the
/// sender context for the invoked command. This is typically the IListItem
/// or ICommandContextItem that was used to invoke the command.
///
- void OnPerformTopLevelCommand(object? context);
+ void OnPerformCommand(object? context, bool topLevel, AppExtensionHost? currentHost);
+
+ void GoHome();
}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/IconDataViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/IconDataViewModel.cs
similarity index 91%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/IconDataViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/IconDataViewModel.cs
index 35d91f6739..70b143864c 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/IconDataViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/IconDataViewModel.cs
@@ -1,13 +1,13 @@
-// Copyright (c) Microsoft Corporation
+// 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 CommunityToolkit.Mvvm.ComponentModel;
-using Microsoft.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
using Windows.Storage.Streams;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class IconDataViewModel : ObservableObject, IIconData
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/IconInfoViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/IconInfoViewModel.cs
similarity index 92%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/IconInfoViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/IconInfoViewModel.cs
index 93f8ece969..21ddbe99d9 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/IconInfoViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/IconInfoViewModel.cs
@@ -1,12 +1,12 @@
-// Copyright (c) Microsoft Corporation
+// 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 CommunityToolkit.Mvvm.ComponentModel;
-using Microsoft.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class IconInfoViewModel : ObservableObject, IIconInfo
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ListItemViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ListItemViewModel.cs
similarity index 97%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ListItemViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ListItemViewModel.cs
index 48542ba628..682bf4daea 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ListItemViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ListItemViewModel.cs
@@ -1,13 +1,13 @@
-// Copyright (c) Microsoft Corporation
+// 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.Diagnostics.CodeAnalysis;
-using Microsoft.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class ListItemViewModel(IListItem model, WeakReference context)
: CommandItemViewModel(new(model), context)
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ListViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ListViewModel.cs
similarity index 98%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ListViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ListViewModel.cs
index 5a5917bc67..9cf15cb70e 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ListViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ListViewModel.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft Corporation
+// 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.
@@ -6,13 +6,13 @@ using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
-using Microsoft.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
using Windows.Foundation;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class ListViewModel : PageViewModel, IDisposable
{
@@ -72,7 +72,7 @@ public partial class ListViewModel : PageViewModel, IDisposable
}
}
- public ListViewModel(IListPage model, TaskScheduler scheduler, CommandPaletteHost host)
+ public ListViewModel(IListPage model, TaskScheduler scheduler, AppExtensionHost host)
: base(model, scheduler, host)
{
_model = new(model);
@@ -158,10 +158,7 @@ public partial class ListViewModel : PageViewModel, IDisposable
}
// Cancel any ongoing search
- if (_cancellationTokenSource != null)
- {
- _cancellationTokenSource.Cancel();
- }
+ _cancellationTokenSource?.Cancel();
lock (_listLock)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/LoadingPageViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/LoadingPageViewModel.cs
similarity index 71%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/LoadingPageViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/LoadingPageViewModel.cs
index 60571cbe73..3e2cd420c2 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/LoadingPageViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/LoadingPageViewModel.cs
@@ -1,15 +1,15 @@
-// Copyright (c) Microsoft Corporation
+// 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;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class LoadingPageViewModel : PageViewModel
{
- public LoadingPageViewModel(IPage? model, TaskScheduler scheduler)
- : base(model, scheduler, CommandPaletteHost.Instance)
+ public LoadingPageViewModel(IPage? model, TaskScheduler scheduler, AppExtensionHost host)
+ : base(model, scheduler, host)
{
ModelIsLoading = true;
IsInitialized = false;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/LogMessageViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/LogMessageViewModel.cs
similarity index 83%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/LogMessageViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/LogMessageViewModel.cs
index 60d065ac04..9ebff20304 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/LogMessageViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/LogMessageViewModel.cs
@@ -2,10 +2,10 @@
// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class LogMessageViewModel : ExtensionObjectViewModel
{
@@ -13,8 +13,6 @@ public partial class LogMessageViewModel : ExtensionObjectViewModel
public string Message { get; private set; } = string.Empty;
- public string ExtensionPfn { get; set; } = string.Empty;
-
public LogMessageViewModel(ILogMessage message, IPageContext context)
: base(context)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ActivateSecondaryCommandMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ActivateSecondaryCommandMessage.cs
similarity index 77%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ActivateSecondaryCommandMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ActivateSecondaryCommandMessage.cs
index 1e35d6d796..1ecd7431d2 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ActivateSecondaryCommandMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ActivateSecondaryCommandMessage.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
///
/// Used to perform a list item's secondary command when the user presses ctrl+enter in the search box
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ActivateSelectedListItemMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ActivateSelectedListItemMessage.cs
similarity index 86%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ActivateSelectedListItemMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ActivateSelectedListItemMessage.cs
index 339e0c1b3d..bdd1876d4e 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ActivateSelectedListItemMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ActivateSelectedListItemMessage.cs
@@ -2,7 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
///
/// Used to perform a list item's command when the user presses enter in the search box
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/BeginInvokeMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/BeginInvokeMessage.cs
similarity index 65%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/BeginInvokeMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/BeginInvokeMessage.cs
index 2c7fb406b8..8ed180a27c 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/BeginInvokeMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/BeginInvokeMessage.cs
@@ -1,7 +1,7 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record BeginInvokeMessage;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ClearSearchMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ClearSearchMessage.cs
similarity index 66%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ClearSearchMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ClearSearchMessage.cs
index e3b7ee831e..47bd0e7be8 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ClearSearchMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ClearSearchMessage.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record ClearSearchMessage()
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/CloseContextMenuMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/CloseContextMenuMessage.cs
similarity index 85%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/CloseContextMenuMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/CloseContextMenuMessage.cs
index daa18498e7..5178e00631 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/CloseContextMenuMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/CloseContextMenuMessage.cs
@@ -2,7 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
///
/// Used to announce that a context menu should close
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/CmdPalInvokeResultMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/CmdPalInvokeResultMessage.cs
similarity index 72%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/CmdPalInvokeResultMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/CmdPalInvokeResultMessage.cs
index 1ecc1be460..da81db6e3c 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/CmdPalInvokeResultMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/CmdPalInvokeResultMessage.cs
@@ -1,7 +1,7 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record CmdPalInvokeResultMessage(Microsoft.CommandPalette.Extensions.CommandResultKind Kind);
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/DismissMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/DismissMessage.cs
similarity index 66%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/DismissMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/DismissMessage.cs
index 273952897d..98a5b34562 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/DismissMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/DismissMessage.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record DismissMessage()
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/FocusSearchBoxMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/FocusSearchBoxMessage.cs
similarity index 66%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/FocusSearchBoxMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/FocusSearchBoxMessage.cs
index 4e6db37daa..73fad88301 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/FocusSearchBoxMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/FocusSearchBoxMessage.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record FocusSearchBoxMessage()
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/GoBackMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/GoBackMessage.cs
similarity index 77%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/GoBackMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/GoBackMessage.cs
index d200a8454f..86872d6bb1 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/GoBackMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/GoBackMessage.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record GoBackMessage(bool WithAnimation = true, bool FocusSearch = true)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/GoHomeMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/GoHomeMessage.cs
similarity index 77%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/GoHomeMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/GoHomeMessage.cs
index 5a7f56d021..d99cbbdd16 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/GoHomeMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/GoHomeMessage.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
// TODO! sticking these properties here feels like leaking the UI into the models
public record GoHomeMessage(bool WithAnimation = true, bool FocusSearch = true)
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/HandleCommandResultMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/HandleCommandResultMessage.cs
similarity index 66%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/HandleCommandResultMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/HandleCommandResultMessage.cs
index 3adf7ae30c..7c60f7cb4e 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/HandleCommandResultMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/HandleCommandResultMessage.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record HandleCommandResultMessage(ExtensionObject Result)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/HideDetailsMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/HideDetailsMessage.cs
similarity index 62%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/HideDetailsMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/HideDetailsMessage.cs
index a04455b519..43fa403731 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/HideDetailsMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/HideDetailsMessage.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record HideDetailsMessage()
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/HotkeySummonMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/HotkeySummonMessage.cs
similarity index 69%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/HotkeySummonMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/HotkeySummonMessage.cs
index bff7af364e..4dcef111a3 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/HotkeySummonMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/HotkeySummonMessage.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record HotkeySummonMessage(string CommandId, IntPtr Hwnd)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/LaunchUriMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/LaunchUriMessage.cs
similarity index 62%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/LaunchUriMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/LaunchUriMessage.cs
index dba45af1b7..3835b7cc7f 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/LaunchUriMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/LaunchUriMessage.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record LaunchUriMessage(Uri Uri)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/NavigateBackMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/NavigateBackMessage.cs
similarity index 69%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/NavigateBackMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/NavigateBackMessage.cs
index 5e19bfc57f..3e085184ed 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/NavigateBackMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/NavigateBackMessage.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record NavigateBackMessage(bool FromBackspace = false)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/NavigateNextCommand.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/NavigateNextCommand.cs
similarity index 76%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/NavigateNextCommand.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/NavigateNextCommand.cs
index c996e0eecf..4ad61b20e6 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/NavigateNextCommand.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/NavigateNextCommand.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
///
/// Used to navigate to the next command in the page when pressing the Down key in the SearchBox.
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/NavigatePreviousCommand.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/NavigatePreviousCommand.cs
similarity index 77%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/NavigatePreviousCommand.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/NavigatePreviousCommand.cs
index 76f0f07908..4d28fce50b 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/NavigatePreviousCommand.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/NavigatePreviousCommand.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
///
/// Used to navigate to the previous command in the page when pressing the Down key in the SearchBox.
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/NavigateToPageMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/NavigateToPageMessage.cs
similarity index 70%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/NavigateToPageMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/NavigateToPageMessage.cs
index 784ce8f2bc..3d17f3b3cc 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/NavigateToPageMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/NavigateToPageMessage.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record NavigateToPageMessage(PageViewModel Page, bool WithAnimation)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/OpenContextMenuMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/OpenContextMenuMessage.cs
similarity index 85%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/OpenContextMenuMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/OpenContextMenuMessage.cs
index 3cdcf72cee..9c19c9474e 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/OpenContextMenuMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/OpenContextMenuMessage.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft Corporation
+// 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.
@@ -6,7 +6,7 @@ using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls.Primitives;
using Windows.Foundation;
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
///
/// Used to announce the context menu should open
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/OpenSettingsMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/OpenSettingsMessage.cs
similarity index 55%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/OpenSettingsMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/OpenSettingsMessage.cs
index 115593d5ae..e4b02b5c0c 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/OpenSettingsMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/OpenSettingsMessage.cs
@@ -1,10 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.BuiltinCommands;
-
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record OpenSettingsMessage()
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/PerformCommandMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/PerformCommandMessage.cs
similarity index 77%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/PerformCommandMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/PerformCommandMessage.cs
index b0e5e4829a..cd07a51beb 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/PerformCommandMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/PerformCommandMessage.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
///
/// Used to do a command - navigate to a page or invoke it
@@ -18,21 +18,12 @@ public record PerformCommandMessage
public bool WithAnimation { get; set; } = true;
- public CommandPaletteHost? ExtensionHost { get; private set; }
-
public PerformCommandMessage(ExtensionObject command)
{
Command = command;
Context = null;
}
- public PerformCommandMessage(TopLevelViewModel topLevelCommand)
- {
- Command = topLevelCommand.CommandViewModel.Model;
- Context = null;
- ExtensionHost = topLevelCommand.ExtensionHost;
- }
-
public PerformCommandMessage(ExtensionObject command, ExtensionObject context)
{
Command = command;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/QuitMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/QuitMessage.cs
similarity index 68%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/QuitMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/QuitMessage.cs
index 2951aa57fb..12b9cec827 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/QuitMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/QuitMessage.cs
@@ -1,10 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.BuiltinCommands;
-
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
///
/// Message which closes the application. Used by via .
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ReloadCommandsMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ReloadCommandsMessage.cs
similarity index 66%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ReloadCommandsMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ReloadCommandsMessage.cs
index c427da4f9c..a553568f50 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ReloadCommandsMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ReloadCommandsMessage.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record ReloadCommandsMessage()
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/SettingsWindowClosedMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/SettingsWindowClosedMessage.cs
similarity index 67%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/SettingsWindowClosedMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/SettingsWindowClosedMessage.cs
index 6627ab6192..f58637e8a5 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/SettingsWindowClosedMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/SettingsWindowClosedMessage.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record SettingsWindowClosedMessage
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ShowConfirmationMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ShowConfirmationMessage.cs
similarity index 72%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ShowConfirmationMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ShowConfirmationMessage.cs
index c4059fbecd..fb7c5e88a8 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ShowConfirmationMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ShowConfirmationMessage.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record ShowConfirmationMessage(Microsoft.CommandPalette.Extensions.IConfirmationArgs? Args)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ShowDetailsMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ShowDetailsMessage.cs
similarity index 64%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ShowDetailsMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ShowDetailsMessage.cs
index b51300d6d0..69dda7a589 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ShowDetailsMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ShowDetailsMessage.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record ShowDetailsMessage(DetailsViewModel Details)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ShowToastMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ShowToastMessage.cs
similarity index 67%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ShowToastMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ShowToastMessage.cs
index 0ec61dffd8..869d169858 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ShowToastMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ShowToastMessage.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record ShowToastMessage(string Message)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ShowWindowMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ShowWindowMessage.cs
similarity index 67%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ShowWindowMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ShowWindowMessage.cs
index 9e880c08f0..01c05ff9b7 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ShowWindowMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/ShowWindowMessage.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record ShowWindowMessage(IntPtr Hwnd)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/TryCommandKeybindingMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/TryCommandKeybindingMessage.cs
similarity index 77%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/TryCommandKeybindingMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/TryCommandKeybindingMessage.cs
index 3df48ec3a0..48f7305e0a 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/TryCommandKeybindingMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/TryCommandKeybindingMessage.cs
@@ -1,10 +1,10 @@
-// Copyright (c) Microsoft Corporation
+// 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 Windows.System;
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record TryCommandKeybindingMessage(bool Ctrl, bool Alt, bool Shift, bool Win, VirtualKey Key)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/UpdateCommandBarMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/UpdateCommandBarMessage.cs
similarity index 95%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/UpdateCommandBarMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/UpdateCommandBarMessage.cs
index 9acec4bfe1..36b7653af5 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/UpdateCommandBarMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/UpdateCommandBarMessage.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.ComponentModel;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
///
/// Used to update the command bar at the bottom to reflect the commands for a list item
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/UpdateFallbackItemsMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/UpdateFallbackItemsMessage.cs
similarity index 67%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/UpdateFallbackItemsMessage.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/UpdateFallbackItemsMessage.cs
index c7503ce1fb..8a913f7a3f 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/UpdateFallbackItemsMessage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Messages/UpdateFallbackItemsMessage.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Messages;
+namespace Microsoft.CmdPal.Core.ViewModels.Messages;
public record UpdateFallbackItemsMessage()
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Microsoft.CmdPal.Core.ViewModels.csproj b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Microsoft.CmdPal.Core.ViewModels.csproj
new file mode 100644
index 0000000000..1508994524
--- /dev/null
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Microsoft.CmdPal.Core.ViewModels.csproj
@@ -0,0 +1,60 @@
+
+
+
+
+
+ enable
+ enable
+ false
+ false
+ $(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPal
+
+ preview
+
+ SA1313;
+
+
+
+ true
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Resources.resx
+ True
+ True
+
+
+
+
+
+
+
+
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionObject`1.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Models/ExtensionObject`1.cs
similarity index 83%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionObject`1.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Models/ExtensionObject`1.cs
index 822229addc..c90225f344 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionObject`1.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/Models/ExtensionObject`1.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft Corporation
+// 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.
-namespace Microsoft.CmdPal.UI.ViewModels.Models;
+namespace Microsoft.CmdPal.Core.ViewModels.Models;
public class ExtensionObject(T? value) // where T : IInspectable
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/NativeMethods.json b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/NativeMethods.json
new file mode 100644
index 0000000000..59fa7259c4
--- /dev/null
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/NativeMethods.json
@@ -0,0 +1,4 @@
+{
+ "$schema": "https://aka.ms/CsWin32.schema.json",
+ "allowMarshaling": false
+}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/NativeMethods.txt b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/NativeMethods.txt
new file mode 100644
index 0000000000..981c7446f7
--- /dev/null
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/NativeMethods.txt
@@ -0,0 +1,19 @@
+GetPhysicallyInstalledSystemMemory
+GlobalMemoryStatusEx
+GetSystemInfo
+CoCreateInstance
+SetForegroundWindow
+IsIconic
+RegisterHotKey
+SetWindowLongPtr
+CallWindowProc
+ShowWindow
+SetForegroundWindow
+SetFocus
+SetActiveWindow
+MonitorFromWindow
+GetMonitorInfo
+SHCreateStreamOnFileEx
+CoAllowSetForegroundWindow
+SHCreateStreamOnFileEx
+SHLoadIndirectString
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/PageViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/PageViewModel.cs
similarity index 89%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/PageViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/PageViewModel.cs
index 126efa83ca..552971b96c 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/PageViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/PageViewModel.cs
@@ -1,14 +1,14 @@
-// Copyright (c) Microsoft Corporation
+// 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.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
-using Microsoft.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class PageViewModel : ExtensionObjectViewModel, IPageContext
{
@@ -43,7 +43,7 @@ public partial class PageViewModel : ExtensionObjectViewModel, IPageContext
public bool ShowSuggestion => !string.IsNullOrEmpty(TextToSuggest) && TextToSuggest != Filter;
[ObservableProperty]
- public partial CommandPaletteHost ExtensionHost { get; private set; }
+ public partial AppExtensionHost ExtensionHost { get; private set; }
public bool HasStatusMessage => MostRecentStatusMessage != null;
@@ -69,7 +69,7 @@ public partial class PageViewModel : ExtensionObjectViewModel, IPageContext
public IconInfoViewModel Icon { get; protected set; }
- public PageViewModel(IPage? model, TaskScheduler scheduler, CommandPaletteHost extensionHost)
+ public PageViewModel(IPage? model, TaskScheduler scheduler, AppExtensionHost extensionHost)
: base((IPageContext?)null)
{
_pageModel = new(model);
@@ -220,7 +220,7 @@ public partial class PageViewModel : ExtensionObjectViewModel, IPageContext
{
// Set the extensionHint to the Page Title (if we have one, and one not provided).
// extensionHint ??= _pageModel?.Unsafe?.Title;
- extensionHint ??= ExtensionHost.Extension?.ExtensionDisplayName ?? Title;
+ extensionHint ??= ExtensionHost.GetExtensionDisplayName() ?? Title;
Task.Factory.StartNew(
() =>
{
@@ -249,7 +249,19 @@ public partial class PageViewModel : ExtensionObjectViewModel, IPageContext
public interface IPageContext
{
- public void ShowException(Exception ex, string? extensionHint = null);
+ void ShowException(Exception ex, string? extensionHint = null);
- public TaskScheduler Scheduler { get; }
+ TaskScheduler Scheduler { get; }
+}
+
+public interface IPageViewModelFactoryService
+{
+ ///
+ /// Creates a new instance of the page view model for the given page type.
+ ///
+ /// The page for which to create the view model.
+ /// Indicates whether the page is not the top-level page.
+ /// The command palette host that will host the page (for status messages)
+ /// A new instance of the page view model.
+ PageViewModel? TryCreatePageViewModel(IPage page, bool nested, AppExtensionHost host);
}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/PageViewModelFactory.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/PageViewModelFactory.cs
new file mode 100644
index 0000000000..a30a2bd76b
--- /dev/null
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/PageViewModelFactory.cs
@@ -0,0 +1,27 @@
+// 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;
+
+namespace Microsoft.CmdPal.Core.ViewModels;
+
+public class PageViewModelFactory : IPageViewModelFactoryService
+{
+ private readonly TaskScheduler _scheduler;
+
+ public PageViewModelFactory(TaskScheduler scheduler)
+ {
+ _scheduler = scheduler;
+ }
+
+ public PageViewModel? TryCreatePageViewModel(IPage page, bool nested, AppExtensionHost host)
+ {
+ return page switch
+ {
+ IListPage listPage => new ListViewModel(listPage, _scheduler, host) { IsNested = nested },
+ IContentPage contentPage => new ContentPageViewModel(contentPage, _scheduler, host),
+ _ => null,
+ };
+ }
+}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ProgressViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ProgressViewModel.cs
similarity index 92%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ProgressViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ProgressViewModel.cs
index 3a2d4512ed..40ea290dd4 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ProgressViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ProgressViewModel.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class ProgressViewModel : ExtensionObjectViewModel
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SeparatorContextItemViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/SeparatorContextItemViewModel.cs
similarity index 79%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SeparatorContextItemViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/SeparatorContextItemViewModel.cs
index 7d700e3625..c6858f490d 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SeparatorContextItemViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/SeparatorContextItemViewModel.cs
@@ -2,10 +2,10 @@
// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class SeparatorContextItemViewModel() : IContextItemViewModel, ISeparatorContextItem
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ShellViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ShellViewModel.cs
similarity index 69%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ShellViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ShellViewModel.cs
index 112c2b67df..170103b09c 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ShellViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ShellViewModel.cs
@@ -1,26 +1,24 @@
-// Copyright (c) Microsoft Corporation
+// 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.Runtime.InteropServices;
-using System.Runtime.Versioning;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using ManagedCommon;
-using Microsoft.CmdPal.Common.Services;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
-using Microsoft.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-using WinRT;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class ShellViewModel : ObservableObject,
IRecipient
{
private readonly IRootPageService _rootPageService;
+ private readonly IAppHostService _appHostService;
private readonly TaskScheduler _scheduler;
+ private readonly IPageViewModelFactoryService _pageViewModelFactory;
private readonly Lock _invokeLock = new();
private Task? _handleInvokeTask;
@@ -60,16 +58,22 @@ public partial class ShellViewModel : ObservableObject,
private IPage? _rootPage;
- private IExtensionWrapper? _activeExtension;
private bool _isNested;
public bool IsNested { get => _isNested; }
- public ShellViewModel(TaskScheduler scheduler, IRootPageService rootPageService)
+ public ShellViewModel(
+ TaskScheduler scheduler,
+ IRootPageService rootPageService,
+ IPageViewModelFactoryService pageViewModelFactory,
+ IAppHostService appHostService)
{
+ _pageViewModelFactory = pageViewModelFactory;
_scheduler = scheduler;
_rootPageService = rootPageService;
- _currentPage = new LoadingPageViewModel(null, _scheduler);
+ _appHostService = appHostService;
+
+ _currentPage = new LoadingPageViewModel(null, _scheduler, appHostService.GetDefaultHost());
// Register to receive messages
WeakReferenceMessenger.Default.Register(this);
@@ -171,11 +175,6 @@ public partial class ShellViewModel : ObservableObject,
}
}
- public void PerformTopLevelCommand(PerformCommandMessage message)
- {
- _rootPageService.OnPerformTopLevelCommand(message.Context);
- }
-
public void Receive(PerformCommandMessage message)
{
PerformCommand(message);
@@ -189,61 +188,12 @@ public partial class ShellViewModel : ObservableObject,
return;
}
- if (!CurrentPage.IsNested)
- {
- // on the main page here
- PerformTopLevelCommand(message);
- }
+ var host = _appHostService.GetHostForCommand(message.Context, CurrentPage.ExtensionHost);
- IExtensionWrapper? extension = null;
+ _rootPageService.OnPerformCommand(message.Context, !CurrentPage.IsNested, host);
try
{
- // In the case that we're coming from a top-level command, the
- // current page's host is the global instance. We only really want
- // to use that as the host of last resort.
- var pageHost = CurrentPage?.ExtensionHost;
- if (pageHost == CommandPaletteHost.Instance)
- {
- pageHost = null;
- }
-
- var messageHost = message.ExtensionHost;
-
- // Use the host from the current page if it has one, else use the
- // one specified in the PerformMessage for a top-level command,
- // else just use the global one.
- CommandPaletteHost host;
-
- // Top level items can come through without a Extension set on the
- // message. In that case, the `Context` is actually the
- // TopLevelViewModel itself, and we can use that to get at the
- // extension object.
- extension = pageHost?.Extension ?? messageHost?.Extension ?? null;
- if (extension == null && message.Context is TopLevelViewModel topLevelViewModel)
- {
- extension = topLevelViewModel.ExtensionHost?.Extension;
- host = pageHost ?? messageHost ?? topLevelViewModel?.ExtensionHost ?? CommandPaletteHost.Instance;
- }
- else
- {
- host = pageHost ?? messageHost ?? CommandPaletteHost.Instance;
- }
-
- if (extension != null)
- {
- if (messageHost != null)
- {
- Logger.LogDebug($"Activated top-level command from {extension.ExtensionDisplayName}");
- }
- else
- {
- Logger.LogDebug($"Activated command from {extension.ExtensionDisplayName}");
- }
- }
-
- SetActiveExtension(extension);
-
if (command is IPage page)
{
Logger.LogDebug($"Navigating to page");
@@ -252,7 +202,7 @@ public partial class ShellViewModel : ObservableObject,
_isNested = !isMainPage;
// Construct our ViewModel of the appropriate type and pass it the UI Thread context.
- var pageViewModel = GetViewModelForPage(page, _isNested, host);
+ var pageViewModel = _pageViewModelFactory.TryCreatePageViewModel(page, _isNested, host);
if (pageViewModel == null)
{
Logger.LogError($"Failed to create ViewModel for page {page.GetType().Name}");
@@ -272,18 +222,18 @@ public partial class ShellViewModel : ObservableObject,
Logger.LogDebug($"Invoking command");
WeakReferenceMessenger.Default.Send();
- StartInvoke(message, invokable);
+ StartInvoke(message, invokable, host);
}
}
catch (Exception ex)
{
// TODO: It would be better to do this as a page exception, rather
// than a silent log message.
- CommandPaletteHost.Instance.Log(ex.Message);
+ host?.Log(ex.Message);
}
}
- private void StartInvoke(PerformCommandMessage message, IInvokableCommand invokable)
+ private void StartInvoke(PerformCommandMessage message, IInvokableCommand invokable, AppExtensionHost? host)
{
// TODO GH #525 This needs more better locking.
lock (_invokeLock)
@@ -296,13 +246,13 @@ public partial class ShellViewModel : ObservableObject,
{
_handleInvokeTask = Task.Run(() =>
{
- SafeHandleInvokeCommandSynchronous(message, invokable);
+ SafeHandleInvokeCommandSynchronous(message, invokable, host);
});
}
}
}
- private void SafeHandleInvokeCommandSynchronous(PerformCommandMessage message, IInvokableCommand invokable)
+ private void SafeHandleInvokeCommandSynchronous(PerformCommandMessage message, IInvokableCommand invokable, AppExtensionHost? host)
{
try
{
@@ -322,7 +272,7 @@ public partial class ShellViewModel : ObservableObject,
// TODO: It would be better to do this as a page exception, rather
// than a silent log message.
- CommandPaletteHost.Instance.Log(ex.Message);
+ host?.Log(ex.Message);
}
}
@@ -397,54 +347,9 @@ public partial class ShellViewModel : ObservableObject,
}
}
- private PageViewModel? GetViewModelForPage(IPage page, bool nested, CommandPaletteHost host)
- {
- return page switch
- {
- IListPage listPage => new ListViewModel(listPage, _scheduler, host)
- {
- IsNested = nested,
- },
- IContentPage contentPage => new ContentPageViewModel(contentPage, _scheduler, host),
- _ => null,
- };
- }
-
- public void SetActiveExtension(IExtensionWrapper? extension)
- {
- if (extension != _activeExtension)
- {
- // There's not really a CoDisallowSetForegroundWindow, so we don't
- // need to handle that
- _activeExtension = extension;
-
- var extensionWinRtObject = _activeExtension?.GetExtensionObject();
- if (extensionWinRtObject != null)
- {
- try
- {
- unsafe
- {
- var winrtObj = (IWinRTObject)extensionWinRtObject;
- var intPtr = winrtObj.NativeObject.ThisPtr;
- var hr = Native.CoAllowSetForegroundWindow(intPtr);
- if (hr != 0)
- {
- Logger.LogWarning($"Error giving foreground rights: 0x{hr.Value:X8}");
- }
- }
- }
- catch (Exception ex)
- {
- Logger.LogError(ex.ToString());
- }
- }
- }
- }
-
public void GoHome(bool withAnimation = true, bool focusSearch = true)
{
- SetActiveExtension(null);
+ _rootPageService.GoHome();
WeakReferenceMessenger.Default.Send(new(withAnimation, focusSearch));
}
@@ -453,20 +358,6 @@ public partial class ShellViewModel : ObservableObject,
WeakReferenceMessenger.Default.Send(new(withAnimation, focusSearch));
}
- // You may ask yourself, why aren't we using CsWin32 for this?
- // The CsWin32 projected version includes some object marshalling, like so:
- //
- // HRESULT CoAllowSetForegroundWindow([MarshalAs(UnmanagedType.IUnknown)] object pUnk,...)
- //
- // And if you do it like that, then the IForegroundTransfer interface isn't marshalled correctly
- internal sealed class Native
- {
- [DllImport("OLE32.dll", ExactSpelling = true)]
- [DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
- [SupportedOSPlatform("windows5.0")]
- internal static extern unsafe global::Windows.Win32.Foundation.HRESULT CoAllowSetForegroundWindow(nint pUnk, [Optional] void* lpvReserved);
- }
-
private void OnUIThread(Action action)
{
_ = Task.Factory.StartNew(
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/StatusMessageViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/StatusMessageViewModel.cs
similarity index 87%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/StatusMessageViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/StatusMessageViewModel.cs
index 32328b0eb1..fb8b333637 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/StatusMessageViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/StatusMessageViewModel.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class StatusMessageViewModel : ExtensionObjectViewModel
{
@@ -15,14 +15,10 @@ public partial class StatusMessageViewModel : ExtensionObjectViewModel
public MessageState State { get; private set; } = MessageState.Info;
- public string ExtensionPfn { get; set; } = string.Empty;
-
public ProgressViewModel? Progress { get; private set; }
public bool HasProgress => Progress != null;
- // public bool IsIndeterminate => Progress != null && Progress.IsIndeterminate;
- // public double ProgressValue => (Progress?.ProgressPercent ?? 0) / 100.0;
public StatusMessageViewModel(IStatusMessage message, WeakReference context)
: base(context)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TagViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/TagViewModel.cs
similarity index 91%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TagViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/TagViewModel.cs
index 414f1882a5..98ea66f4e8 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TagViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/TagViewModel.cs
@@ -1,11 +1,11 @@
-// Copyright (c) Microsoft Corporation
+// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class TagViewModel(ITag _tag, WeakReference context) : ExtensionObjectViewModel(context)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ToastViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ToastViewModel.cs
similarity index 81%
rename from src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ToastViewModel.cs
rename to src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ToastViewModel.cs
index 156a47f557..719d7edd5d 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ToastViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Core.ViewModels/ToastViewModel.cs
@@ -4,9 +4,9 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class ToastViewModel : ObservableObject
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/AliasManager.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/AliasManager.cs
index 2d5fd66145..131d633940 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/AliasManager.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/AliasManager.cs
@@ -4,7 +4,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
namespace Microsoft.CmdPal.UI.ViewModels;
@@ -38,7 +38,8 @@ public partial class AliasManager : ObservableObject
if (topLevelCommand != null)
{
WeakReferenceMessenger.Default.Send();
- WeakReferenceMessenger.Default.Send(new(topLevelCommand));
+
+ WeakReferenceMessenger.Default.Send(topLevelCommand.GetPerformCommandMessage());
return true;
}
}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandPaletteContentPageViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandPaletteContentPageViewModel.cs
new file mode 100644
index 0000000000..e3cd8a92d7
--- /dev/null
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandPaletteContentPageViewModel.cs
@@ -0,0 +1,28 @@
+// 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.CmdPal.Core.ViewModels;
+using Microsoft.CommandPalette.Extensions;
+
+namespace Microsoft.CmdPal.UI.ViewModels;
+
+public partial class CommandPaletteContentPageViewModel : ContentPageViewModel
+{
+ public CommandPaletteContentPageViewModel(IContentPage model, TaskScheduler scheduler, AppExtensionHost host)
+ : base(model, scheduler, host)
+ {
+ }
+
+ public override ContentViewModel? ViewModelFromContent(IContent content, WeakReference context)
+ {
+ ContentViewModel? viewModel = content switch
+ {
+ IFormContent form => new ContentFormViewModel(form, context),
+ IMarkdownContent markdown => new ContentMarkdownViewModel(markdown, context),
+ ITreeContent tree => new ContentTreeViewModel(tree, context),
+ _ => null,
+ };
+ return viewModel;
+ }
+}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandPaletteHost.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandPaletteHost.cs
index 9aa12dc037..ab507950c5 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandPaletteHost.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandPaletteHost.cs
@@ -1,35 +1,19 @@
-// Copyright (c) Microsoft Corporation
+// 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.ObjectModel;
-using System.Diagnostics;
-using ManagedCommon;
using Microsoft.CmdPal.Common.Services;
+using Microsoft.CmdPal.Core.ViewModels;
using Microsoft.CommandPalette.Extensions;
-using Microsoft.CommandPalette.Extensions.Toolkit;
-using Windows.Foundation;
namespace Microsoft.CmdPal.UI.ViewModels;
-public sealed partial class CommandPaletteHost : IExtensionHost
+public sealed partial class CommandPaletteHost : AppExtensionHost, IExtensionHost
{
// Static singleton, so that we can access this from anywhere
// Post MVVM - this should probably be like, a dependency injection thing.
public static CommandPaletteHost Instance { get; } = new();
- private static readonly GlobalLogPageContext _globalLogPageContext = new();
-
- private static ulong _hostingHwnd;
-
- public ulong HostingHwnd => _hostingHwnd;
-
- public string LanguageOverride => string.Empty;
-
- public static ObservableCollection LogMessages { get; } = [];
-
- public ObservableCollection StatusMessages { get; } = [];
-
public IExtensionWrapper? Extension { get; }
private readonly ICommandProvider? _builtInProvider;
@@ -48,145 +32,8 @@ public sealed partial class CommandPaletteHost : IExtensionHost
_builtInProvider = builtInProvider;
}
- public IAsyncAction ShowStatus(IStatusMessage? message, StatusContext context)
+ public override string? GetExtensionDisplayName()
{
- if (message == null)
- {
- return Task.CompletedTask.AsAsyncAction();
- }
-
- Debug.WriteLine(message.Message);
-
- _ = Task.Run(() =>
- {
- ProcessStatusMessage(message, context);
- });
-
- return Task.CompletedTask.AsAsyncAction();
- }
-
- public IAsyncAction HideStatus(IStatusMessage? message)
- {
- if (message == null)
- {
- return Task.CompletedTask.AsAsyncAction();
- }
-
- _ = Task.Run(() =>
- {
- ProcessHideStatusMessage(message);
- });
- return Task.CompletedTask.AsAsyncAction();
- }
-
- public IAsyncAction LogMessage(ILogMessage? message)
- {
- if (message == null)
- {
- return Task.CompletedTask.AsAsyncAction();
- }
-
- Logger.LogDebug(message.Message);
-
- _ = Task.Run(() =>
- {
- ProcessLogMessage(message);
- });
-
- // We can't just make a LogMessageViewModel : ExtensionObjectViewModel
- // because we don't necessarily know the page context. Butts.
- return Task.CompletedTask.AsAsyncAction();
- }
-
- public void ProcessLogMessage(ILogMessage message)
- {
- var vm = new LogMessageViewModel(message, _globalLogPageContext);
- vm.SafeInitializePropertiesSynchronous();
-
- if (Extension != null)
- {
- vm.ExtensionPfn = Extension.PackageFamilyName;
- }
-
- Task.Factory.StartNew(
- () =>
- {
- LogMessages.Add(vm);
- },
- CancellationToken.None,
- TaskCreationOptions.None,
- _globalLogPageContext.Scheduler);
- }
-
- public void ProcessStatusMessage(IStatusMessage message, StatusContext context)
- {
- // If this message is already in the list of messages, just bring it to the top
- var oldVm = StatusMessages.Where(messageVM => messageVM.Model.Unsafe == message).FirstOrDefault();
- if (oldVm != null)
- {
- Task.Factory.StartNew(
- () =>
- {
- StatusMessages.Remove(oldVm);
- StatusMessages.Add(oldVm);
- },
- CancellationToken.None,
- TaskCreationOptions.None,
- _globalLogPageContext.Scheduler);
- return;
- }
-
- var vm = new StatusMessageViewModel(message, new(_globalLogPageContext));
- vm.SafeInitializePropertiesSynchronous();
-
- if (Extension != null)
- {
- vm.ExtensionPfn = Extension.PackageFamilyName;
- }
-
- Task.Factory.StartNew(
- () =>
- {
- StatusMessages.Add(vm);
- },
- CancellationToken.None,
- TaskCreationOptions.None,
- _globalLogPageContext.Scheduler);
- }
-
- public void ProcessHideStatusMessage(IStatusMessage message)
- {
- Task.Factory.StartNew(
- () =>
- {
- try
- {
- var vm = StatusMessages.Where(messageVM => messageVM.Model.Unsafe == message).FirstOrDefault();
- if (vm != null)
- {
- StatusMessages.Remove(vm);
- }
- }
- catch
- {
- }
- },
- CancellationToken.None,
- TaskCreationOptions.None,
- _globalLogPageContext.Scheduler);
- }
-
- public static void SetHostHwnd(ulong hostHwnd) => _hostingHwnd = hostHwnd;
-
- public void DebugLog(string message)
- {
-#if DEBUG
- this.ProcessLogMessage(new LogMessage(message));
-#endif
- }
-
- public void Log(string message)
- {
- this.ProcessLogMessage(new LogMessage(message));
+ return Extension?.ExtensionDisplayName;
}
}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandPalettePageViewModelFactory.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandPalettePageViewModelFactory.cs
new file mode 100644
index 0000000000..90e70d7fef
--- /dev/null
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandPalettePageViewModelFactory.cs
@@ -0,0 +1,29 @@
+// 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.CmdPal.Core.ViewModels;
+using Microsoft.CommandPalette.Extensions;
+
+namespace Microsoft.CmdPal.UI.ViewModels;
+
+public class CommandPalettePageViewModelFactory
+ : IPageViewModelFactoryService
+{
+ private readonly TaskScheduler _scheduler;
+
+ public CommandPalettePageViewModelFactory(TaskScheduler scheduler)
+ {
+ _scheduler = scheduler;
+ }
+
+ public PageViewModel? TryCreatePageViewModel(IPage page, bool nested, AppExtensionHost host)
+ {
+ return page switch
+ {
+ IListPage listPage => new ListViewModel(listPage, _scheduler, host) { IsNested = nested },
+ IContentPage contentPage => new CommandPaletteContentPageViewModel(contentPage, _scheduler, host),
+ _ => null,
+ };
+ }
+}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandProviderWrapper.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandProviderWrapper.cs
index 302fe448ab..852babe4b7 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandProviderWrapper.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandProviderWrapper.cs
@@ -4,7 +4,8 @@
using ManagedCommon;
using Microsoft.CmdPal.Common.Services;
-using Microsoft.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
using Microsoft.Extensions.DependencyInjection;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandSettingsViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandSettingsViewModel.cs
index f6cc2cd5a9..a23cb4621e 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandSettingsViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandSettingsViewModel.cs
@@ -3,10 +3,11 @@
// See the LICENSE file in the project root for more information.
using ManagedCommon;
-using Microsoft.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels.Models;
+using Microsoft.CmdPal.UI.ViewModels;
using Microsoft.CommandPalette.Extensions;
-namespace Microsoft.CmdPal.UI.ViewModels;
+namespace Microsoft.CmdPal.Core.ViewModels;
public partial class CommandSettingsViewModel(ICommandSettings? _unsafeSettings, CommandProviderWrapper provider, TaskScheduler mainThread)
{
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/BuiltInsCommandProvider.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/BuiltInsCommandProvider.cs
index 9552e108ef..3a3a9bd405 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/BuiltInsCommandProvider.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/BuiltInsCommandProvider.cs
@@ -2,7 +2,7 @@
// 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.CmdPal.UI.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/BuiltinsExtensionHost.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/BuiltinsExtensionHost.cs
index f643f0fc84..9b8bd8ed48 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/BuiltinsExtensionHost.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/BuiltinsExtensionHost.cs
@@ -2,15 +2,7 @@
// 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.Diagnostics.CodeAnalysis;
-using System.IO.Compression;
-using System.Text.Json;
-using System.Text.Json.Nodes;
using Microsoft.CmdPal.Common;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
-using Microsoft.CommandPalette.Extensions;
-using Microsoft.CommandPalette.Extensions.Toolkit;
-using Windows.Foundation;
namespace Microsoft.CmdPal.UI.ViewModels.BuiltinCommands;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/LogMessagesPage.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/LogMessagesPage.cs
index e0be3beb90..acb04889fb 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/LogMessagesPage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/LogMessagesPage.cs
@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Specialized;
+using Microsoft.CmdPal.Core.ViewModels;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
@@ -10,7 +11,7 @@ namespace Microsoft.CmdPal.UI.ViewModels.Commands;
public partial class LogMessagesPage : ListPage
{
- private readonly List _listItems = new();
+ private readonly List _listItems = [];
public LogMessagesPage()
{
@@ -31,7 +32,6 @@ public partial class LogMessagesPage : ListPage
var li = new ListItem(new NoOpCommand())
{
Title = logMessageViewModel.Message,
- Subtitle = logMessageViewModel.ExtensionPfn,
};
_listItems.Insert(0, li);
}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs
index 04277083ef..5be7c872c3 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs
@@ -6,8 +6,8 @@ using System.Collections.Immutable;
using System.Collections.Specialized;
using CommunityToolkit.Mvvm.Messaging;
using ManagedCommon;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
using Microsoft.CmdPal.Ext.Apps;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
using Microsoft.Extensions.DependencyInjection;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/NewExtensionFormBase.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/NewExtensionFormBase.cs
index e68fef10a4..5a68c2a2cf 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/NewExtensionFormBase.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/NewExtensionFormBase.cs
@@ -6,7 +6,7 @@ using System.Diagnostics.CodeAnalysis;
using System.IO.Compression;
using System.Text.Json;
using System.Text.Json.Nodes;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
using Windows.Foundation;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/OpenSettingsCommand.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/OpenSettingsCommand.cs
index 91d6d3c9e3..a5af351fd4 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/OpenSettingsCommand.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/OpenSettingsCommand.cs
@@ -3,7 +3,7 @@
// See the LICENSE file in the project root for more information.
using CommunityToolkit.Mvvm.Messaging;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/QuitAction.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/QuitAction.cs
index bd3cee3159..313685f6f2 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/QuitAction.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/QuitAction.cs
@@ -3,7 +3,7 @@
// See the LICENSE file in the project root for more information.
using CommunityToolkit.Mvvm.Messaging;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/ReloadExtensionsCommand.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/ReloadExtensionsCommand.cs
index c2fb9f916b..77efb05a73 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/ReloadExtensionsCommand.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/ReloadExtensionsCommand.cs
@@ -3,7 +3,7 @@
// See the LICENSE file in the project root for more information.
using CommunityToolkit.Mvvm.Messaging;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentFormViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentFormViewModel.cs
index 5477242a32..d561a0e00f 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentFormViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentFormViewModel.cs
@@ -7,8 +7,9 @@ using AdaptiveCards.ObjectModel.WinUI3;
using AdaptiveCards.Templating;
using CommunityToolkit.Mvvm.Messaging;
using ManagedCommon;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
-using Microsoft.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
using Windows.Data.Json;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentMarkdownViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentMarkdownViewModel.cs
index c8508e414a..8ae0935f12 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentMarkdownViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentMarkdownViewModel.cs
@@ -2,7 +2,8 @@
// 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.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
namespace Microsoft.CmdPal.UI.ViewModels;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentTreeViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentTreeViewModel.cs
index 77734921aa..6368f86ac6 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentTreeViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentTreeViewModel.cs
@@ -3,7 +3,8 @@
// See the LICENSE file in the project root for more information.
using System.Collections.ObjectModel;
-using Microsoft.CmdPal.UI.ViewModels.Models;
+using Microsoft.CmdPal.Core.ViewModels;
+using Microsoft.CmdPal.Core.ViewModels.Models;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
@@ -37,7 +38,7 @@ public partial class ContentTreeViewModel(ITreeContent _tree, WeakReference context)
+ {
+ ContentViewModel? viewModel = content switch
+ {
+ IFormContent form => new ContentFormViewModel(form, context),
+ IMarkdownContent markdown => new ContentMarkdownViewModel(markdown, context),
+ ITreeContent tree => new ContentTreeViewModel(tree, context),
+ _ => null,
+ };
+ return viewModel;
+ }
+
// TODO: Does this need to hop to a _different_ thread, so that we don't block the extension while we're fetching?
private void Model_ItemsChanged(object sender, IItemsChangedEventArgs args) => FetchContent();
@@ -78,7 +93,7 @@ public partial class ContentTreeViewModel(ITreeContent _tree, WeakReference
+
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionWrapper.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionWrapper.cs
index 5b4eee44ef..5cab466b6f 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionWrapper.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionWrapper.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft Corporation
+// 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.
@@ -12,7 +12,6 @@ using Windows.Win32;
using Windows.Win32.System.Com;
using WinRT;
-// [assembly: System.Runtime.CompilerServices.DisableRuntimeMarshalling]
namespace Microsoft.CmdPal.UI.ViewModels.Models;
public class ExtensionWrapper : IExtensionWrapper
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ProviderSettingsViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ProviderSettingsViewModel.cs
index 61bb7f946d..3c8e402364 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ProviderSettingsViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ProviderSettingsViewModel.cs
@@ -6,7 +6,8 @@ using System.Diagnostics.CodeAnalysis;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.CmdPal.Common.Services;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
using Microsoft.CmdPal.UI.ViewModels.Properties;
using Microsoft.Extensions.DependencyInjection;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs
index 752ca0e38e..b4f6542c93 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs
@@ -10,7 +10,8 @@ using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using ManagedCommon;
using Microsoft.CmdPal.Common.Services;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
using Microsoft.Extensions.DependencyInjection;
@@ -104,14 +105,14 @@ public partial class TopLevelCommandManager : ObservableObject,
List commands = [];
foreach (var item in commandProvider.TopLevelItems)
{
- TopLevelCommands.Add(item);
+ commands.Add(item);
}
foreach (var item in commandProvider.FallbackItems)
{
if (item.IsEnabled)
{
- TopLevelCommands.Add(item);
+ commands.Add(item);
}
}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelViewModel.cs
index 16704e6cf7..dabfdca3f6 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelViewModel.cs
@@ -6,7 +6,8 @@ using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;
using ManagedCommon;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
using Microsoft.CmdPal.UI.ViewModels.Settings;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
@@ -254,7 +255,7 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
private void UpdateTags()
{
- List tags = new();
+ List tags = [];
if (Hotkey != null)
{
@@ -341,4 +342,9 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
return false;
}
+
+ public PerformCommandMessage GetPerformCommandMessage()
+ {
+ return new PerformCommandMessage(this.CommandViewModel.Model, new Core.ViewModels.Models.ExtensionObject(this));
+ }
}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml.cs
index a9f416483a..36c742ba7f 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml.cs
@@ -5,6 +5,7 @@
using ManagedCommon;
using Microsoft.CmdPal.Common.Helpers;
using Microsoft.CmdPal.Common.Services;
+using Microsoft.CmdPal.Core.ViewModels;
using Microsoft.CmdPal.Ext.Apps;
using Microsoft.CmdPal.Ext.Bookmarks;
using Microsoft.CmdPal.Ext.Calc;
@@ -145,10 +146,12 @@ public partial class App : Application
services.AddSingleton();
services.AddSingleton();
+ services.AddSingleton();
services.AddSingleton(new TelemetryForwarder());
// ViewModels
services.AddSingleton();
+ services.AddSingleton();
return services.BuildServiceProvider();
}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/CommandBar.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/CommandBar.xaml
index 1bbd0ab619..0edcf04a9c 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/CommandBar.xaml
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/CommandBar.xaml
@@ -6,6 +6,7 @@
xmlns:animations="using:CommunityToolkit.WinUI.Animations"
xmlns:cmdpalUI="using:Microsoft.CmdPal.UI"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
+ xmlns:coreViewModels="using:Microsoft.CmdPal.Core.ViewModels"
xmlns:cpcontrols="using:Microsoft.CmdPal.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:help="using:Microsoft.CmdPal.UI.Helpers"
@@ -87,7 +88,7 @@
ItemsSource="{x:Bind CurrentPageViewModel.StatusMessages, Mode=OneWay}"
Layout="{StaticResource VerticalStackLayout}">
-
+
+
-
+
@@ -42,9 +44,18 @@
SourceKey="{x:Bind Icon}"
SourceRequested="{x:Bind help:IconCacheProvider.SourceRequested}" />
+ Text="{x:Bind Title}"
+ TextTrimming="WordEllipsis"
+ TextWrapping="NoWrap">
+
+
+
+
-
+
@@ -73,10 +84,19 @@
SourceKey="{x:Bind Icon}"
SourceRequested="{x:Bind help:IconCacheProvider.SourceRequested}" />
+ Text="{x:Bind Title}"
+ TextTrimming="WordEllipsis"
+ TextWrapping="NoWrap">
+
+
+
+
-
+
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ContextMenu.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ContextMenu.xaml.cs
index f08e8347c5..8047cd52a3 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ContextMenu.xaml.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ContextMenu.xaml.cs
@@ -2,17 +2,12 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;
-using CommunityToolkit.WinUI;
-using Microsoft.CmdPal.Ext.System;
-using Microsoft.CmdPal.UI.ViewModels;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
-using Microsoft.CmdPal.UI.Views;
+using Microsoft.CmdPal.Core.ViewModels;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
using Microsoft.UI.Input;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
-using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Input;
using Windows.System;
using Windows.UI.Core;
@@ -183,34 +178,97 @@ public sealed partial class ContextMenu : UserControl,
{
if (e.Key == VirtualKey.Up)
{
- // navigate previous
- if (CommandsDropdown.SelectedIndex > 0)
- {
- CommandsDropdown.SelectedIndex--;
- }
- else
- {
- CommandsDropdown.SelectedIndex = CommandsDropdown.Items.Count - 1;
- }
+ NavigateUp();
e.Handled = true;
}
else if (e.Key == VirtualKey.Down)
{
- // navigate next
- if (CommandsDropdown.SelectedIndex < CommandsDropdown.Items.Count - 1)
- {
- CommandsDropdown.SelectedIndex++;
- }
- else
- {
- CommandsDropdown.SelectedIndex = 0;
- }
+ NavigateDown();
e.Handled = true;
}
}
+ private void NavigateUp()
+ {
+ var newIndex = CommandsDropdown.SelectedIndex;
+
+ if (CommandsDropdown.SelectedIndex > 0)
+ {
+ newIndex--;
+
+ while (
+ newIndex >= 0 &&
+ IsSeparator(CommandsDropdown.Items[newIndex]) &&
+ newIndex != CommandsDropdown.SelectedIndex)
+ {
+ newIndex--;
+ }
+
+ if (newIndex < 0)
+ {
+ newIndex = CommandsDropdown.Items.Count - 1;
+
+ while (
+ newIndex >= 0 &&
+ IsSeparator(CommandsDropdown.Items[newIndex]) &&
+ newIndex != CommandsDropdown.SelectedIndex)
+ {
+ newIndex--;
+ }
+ }
+ }
+ else
+ {
+ newIndex = CommandsDropdown.Items.Count - 1;
+ }
+
+ CommandsDropdown.SelectedIndex = newIndex;
+ }
+
+ private void NavigateDown()
+ {
+ var newIndex = CommandsDropdown.SelectedIndex;
+
+ if (CommandsDropdown.SelectedIndex == CommandsDropdown.Items.Count - 1)
+ {
+ newIndex = 0;
+ }
+ else
+ {
+ newIndex++;
+
+ while (
+ newIndex < CommandsDropdown.Items.Count &&
+ IsSeparator(CommandsDropdown.Items[newIndex]) &&
+ newIndex != CommandsDropdown.SelectedIndex)
+ {
+ newIndex++;
+ }
+
+ if (newIndex >= CommandsDropdown.Items.Count)
+ {
+ newIndex = 0;
+
+ while (
+ newIndex < CommandsDropdown.Items.Count &&
+ IsSeparator(CommandsDropdown.Items[newIndex]) &&
+ newIndex != CommandsDropdown.SelectedIndex)
+ {
+ newIndex++;
+ }
+ }
+ }
+
+ CommandsDropdown.SelectedIndex = newIndex;
+ }
+
+ private bool IsSeparator(object item)
+ {
+ return item is SeparatorContextItemViewModel;
+ }
+
private void UpdateUiForStackChange()
{
ContextFilterBox.Text = string.Empty;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/IconBox.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/IconBox.cs
index 34f0683440..c0a4e5a16c 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/IconBox.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/IconBox.cs
@@ -2,8 +2,8 @@
// 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.CmdPal.Core.ViewModels;
using Microsoft.CmdPal.UI.Deferred;
-using Microsoft.CmdPal.UI.ViewModels;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/SearchBar.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/SearchBar.xaml.cs
index cc8b600526..761c69d724 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/SearchBar.xaml.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/SearchBar.xaml.cs
@@ -5,8 +5,8 @@
using System.Diagnostics;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.WinUI;
-using Microsoft.CmdPal.UI.ViewModels;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
using Microsoft.CmdPal.UI.Views;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Input;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/ShortcutDialogContentControl.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/ShortcutDialogContentControl.xaml
index 7932a27e91..56ae0bfca6 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/ShortcutDialogContentControl.xaml
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/ShortcutDialogContentControl.xaml
@@ -4,8 +4,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.CmdPal.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:labToolkit="using:CommunityToolkit.Labs.WinUI.MarkdownTextBlock"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:tk7controls="using:CommunityToolkit.WinUI.UI.Controls"
x:Name="ShortcutContentControl"
mc:Ignorable="d">
@@ -66,7 +66,7 @@
IsTabStop="{Binding ElementName=ShortcutContentControl, Path=IsWarningAltGr, Mode=OneWay}"
Severity="Warning" />
-
@@ -36,7 +36,7 @@
-
+
+
+
-
@@ -61,12 +67,9 @@
-
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/ContentPage.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/ContentPage.xaml.cs
index 1b53a41339..55887f155d 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/ContentPage.xaml.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/ContentPage.xaml.cs
@@ -3,8 +3,8 @@
// See the LICENSE file in the project root for more information.
using CommunityToolkit.Mvvm.Messaging;
-using Microsoft.CmdPal.UI.ViewModels;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
+using Microsoft.CmdPal.Core.ViewModels;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/ListPage.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/ListPage.xaml
index 63f1e0e165..0a43d25bd3 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/ListPage.xaml
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/ListPage.xaml
@@ -5,6 +5,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
+ xmlns:coreViewModels="using:Microsoft.CmdPal.Core.ViewModels"
xmlns:cpcontrols="using:Microsoft.CmdPal.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:help="using:Microsoft.CmdPal.UI.Helpers"
@@ -27,7 +28,7 @@
EmptyValue="Collapsed"
NotEmptyValue="Visible" />
-
+
-
+
+
@@ -23,6 +24,13 @@
false
+
+ true
+ false
+ false
+ true
+
+
true
@@ -71,7 +79,7 @@
-
+
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt b/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt
index 165933fe93..a432d9a808 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt
@@ -22,7 +22,6 @@ SetActiveWindow
MonitorFromWindow
GetMonitorInfo
GetDpiForMonitor
-CoAllowSetForegroundWindow
WM_HOTKEY
WM_NCLBUTTONDBLCLK
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/LoadingPage.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/LoadingPage.xaml.cs
index 66eff31c8a..ed234c4d54 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/LoadingPage.xaml.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/LoadingPage.xaml.cs
@@ -2,7 +2,7 @@
// 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.CmdPal.UI.ViewModels;
+using Microsoft.CmdPal.Core.ViewModels;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Navigation;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml
index 63877834e9..21734922c0 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml
@@ -6,11 +6,14 @@
xmlns:animations="using:CommunityToolkit.WinUI.Animations"
xmlns:cmdpalUI="using:Microsoft.CmdPal.UI"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
+ xmlns:coreViewModels="using:Microsoft.CmdPal.Core.ViewModels"
xmlns:cpcontrols="using:Microsoft.CmdPal.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:help="using:Microsoft.CmdPal.UI.Helpers"
+ xmlns:labToolkit="using:CommunityToolkit.Labs.WinUI.MarkdownTextBlock"
+ xmlns:markdownTextBlockRns="using:CommunityToolkit.WinUI.Controls.MarkdownTextBlockRns"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:toolkit="using:CommunityToolkit.WinUI.UI.Controls"
+ xmlns:toolkit="using:CommunityToolkit.WinUI.Controls"
xmlns:ui="using:CommunityToolkit.WinUI"
xmlns:viewModels="using:Microsoft.CmdPal.UI.ViewModels"
Background="Transparent"
@@ -39,7 +42,7 @@
FalseValue="Visible"
TrueValue="Collapsed" />
-
+
-
+
-
+
-
+
-
+
-
+
+
+
@@ -406,14 +414,11 @@
TextWrapping="WrapWholeWords"
Visibility="{x:Bind ViewModel.Details.Title, Converter={StaticResource StringNotEmptyToVisibilityConverter}, Mode=OneWay}" />
-
(new(message.Hwnd));
}
- var msg = new PerformCommandMessage(topLevelCommand) { WithAnimation = false };
+ var msg = topLevelCommand.GetPerformCommandMessage();
+ msg.WithAnimation = false;
WeakReferenceMessenger.Default.Send(msg);
// we can't necessarily SelectSearch() here, because when the page is loaded,
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/PowerToysAppHostService.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/PowerToysAppHostService.cs
new file mode 100644
index 0000000000..7edf0a34c9
--- /dev/null
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/PowerToysAppHostService.cs
@@ -0,0 +1,29 @@
+// 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.CmdPal.Core.ViewModels;
+using Microsoft.CmdPal.UI.ViewModels;
+
+// To learn more about WinUI, the WinUI project structure,
+// and more about our project templates, see: http://aka.ms/winui-project-info.
+namespace Microsoft.CmdPal.UI;
+
+internal sealed class PowerToysAppHostService : IAppHostService
+{
+ public AppExtensionHost GetDefaultHost()
+ {
+ return CommandPaletteHost.Instance;
+ }
+
+ public AppExtensionHost GetHostForCommand(object? context, AppExtensionHost? currentHost)
+ {
+ AppExtensionHost? topLevelHost = null;
+ if (context is TopLevelViewModel topLevelViewModel)
+ {
+ topLevelHost = topLevelViewModel.ExtensionHost;
+ }
+
+ return topLevelHost ?? currentHost ?? CommandPaletteHost.Instance;
+ }
+}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/PowerToysRootPageService.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/PowerToysRootPageService.cs
index 61d6d1f203..60bd5e9360 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/PowerToysRootPageService.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/PowerToysRootPageService.cs
@@ -2,12 +2,16 @@
// 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.Runtime.InteropServices;
+using System.Runtime.Versioning;
using ManagedCommon;
using Microsoft.CmdPal.Common.Services;
+using Microsoft.CmdPal.Core.ViewModels;
using Microsoft.CmdPal.UI.ViewModels;
using Microsoft.CmdPal.UI.ViewModels.MainPage;
using Microsoft.CommandPalette.Extensions;
using Microsoft.Extensions.DependencyInjection;
+using WinRT;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
@@ -16,6 +20,7 @@ namespace Microsoft.CmdPal.UI;
internal sealed class PowerToysRootPageService : IRootPageService
{
private readonly IServiceProvider _serviceProvider;
+ private IExtensionWrapper? _activeExtension;
private Lazy _mainListPage;
public PowerToysRootPageService(IServiceProvider serviceProvider)
@@ -53,7 +58,7 @@ internal sealed class PowerToysRootPageService : IRootPageService
}
}
- public void OnPerformTopLevelCommand(object? context)
+ private void OnPerformTopLevelCommand(object? context)
{
try
{
@@ -68,4 +73,72 @@ internal sealed class PowerToysRootPageService : IRootPageService
Logger.LogError(ex.ToString());
}
}
+
+ public void OnPerformCommand(object? context, bool topLevel, AppExtensionHost? currentHost)
+ {
+ if (topLevel)
+ {
+ OnPerformTopLevelCommand(context);
+ }
+
+ if (currentHost is CommandPaletteHost host)
+ {
+ SetActiveExtension(host.Extension);
+ }
+ else
+ {
+ throw new InvalidOperationException("This must be a programming error - everything in Command Palette should have a CommandPaletteHost");
+ }
+ }
+
+ public void SetActiveExtension(IExtensionWrapper? extension)
+ {
+ if (extension != _activeExtension)
+ {
+ // There's not really a CoDisallowSetForegroundWindow, so we don't
+ // need to handle that
+ _activeExtension = extension;
+
+ var extensionWinRtObject = _activeExtension?.GetExtensionObject();
+ if (extensionWinRtObject != null)
+ {
+ try
+ {
+ unsafe
+ {
+ var winrtObj = (IWinRTObject)extensionWinRtObject;
+ var intPtr = winrtObj.NativeObject.ThisPtr;
+ var hr = Native.CoAllowSetForegroundWindow(intPtr);
+ if (hr != 0)
+ {
+ Logger.LogWarning($"Error giving foreground rights: 0x{hr.Value:X8}");
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Logger.LogError(ex.ToString());
+ }
+ }
+ }
+ }
+
+ public void GoHome()
+ {
+ SetActiveExtension(null);
+ }
+
+ // You may ask yourself, why aren't we using CsWin32 for this?
+ // The CsWin32 projected version includes some object marshalling, like so:
+ //
+ // HRESULT CoAllowSetForegroundWindow([MarshalAs(UnmanagedType.IUnknown)] object pUnk,...)
+ //
+ // And if you do it like that, then the IForegroundTransfer interface isn't marshalled correctly
+ internal sealed class Native
+ {
+ [DllImport("OLE32.dll", ExactSpelling = true)]
+ [DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
+ [SupportedOSPlatform("windows5.0")]
+ internal static extern unsafe global::Windows.Win32.Foundation.HRESULT CoAllowSetForegroundWindow(nint pUnk, [Optional] void* lpvReserved);
+ }
}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Properties/PublishProfiles/win-arm64.pubxml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Properties/PublishProfiles/win-arm64.pubxml
index b95afb7240..adf22122d9 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Properties/PublishProfiles/win-arm64.pubxml
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Properties/PublishProfiles/win-arm64.pubxml
@@ -13,7 +13,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
False
False
True
- False
- False
+ True
+ False
\ No newline at end of file
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Properties/PublishProfiles/win-x64.pubxml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Properties/PublishProfiles/win-x64.pubxml
index 5ff16b291b..7f6d14d1ad 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Properties/PublishProfiles/win-x64.pubxml
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Properties/PublishProfiles/win-x64.pubxml
@@ -13,7 +13,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
False
False
True
- False
- False
+ True
+ False
\ No newline at end of file
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/SettingsWindow.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/SettingsWindow.xaml.cs
index 770f3b5367..a13782478a 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/SettingsWindow.xaml.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/SettingsWindow.xaml.cs
@@ -4,13 +4,12 @@
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.Messaging;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
using Microsoft.CmdPal.UI.Helpers;
using Microsoft.CmdPal.UI.ViewModels;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
-using Windows.Graphics;
using WinUIEx;
using RS_ = Microsoft.CmdPal.UI.Helpers.ResourceLoaderInstance;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/ToastWindow.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/ToastWindow.xaml.cs
index 478f565f35..6b38020e22 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/ToastWindow.xaml.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/ToastWindow.xaml.cs
@@ -5,13 +5,11 @@
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.WinUI;
using ManagedCommon;
+using Microsoft.CmdPal.Core.ViewModels;
+using Microsoft.CmdPal.Core.ViewModels.Messages;
using Microsoft.CmdPal.UI.Helpers;
-using Microsoft.CmdPal.UI.ViewModels;
-using Microsoft.CmdPal.UI.ViewModels.Messages;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Windowing;
-using Microsoft.UI.Xaml;
-using Windows.Graphics;
using Windows.Win32;
using Windows.Win32.Foundation;
using Windows.Win32.Graphics.Gdi;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Views/ICurrentPageAware.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Views/ICurrentPageAware.cs
index 2aa93bafb3..a66a397e42 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Views/ICurrentPageAware.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Views/ICurrentPageAware.cs
@@ -2,11 +2,11 @@
// 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.CmdPal.UI.ViewModels;
+using Microsoft.CmdPal.Core.ViewModels;
namespace Microsoft.CmdPal.UI.Views;
public interface ICurrentPageAware
{
- public PageViewModel? CurrentPageViewModel { get; set; }
+ PageViewModel? CurrentPageViewModel { get; set; }
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AllAppsCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AllAppsCommandProvider.cs
index e62fc71e2b..3dadba9749 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AllAppsCommandProvider.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AllAppsCommandProvider.cs
@@ -2,8 +2,12 @@
// 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;
+using System.Collections.Generic;
using System.Linq;
+using Microsoft.CmdPal.Ext.Apps.Programs;
using Microsoft.CmdPal.Ext.Apps.Properties;
+using Microsoft.CmdPal.Ext.Apps.State;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
@@ -21,7 +25,7 @@ public partial class AllAppsCommandProvider : CommandProvider
{
Id = WellKnownId;
DisplayName = Resources.installed_apps;
- Icon = IconHelpers.FromRelativePath("Assets\\AllApps.svg");
+ Icon = Icons.AllAppsIcon;
Settings = AllAppsSettings.Instance.Settings;
_listItem = new(Page)
@@ -29,9 +33,12 @@ public partial class AllAppsCommandProvider : CommandProvider
Subtitle = Resources.search_installed_apps,
MoreCommands = [new CommandContextItem(AllAppsSettings.Instance.Settings.SettingsPage)],
};
+
+ // Subscribe to pin state changes to refresh the command provider
+ PinnedAppsManager.Instance.PinStateChanged += OnPinStateChanged;
}
- public override ICommandItem[] TopLevelCommands() => [_listItem];
+ public override ICommandItem[] TopLevelCommands() => [_listItem, ..Page.GetPinnedApps()];
public ICommandItem? LookupApp(string displayName)
{
@@ -62,4 +69,9 @@ public partial class AllAppsCommandProvider : CommandProvider
return null;
}
+
+ private void OnPinStateChanged(object? sender, System.EventArgs e)
+ {
+ RaiseItemsChanged(0);
+ }
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AllAppsPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AllAppsPage.cs
index f271d4d556..4c8b5baedc 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AllAppsPage.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AllAppsPage.cs
@@ -2,14 +2,19 @@
// 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;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
+using System.Numerics;
+using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using ManagedCommon;
+using Microsoft.CmdPal.Ext.Apps.Commands;
using Microsoft.CmdPal.Ext.Apps.Programs;
using Microsoft.CmdPal.Ext.Apps.Properties;
+using Microsoft.CmdPal.Ext.Apps.State;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
@@ -18,16 +23,22 @@ namespace Microsoft.CmdPal.Ext.Apps;
public sealed partial class AllAppsPage : ListPage
{
private readonly Lock _listLock = new();
- private AppListItem[] allAppsSection = [];
+
+ private AppItem[] allApps = [];
+ private AppListItem[] unpinnedApps = [];
+ private AppListItem[] pinnedApps = [];
public AllAppsPage()
{
this.Name = Resources.all_apps;
- this.Icon = IconHelpers.FromRelativePath("Assets\\AllApps.svg");
+ this.Icon = Icons.AllAppsIcon;
this.ShowDetails = true;
this.IsLoading = true;
this.PlaceholderText = Resources.search_installed_apps_placeholder;
+ // Subscribe to pin state changes to refresh the command provider
+ PinnedAppsManager.Instance.PinStateChanged += OnPinStateChanged;
+
Task.Run(() =>
{
lock (_listLock)
@@ -37,89 +48,139 @@ public sealed partial class AllAppsPage : ListPage
});
}
+ internal AppListItem[] GetPinnedApps()
+ {
+ BuildListItems();
+ return pinnedApps;
+ }
+
public override IListItem[] GetItems()
{
- if (allAppsSection.Length == 0 || AppCache.Instance.Value.ShouldReload())
- {
- lock (_listLock)
- {
- BuildListItems();
- }
- }
-
- return allAppsSection;
+ // Build or update the list if needed
+ BuildListItems();
+ return pinnedApps.Concat(unpinnedApps).ToArray();
}
private void BuildListItems()
{
- this.IsLoading = true;
+ if (allApps.Length == 0 || AppCache.Instance.Value.ShouldReload())
+ {
+ lock (_listLock)
+ {
+ this.IsLoading = true;
- Stopwatch stopwatch = new();
- stopwatch.Start();
+ Stopwatch stopwatch = new();
+ stopwatch.Start();
- var apps = GetPrograms();
+ var apps = GetPrograms();
+ this.allApps = apps.AllApps;
+ this.pinnedApps = apps.PinnedItems;
+ this.unpinnedApps = apps.UnpinnedItems;
- this.allAppsSection = apps
- .Select((app) => new AppListItem(app, true))
- .ToArray();
+ this.IsLoading = false;
- this.IsLoading = false;
+ AppCache.Instance.Value.ResetReloadFlag();
- AppCache.Instance.Value.ResetReloadFlag();
-
- stopwatch.Stop();
- Logger.LogTrace($"{nameof(AllAppsPage)}.{nameof(BuildListItems)} took: {stopwatch.ElapsedMilliseconds} ms");
+ stopwatch.Stop();
+ Logger.LogTrace($"{nameof(AllAppsPage)}.{nameof(BuildListItems)} took: {stopwatch.ElapsedMilliseconds} ms");
+ }
+ }
}
- internal List GetPrograms()
+ private AppItem[] GetAllApps()
{
var uwpResults = AppCache.Instance.Value.UWPs
- .Where((application) => application.Enabled)
- .Select(UwpToAppItem);
+ .Where((application) => application.Enabled)
+ .Select(app => app.ToAppItem());
var win32Results = AppCache.Instance.Value.Win32s
.Where((application) => application.Enabled && application.Valid)
- .Select(app =>
- {
- var icoPath = string.IsNullOrEmpty(app.IcoPath) ?
- (app.AppType == Win32Program.ApplicationType.InternetShortcutApplication ?
- app.IcoPath :
- app.FullPath) :
- app.IcoPath;
+ .Select(app => app.ToAppItem());
- // icoPath = icoPath.EndsWith(".lnk", System.StringComparison.InvariantCultureIgnoreCase) ? (icoPath + ",0") : icoPath;
- icoPath = icoPath.EndsWith(".lnk", System.StringComparison.InvariantCultureIgnoreCase) ?
- app.FullPath :
- icoPath;
- return new AppItem()
- {
- Name = app.Name,
- Subtitle = app.Description,
- Type = app.Type(),
- IcoPath = icoPath,
- ExePath = !string.IsNullOrEmpty(app.LnkFilePath) ? app.LnkFilePath : app.FullPath,
- DirPath = app.Location,
- Commands = app.GetCommands(),
- };
- });
-
- return uwpResults.Concat(win32Results).OrderBy(app => app.Name).ToList();
+ var allApps = uwpResults.Concat(win32Results).ToArray();
+ return allApps;
}
- private AppItem UwpToAppItem(UWPApplication app)
+ internal (AppItem[] AllApps, AppListItem[] PinnedItems, AppListItem[] UnpinnedItems) GetPrograms()
{
- var iconPath = app.LogoType != LogoType.Error ? app.LogoPath : string.Empty;
- var item = new AppItem()
+ var allApps = GetAllApps();
+ var pinned = new List();
+ var unpinned = new List();
+
+ foreach (var app in allApps)
{
- Name = app.Name,
- Subtitle = app.Description,
- Type = UWPApplication.Type(),
- IcoPath = iconPath,
- DirPath = app.Location,
- UserModelId = app.UserModelId,
- IsPackaged = true,
- Commands = app.GetCommands(),
- };
- return item;
+ var isPinned = PinnedAppsManager.Instance.IsAppPinned(app.AppIdentifier);
+ var appListItem = new AppListItem(app, true, isPinned);
+
+ if (isPinned)
+ {
+ appListItem.Tags = appListItem.Tags
+ .Concat([new Tag() { Icon = Icons.PinIcon }])
+ .ToArray();
+ pinned.Add(appListItem);
+ }
+ else
+ {
+ unpinned.Add(appListItem);
+ }
+ }
+
+ return (
+ allApps
+ .ToArray(),
+ pinned
+ .OrderBy(app => app.Title)
+ .ToArray(),
+ unpinned
+ .OrderBy(app => app.Title)
+ .ToArray());
+ }
+
+ private void OnPinStateChanged(object? sender, PinStateChangedEventArgs e)
+ {
+ /*
+ * Rebuilding all the lists is pretty expensive.
+ * So, instead, we'll just compare pinned items to move existing
+ * items between the two lists.
+ */
+ var existingAppItem = allApps.FirstOrDefault(f => f.AppIdentifier == e.AppIdentifier);
+
+ if (existingAppItem != null)
+ {
+ var appListItem = new AppListItem(existingAppItem, true, e.IsPinned);
+
+ if (e.IsPinned)
+ {
+ // Remove it from the unpinned apps array
+ this.unpinnedApps = this.unpinnedApps
+ .Where(app => app.AppIdentifier != existingAppItem.AppIdentifier)
+ .OrderBy(app => app.Title)
+ .ToArray();
+
+ var newPinned = this.pinnedApps.ToList();
+ newPinned.Add(appListItem);
+
+ this.pinnedApps = newPinned
+ .OrderBy(app => app.Title)
+ .ToArray();
+ }
+ else
+ {
+ // Remove it from the pinned apps array
+ this.pinnedApps = this.pinnedApps
+ .Where(app => app.AppIdentifier != existingAppItem.AppIdentifier)
+ .OrderBy(app => app.Title)
+ .ToArray();
+
+ var newUnpinned = this.unpinnedApps.ToList();
+ newUnpinned.Add(appListItem);
+
+ this.unpinnedApps = newUnpinned
+ .OrderBy(app => app.Title)
+ .ToArray();
+ }
+
+ RaiseItemsChanged(0);
+ }
}
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppItem.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppItem.cs
index 4bb26bed67..2e5ba78b1f 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppItem.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppItem.cs
@@ -4,6 +4,7 @@
using System.Collections.Generic;
using Microsoft.CmdPal.Ext.Apps.Programs;
+using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
namespace Microsoft.CmdPal.Ext.Apps;
@@ -26,7 +27,9 @@ internal sealed class AppItem
public bool IsPackaged { get; set; }
- public List? Commands { get; set; }
+ public List? Commands { get; set; }
+
+ public string AppIdentifier { get; set; } = string.Empty;
public AppItem()
{
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppListItem.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppListItem.cs
index 57c9175d4d..4ac8f79aea 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppListItem.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppListItem.cs
@@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
+using Microsoft.CmdPal.Ext.Apps.Commands;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
using Windows.Storage.Streams;
@@ -23,14 +24,17 @@ internal sealed partial class AppListItem : ListItem
public override IIconInfo? Icon { get => _icon.Value; set => base.Icon = value; }
- public AppListItem(AppItem app, bool useThumbnails)
+ public string AppIdentifier => _app.AppIdentifier;
+
+ public AppListItem(AppItem app, bool useThumbnails, bool isPinned)
: base(new AppCommand(app))
{
_app = app;
Title = app.Name;
Subtitle = app.Subtitle;
Tags = [_appTag];
- MoreCommands = _app.Commands!.ToArray();
+
+ MoreCommands = AddPinCommands(_app.Commands!, isPinned);
_details = new Lazy(() =>
{
@@ -121,4 +125,37 @@ internal sealed partial class AppListItem : ListItem
return icon;
}
+
+ private IContextItem[] AddPinCommands(List commands, bool isPinned)
+ {
+ var newCommands = new List();
+ newCommands.AddRange(commands);
+
+ newCommands.Add(new SeparatorContextItem());
+
+ // 0x50 = P
+ // Full key chord would be Ctrl+P
+ var pinKeyChord = KeyChordHelpers.FromModifiers(true, false, false, false, 0x50, 0);
+
+ if (isPinned)
+ {
+ newCommands.Add(
+ new CommandContextItem(
+ new UnpinAppCommand(this.AppIdentifier))
+ {
+ RequestedShortcut = pinKeyChord,
+ });
+ }
+ else
+ {
+ newCommands.Add(
+ new CommandContextItem(
+ new PinAppCommand(this.AppIdentifier))
+ {
+ RequestedShortcut = pinKeyChord,
+ });
+ }
+
+ return newCommands.ToArray();
+ }
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/CopyPathCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/CopyPathCommand.cs
index 30ad044f37..9fca0304aa 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/CopyPathCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/CopyPathCommand.cs
@@ -13,14 +13,12 @@ namespace Microsoft.CmdPal.Ext.Apps.Commands;
internal sealed partial class CopyPathCommand : InvokableCommand
{
- private static readonly IconInfo TheIcon = new("\ue8c8");
-
private readonly string _target;
public CopyPathCommand(string target)
{
Name = Resources.copy_path;
- Icon = TheIcon;
+ Icon = Icons.CopyIcon;
_target = target;
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/OpenInConsoleCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/OpenInConsoleCommand.cs
index 41e934759a..2bb8d421d4 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/OpenInConsoleCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/OpenInConsoleCommand.cs
@@ -13,14 +13,12 @@ namespace Microsoft.CmdPal.Ext.Apps.Commands;
internal sealed partial class OpenInConsoleCommand : InvokableCommand
{
- private static readonly IconInfo TheIcon = new("\ue838");
-
private readonly string _target;
public OpenInConsoleCommand(string target)
{
Name = Resources.open_path_in_console;
- Icon = TheIcon;
+ Icon = Icons.OpenPathIcon;
_target = target;
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/OpenPathCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/OpenPathCommand.cs
index 88c7df5d94..f4c8dde29e 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/OpenPathCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/OpenPathCommand.cs
@@ -11,14 +11,12 @@ namespace Microsoft.CmdPal.Ext.Apps.Commands;
internal sealed partial class OpenPathCommand : InvokableCommand
{
- private static readonly IconInfo TheIcon = new("\ue838");
-
private readonly string _target;
public OpenPathCommand(string target)
{
Name = Resources.open_location;
- Icon = TheIcon;
+ Icon = Icons.OpenPathIcon;
_target = target;
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/PinAppCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/PinAppCommand.cs
new file mode 100644
index 0000000000..8311e36cfc
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/PinAppCommand.cs
@@ -0,0 +1,28 @@
+// 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.Diagnostics.CodeAnalysis;
+using Microsoft.CmdPal.Ext.Apps.Properties;
+using Microsoft.CmdPal.Ext.Apps.State;
+using Microsoft.CommandPalette.Extensions.Toolkit;
+
+namespace Microsoft.CmdPal.Ext.Apps.Commands;
+
+internal sealed partial class PinAppCommand : InvokableCommand
+{
+ private readonly string _appIdentifier;
+
+ public PinAppCommand(string appIdentifier)
+ {
+ _appIdentifier = appIdentifier;
+ Name = Resources.pin_app;
+ Icon = Icons.PinIcon;
+ }
+
+ public override CommandResult Invoke()
+ {
+ PinnedAppsManager.Instance.PinApp(_appIdentifier);
+ return CommandResult.KeepOpen();
+ }
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/RunAsAdminCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/RunAsAdminCommand.cs
index 0a6d43f608..887f669454 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/RunAsAdminCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/RunAsAdminCommand.cs
@@ -13,8 +13,6 @@ namespace Microsoft.CmdPal.Ext.Apps.Commands;
internal sealed partial class RunAsAdminCommand : InvokableCommand
{
- private static readonly IconInfo TheIcon = new("\uE7EF");
-
private readonly string _target;
private readonly string _parentDir;
private readonly bool _packaged;
@@ -22,7 +20,7 @@ internal sealed partial class RunAsAdminCommand : InvokableCommand
public RunAsAdminCommand(string target, string parentDir, bool packaged)
{
Name = Resources.run_as_administrator;
- Icon = TheIcon;
+ Icon = Icons.RunAsAdminIcon;
_target = target;
_parentDir = parentDir;
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/RunAsUserCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/RunAsUserCommand.cs
index c897aed560..89e2d3e8ae 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/RunAsUserCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/RunAsUserCommand.cs
@@ -13,21 +13,19 @@ namespace Microsoft.CmdPal.Ext.Apps.Commands;
internal sealed partial class RunAsUserCommand : InvokableCommand
{
- private static readonly IconInfo TheIcon = new("\uE7EE");
-
private readonly string _target;
private readonly string _parentDir;
public RunAsUserCommand(string target, string parentDir)
{
Name = Resources.run_as_different_user;
- Icon = TheIcon;
+ Icon = Icons.RunAsUserIcon;
_target = target;
_parentDir = parentDir;
}
- internal static async Task RunAsAdmin(string target, string parentDir)
+ internal static async Task RunAsUser(string target, string parentDir)
{
await Task.Run(() =>
{
@@ -39,7 +37,7 @@ internal sealed partial class RunAsUserCommand : InvokableCommand
public override CommandResult Invoke()
{
- _ = RunAsAdmin(_target, _parentDir).ConfigureAwait(false);
+ _ = RunAsUser(_target, _parentDir).ConfigureAwait(false);
return CommandResult.Dismiss();
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/UnpinAppCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/UnpinAppCommand.cs
new file mode 100644
index 0000000000..fcba03f3d3
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/UnpinAppCommand.cs
@@ -0,0 +1,27 @@
+// 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.CmdPal.Ext.Apps.Properties;
+using Microsoft.CmdPal.Ext.Apps.State;
+using Microsoft.CommandPalette.Extensions.Toolkit;
+
+namespace Microsoft.CmdPal.Ext.Apps.Commands;
+
+internal sealed partial class UnpinAppCommand : InvokableCommand
+{
+ private readonly string _appIdentifier;
+
+ public UnpinAppCommand(string appIdentifier)
+ {
+ _appIdentifier = appIdentifier;
+ Name = Resources.unpin_app;
+ Icon = Icons.UnpinIcon;
+ }
+
+ public override CommandResult Invoke()
+ {
+ PinnedAppsManager.Instance.UnpinApp(_appIdentifier);
+ return CommandResult.KeepOpen();
+ }
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Icons.cs
new file mode 100644
index 0000000000..68f46bcee1
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Icons.cs
@@ -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.Apps;
+
+internal sealed class Icons
+{
+ internal static IconInfo AllAppsIcon => IconHelpers.FromRelativePath("Assets\\AllApps.svg");
+
+ internal static IconInfo RunAsUserIcon => new("\uE7EE"); // OtherUser icon
+
+ internal static IconInfo RunAsAdminIcon => new("\uE7EF"); // Admin icon
+
+ internal static IconInfo OpenPathIcon => new("\ue838"); // Folder Open icon
+
+ internal static IconInfo CopyIcon => new("\ue8c8"); // Copy icon
+
+ public static IconInfo UnpinIcon { get; } = new("\uE77A"); // Unpin icon
+
+ public static IconInfo PinIcon { get; } = new("\uE840"); // Pin icon
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/JsonSerializationContext.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/JsonSerializationContext.cs
new file mode 100644
index 0000000000..5a11d9c135
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/JsonSerializationContext.cs
@@ -0,0 +1,21 @@
+// 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;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.Json.Serialization;
+using System.Threading.Tasks;
+using Microsoft.CmdPal.Ext.Apps.State;
+
+namespace Microsoft.CmdPal.Ext.Apps;
+
+[JsonSerializable(typeof(string))]
+[JsonSerializable(typeof(PinnedApps))]
+[JsonSerializable(typeof(List), TypeInfoPropertyName = "StringList")]
+[JsonSourceGenerationOptions(UseStringEnumConverter = true, WriteIndented = true, IncludeFields = true, PropertyNameCaseInsensitive = true, AllowTrailingCommas = true)]
+internal sealed partial class JsonSerializationContext : JsonSerializerContext
+{
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWPApplication.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWPApplication.cs
index 1cf4bc4463..c5270b355c 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWPApplication.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWPApplication.cs
@@ -10,7 +10,9 @@ using System.Xml;
using ManagedCommon;
using Microsoft.CmdPal.Ext.Apps.Commands;
using Microsoft.CmdPal.Ext.Apps.Properties;
+using Microsoft.CmdPal.Ext.Apps.State;
using Microsoft.CmdPal.Ext.Apps.Utils;
+using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
using Windows.System;
using Windows.Win32;
@@ -70,9 +72,15 @@ public class UWPApplication : IProgram
return Resources.packaged_application;
}
- public List GetCommands()
+ public string GetAppIdentifier()
{
- List commands = [];
+ // Use UserModelId for UWP apps as it's unique
+ return UserModelId;
+ }
+
+ public List GetCommands()
+ {
+ List commands = [];
if (CanRunElevated)
{
@@ -98,7 +106,6 @@ public class UWPApplication : IProgram
new OpenPathCommand(Location)
{
Name = Resources.open_containing_folder,
- Icon = new("\ue838"),
})
{
RequestedShortcut = KeyChordHelpers.FromModifiers(ctrl: true, shift: true, vkey: VirtualKey.E),
@@ -511,6 +518,25 @@ public class UWPApplication : IProgram
}
}
+ internal AppItem ToAppItem()
+ {
+ var app = this;
+ var iconPath = app.LogoType != LogoType.Error ? app.LogoPath : string.Empty;
+ var item = new AppItem()
+ {
+ Name = app.Name,
+ Subtitle = app.Description,
+ Type = UWPApplication.Type(),
+ IcoPath = iconPath,
+ DirPath = app.Location,
+ UserModelId = app.UserModelId,
+ IsPackaged = true,
+ Commands = app.GetCommands(),
+ AppIdentifier = app.GetAppIdentifier(),
+ };
+ return item;
+ }
+
/*
public ImageSource Logo()
{
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/Win32Program.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/Win32Program.cs
index dd6bdd875d..d8bebcd9a4 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/Win32Program.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/Win32Program.cs
@@ -19,7 +19,9 @@ using System.Windows.Input;
using ManagedCommon;
using Microsoft.CmdPal.Ext.Apps.Commands;
using Microsoft.CmdPal.Ext.Apps.Properties;
+using Microsoft.CmdPal.Ext.Apps.State;
using Microsoft.CmdPal.Ext.Apps.Utils;
+using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
using Microsoft.Win32;
using Windows.System;
@@ -186,9 +188,9 @@ public class Win32Program : IProgram
return true;
}
- public List GetCommands()
+ public List GetCommands()
{
- List commands = new List();
+ List commands = new List();
if (AppType != ApplicationType.InternetShortcutApplication && AppType != ApplicationType.Folder && AppType != ApplicationType.GenericFile)
{
@@ -231,6 +233,12 @@ public class Win32Program : IProgram
return ExecutableName;
}
+ public string GetAppIdentifier()
+ {
+ // Use a combination of name and path to create a unique identifier
+ return $"{Name}|{FullPath}";
+ }
+
private static Win32Program CreateWin32Program(string path)
{
try
@@ -933,4 +941,29 @@ public class Win32Program : IProgram
return Array.Empty();
}
}
+
+ internal AppItem ToAppItem()
+ {
+ var app = this;
+ var icoPath = string.IsNullOrEmpty(app.IcoPath) ?
+ (app.AppType == Win32Program.ApplicationType.InternetShortcutApplication ?
+ app.IcoPath :
+ app.FullPath) :
+ app.IcoPath;
+
+ icoPath = icoPath.EndsWith(".lnk", System.StringComparison.InvariantCultureIgnoreCase) ?
+ app.FullPath :
+ icoPath;
+ return new AppItem()
+ {
+ Name = app.Name,
+ Subtitle = app.Description,
+ Type = app.Type(),
+ IcoPath = icoPath,
+ ExePath = !string.IsNullOrEmpty(app.LnkFilePath) ? app.LnkFilePath : app.FullPath,
+ DirPath = app.Location,
+ Commands = app.GetCommands(),
+ AppIdentifier = app.GetAppIdentifier(),
+ };
+ }
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Properties/Resources.Designer.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Properties/Resources.Designer.cs
index cc07ac86b4..419bba3580 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Properties/Resources.Designer.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Properties/Resources.Designer.cs
@@ -213,6 +213,15 @@ namespace Microsoft.CmdPal.Ext.Apps.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Pin.
+ ///
+ internal static string pin_app {
+ get {
+ return ResourceManager.GetString("pin_app", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Run as administrator.
///
@@ -267,6 +276,15 @@ namespace Microsoft.CmdPal.Ext.Apps.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Unpin.
+ ///
+ internal static string unpin_app {
+ get {
+ return ResourceManager.GetString("unpin_app", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Experimental: When enabled, Command Palette will load thumbnails from the Windows Shell. Using thumbnails may cause the app to crash on launch.
///
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Properties/Resources.resx b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Properties/Resources.resx
index ce4fb79689..1e4c8fa4bd 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Properties/Resources.resx
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Properties/Resources.resx
@@ -199,4 +199,10 @@
Experimental: When enabled, Command Palette will load thumbnails from the Windows Shell. Using thumbnails may cause the app to crash on launch
A description for "use_thumbnails_setting_label"
+
+ Pin
+
+
+ Unpin
+
\ No newline at end of file
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/State/PinStateChangedEventArgs.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/State/PinStateChangedEventArgs.cs
new file mode 100644
index 0000000000..75cbbde56d
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/State/PinStateChangedEventArgs.cs
@@ -0,0 +1,34 @@
+// 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;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Microsoft.CmdPal.Ext.Apps.State;
+
+public class PinStateChangedEventArgs : EventArgs
+{
+ ///
+ /// Gets the identifier of the application whose pin state has changed.
+ ///
+ public string AppIdentifier { get; }
+
+ ///
+ /// Gets a value indicating whether the specified app identifier was pinned or not.
+ ///
+ public bool IsPinned { get; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The identifier of the application whose pin state has changed.
+ public PinStateChangedEventArgs(string appIdentifier, bool isPinned)
+ {
+ AppIdentifier = appIdentifier ?? throw new ArgumentNullException(nameof(appIdentifier));
+ IsPinned = isPinned;
+ }
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/State/PinnedApps.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/State/PinnedApps.cs
new file mode 100644
index 0000000000..ff76043bf1
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/State/PinnedApps.cs
@@ -0,0 +1,47 @@
+// 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 System.Diagnostics.CodeAnalysis;
+using System.IO;
+using System.Text.Json;
+
+namespace Microsoft.CmdPal.Ext.Apps.State;
+
+public sealed class PinnedApps
+{
+ public List PinnedAppIdentifiers { get; set; } = [];
+
+ public static PinnedApps ReadFromFile(string path)
+ {
+ if (!File.Exists(path))
+ {
+ return new PinnedApps();
+ }
+
+ try
+ {
+ var jsonString = File.ReadAllText(path);
+ var result = JsonSerializer.Deserialize(jsonString, JsonSerializationContext.Default.PinnedApps);
+ return result ?? new PinnedApps();
+ }
+ catch
+ {
+ return new PinnedApps();
+ }
+ }
+
+ public static void WriteToFile(string path, PinnedApps data)
+ {
+ try
+ {
+ var jsonString = JsonSerializer.Serialize(data, JsonSerializationContext.Default.PinnedApps);
+ File.WriteAllText(path, jsonString);
+ }
+ catch
+ {
+ // Silently fail - we don't want pinning issues to crash the extension
+ }
+ }
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/State/PinnedAppsManager.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/State/PinnedAppsManager.cs
new file mode 100644
index 0000000000..4540caf78d
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/State/PinnedAppsManager.cs
@@ -0,0 +1,82 @@
+// 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;
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
+using System.Linq;
+using ManagedCommon;
+using Microsoft.CommandPalette.Extensions.Toolkit;
+
+namespace Microsoft.CmdPal.Ext.Apps.State;
+
+public sealed class PinnedAppsManager
+{
+ private static readonly Lazy _instance = new(() => new PinnedAppsManager());
+ private readonly string _pinnedAppsFilePath;
+
+ public static PinnedAppsManager Instance => _instance.Value;
+
+ private PinnedApps _pinnedApps = new();
+
+ // Add event for when pinning state changes
+ public event EventHandler? PinStateChanged;
+
+ private PinnedAppsManager()
+ {
+ _pinnedAppsFilePath = GetPinnedAppsFilePath();
+ LoadPinnedApps();
+ }
+
+ public bool IsAppPinned(string appIdentifier)
+ {
+ return _pinnedApps.PinnedAppIdentifiers.Contains(appIdentifier, StringComparer.OrdinalIgnoreCase);
+ }
+
+ public void PinApp(string appIdentifier)
+ {
+ if (!IsAppPinned(appIdentifier))
+ {
+ _pinnedApps.PinnedAppIdentifiers.Add(appIdentifier);
+ SavePinnedApps();
+ Logger.LogTrace($"Pinned app: {appIdentifier}");
+ PinStateChanged?.Invoke(this, new PinStateChangedEventArgs(appIdentifier, true));
+ }
+ }
+
+ public string[] GetPinnedAppIdentifiers()
+ {
+ return _pinnedApps.PinnedAppIdentifiers.ToArray();
+ }
+
+ public void UnpinApp(string appIdentifier)
+ {
+ var removed = _pinnedApps.PinnedAppIdentifiers.RemoveAll(id =>
+ string.Equals(id, appIdentifier, StringComparison.OrdinalIgnoreCase));
+
+ if (removed > 0)
+ {
+ SavePinnedApps();
+ Logger.LogTrace($"Unpinned app: {appIdentifier}");
+ PinStateChanged?.Invoke(this, new PinStateChangedEventArgs(appIdentifier, false));
+ }
+ }
+
+ private void LoadPinnedApps()
+ {
+ _pinnedApps = PinnedApps.ReadFromFile(_pinnedAppsFilePath);
+ }
+
+ private void SavePinnedApps()
+ {
+ PinnedApps.WriteToFile(_pinnedAppsFilePath, _pinnedApps);
+ }
+
+ private static string GetPinnedAppsFilePath()
+ {
+ var directory = Utilities.BaseSettingsPath("Microsoft.CmdPal");
+ Directory.CreateDirectory(directory);
+ return Path.Combine(directory, "apps.pinned.json");
+ }
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/AddBookmarkPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/AddBookmarkPage.cs
index a4f9ba0050..d74b942990 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/AddBookmarkPage.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/AddBookmarkPage.cs
@@ -25,7 +25,7 @@ internal sealed partial class AddBookmarkPage : ContentPage
{
var name = bookmark?.Name ?? string.Empty;
var url = bookmark?.Bookmark ?? string.Empty;
- Icon = IconHelpers.FromRelativePath("Assets\\Bookmark.svg");
+ Icon = Icons.BookmarkIcon;
var isAdd = string.IsNullOrEmpty(name) && string.IsNullOrEmpty(url);
Title = isAdd ? Resources.bookmarks_add_title : Resources.bookmarks_edit_name;
Name = isAdd ? Resources.bookmarks_add_name : Resources.bookmarks_edit_name;
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarksCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarksCommandProvider.cs
index 7045b05867..55cd7c93a1 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarksCommandProvider.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarksCommandProvider.cs
@@ -23,15 +23,11 @@ public partial class BookmarksCommandProvider : CommandProvider
private Bookmarks? _bookmarks;
- public static IconInfo DeleteIcon { get; private set; } = new("\uE74D"); // Delete
-
- public static IconInfo EditIcon { get; private set; } = new("\uE70F"); // Edit
-
public BookmarksCommandProvider()
{
Id = "Bookmarks";
DisplayName = Resources.bookmarks_display_name;
- Icon = new IconInfo("\uE718"); // Pin
+ Icon = Icons.PinIcon;
_addNewCommand.AddedCommand += AddNewCommand_AddedCommand;
}
@@ -132,7 +128,7 @@ public partial class BookmarksCommandProvider : CommandProvider
listItem.Subtitle = urlCommand.Url;
}
- var edit = new AddBookmarkPage(bookmark) { Icon = EditIcon };
+ var edit = new AddBookmarkPage(bookmark) { Icon = Icons.EditIcon };
edit.AddedCommand += Edit_AddedCommand;
contextMenu.Add(new CommandContextItem(edit));
@@ -153,7 +149,7 @@ public partial class BookmarksCommandProvider : CommandProvider
result: CommandResult.KeepOpen())
{
IsCritical = true,
- Icon = DeleteIcon,
+ Icon = Icons.DeleteIcon,
};
contextMenu.Add(delete);
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Icons.cs
new file mode 100644
index 0000000000..6f8fd8b05e
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Icons.cs
@@ -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.Bookmarks;
+
+internal sealed class Icons
+{
+ internal static IconInfo BookmarkIcon => IconHelpers.FromRelativePath("Assets\\Bookmark.svg");
+
+ internal static IconInfo DeleteIcon { get; private set; } = new("\uE74D"); // Delete
+
+ internal static IconInfo EditIcon { get; private set; } = new("\uE70F"); // Edit
+
+ internal static IconInfo PinIcon { get; private set; } = new IconInfo("\uE718"); // Pin
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/CalculatorCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/CalculatorCommandProvider.cs
index 1478dbbd45..0f4a8b0d9b 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/CalculatorCommandProvider.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/CalculatorCommandProvider.cs
@@ -25,7 +25,7 @@ public partial class CalculatorCommandProvider : CommandProvider
{
Id = "Calculator";
DisplayName = Resources.calculator_display_name;
- Icon = CalculatorIcons.ProviderIcon;
+ Icon = Icons.CalculatorIcon;
Settings = settings.Settings;
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/CalculatorIcons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/CalculatorIcons.cs
deleted file mode 100644
index e3be5f2149..0000000000
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/CalculatorIcons.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// 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.Calc.Helper;
-
-public static class CalculatorIcons
-{
- public static IconInfo ResultIcon => new("\uE94E");
-
- public static IconInfo SaveIcon => new("\uE74E");
-
- public static IconInfo ErrorIcon => new("\uE783");
-
- public static IconInfo ProviderIcon => IconHelpers.FromRelativePath("Assets\\Calculator.svg");
-}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/ErrorHandler.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/ErrorHandler.cs
index b3948dc854..bfcf49a556 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/ErrorHandler.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/ErrorHandler.cs
@@ -47,7 +47,7 @@ internal static class ErrorHandler
{
Title = Properties.Resources.calculator_calculation_failed_title,
Subtitle = errorMessage,
- Icon = CalculatorIcons.ErrorIcon,
+ Icon = Icons.ErrorIcon,
};
}
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/ResultHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/ResultHelper.cs
index 0fab0a8245..e4780e4b62 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/ResultHelper.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/ResultHelper.cs
@@ -33,7 +33,7 @@ public static class ResultHelper
return new ListItem(saveCommand)
{
// Using CurrentCulture since this is user facing
- Icon = CalculatorIcons.ResultIcon,
+ Icon = Icons.ResultIcon,
Title = result,
Subtitle = query,
TextToSuggest = result,
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/SaveCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/SaveCommand.cs
index 850f8511e3..d2605e6f92 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/SaveCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/SaveCommand.cs
@@ -18,7 +18,7 @@ public sealed partial class SaveCommand : InvokableCommand
public SaveCommand(string result)
{
Name = Resources.calculator_save_command_name;
- Icon = CalculatorIcons.SaveIcon;
+ Icon = Icons.SaveIcon;
_result = result;
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Icons.cs
new file mode 100644
index 0000000000..f7d1a613f1
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Icons.cs
@@ -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.Calc;
+
+internal sealed class Icons
+{
+ internal static IconInfo CalculatorIcon => IconHelpers.FromRelativePath("Assets\\Calculator.svg");
+
+ internal static IconInfo ResultIcon => new("\uE94E"); // CalculatorEqualTo icon
+
+ internal static IconInfo SaveIcon => new("\uE74E"); // Save icon
+
+ internal static IconInfo ErrorIcon => new("\uE783"); // Error icon
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Pages/CalculatorListPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Pages/CalculatorListPage.cs
index 24f26646c5..4b0cf29d64 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Pages/CalculatorListPage.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Pages/CalculatorListPage.cs
@@ -35,7 +35,7 @@ public sealed partial class CalculatorListPage : DynamicListPage
public CalculatorListPage(SettingsManager settings)
{
_settingsManager = settings;
- Icon = CalculatorIcons.ProviderIcon;
+ Icon = Icons.CalculatorIcon;
Name = Resources.calculator_title;
PlaceholderText = Resources.calculator_placeholder_text;
Id = "com.microsoft.cmdpal.calculator";
@@ -43,11 +43,11 @@ public sealed partial class CalculatorListPage : DynamicListPage
_emptyItem = new ListItem(new NoOpCommand())
{
Title = Resources.calculator_placeholder_text,
- Icon = CalculatorIcons.ResultIcon,
+ Icon = Icons.ResultIcon,
};
EmptyContent = new CommandItem(new NoOpCommand())
{
- Icon = CalculatorIcons.ProviderIcon,
+ Icon = Icons.CalculatorIcon,
Title = Resources.calculator_placeholder_text,
};
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Pages/FallbackCalculatorItem.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Pages/FallbackCalculatorItem.cs
index 05d047924c..10d305bb7c 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Pages/FallbackCalculatorItem.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Pages/FallbackCalculatorItem.cs
@@ -20,7 +20,7 @@ public sealed partial class FallbackCalculatorItem : FallbackCommandItem
_copyCommand.Name = string.Empty;
Title = string.Empty;
Subtitle = Resources.calculator_placeholder_text;
- Icon = CalculatorIcons.ProviderIcon;
+ Icon = Icons.CalculatorIcon;
_settings = settings;
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/ClipboardHistoryCommandsProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/ClipboardHistoryCommandsProvider.cs
index d04126a453..c15658c96c 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/ClipboardHistoryCommandsProvider.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/ClipboardHistoryCommandsProvider.cs
@@ -18,11 +18,11 @@ public partial class ClipboardHistoryCommandsProvider : CommandProvider
{
Title = Properties.Resources.list_item_title,
Subtitle = Properties.Resources.list_item_subtitle,
- Icon = Icons.ClipboardList,
+ Icon = Icons.ClipboardListIcon,
};
DisplayName = Properties.Resources.provider_display_name;
- Icon = Icons.ClipboardList;
+ Icon = Icons.ClipboardListIcon;
Id = "Windows.ClipboardHistory";
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Commands/CopyCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Commands/CopyCommand.cs
index 37b00d2ed7..d55f87c9c6 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Commands/CopyCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Commands/CopyCommand.cs
@@ -19,11 +19,11 @@ internal sealed partial class CopyCommand : InvokableCommand
Name = Properties.Resources.copy_command_name;
if (clipboardFormat == ClipboardFormat.Text)
{
- Icon = Icons.Copy;
+ Icon = Icons.CopyIcon;
}
else
{
- Icon = Icons.Picture;
+ Icon = Icons.PictureIcon;
}
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Commands/PasteCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Commands/PasteCommand.cs
index b60c0ecd02..87f5fe1633 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Commands/PasteCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Commands/PasteCommand.cs
@@ -20,7 +20,7 @@ internal sealed partial class PasteCommand : InvokableCommand
_clipboardItem = clipboardItem;
_clipboardFormat = clipboardFormat;
Name = Properties.Resources.paste_command_name;
- Icon = Icons.Paste;
+ Icon = Icons.PasteIcon;
}
private void HideWindow()
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Icons.cs
index 15c90a857b..38fbc06d07 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Icons.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Icons.cs
@@ -8,11 +8,11 @@ namespace Microsoft.CmdPal.Ext.ClipboardHistory;
internal sealed class Icons
{
- internal static IconInfo Copy { get; } = new("\xE8C8");
+ internal static IconInfo CopyIcon { get; } = new("\xE8C8");
- internal static IconInfo Picture { get; } = new("\xE8B9");
+ internal static IconInfo PictureIcon { get; } = new("\xE8B9");
- internal static IconInfo Paste { get; } = new("\uE77F");
+ internal static IconInfo PasteIcon { get; } = new("\uE77F");
- internal static IconInfo ClipboardList { get; } = new("\uF0E3");
+ internal static IconInfo ClipboardListIcon { get; } = new("\uF0E3");
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Pages/ClipboardHistoryListPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Pages/ClipboardHistoryListPage.cs
index fed78fa32c..b8cccb987b 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Pages/ClipboardHistoryListPage.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.ClipboardHistory/Pages/ClipboardHistoryListPage.cs
@@ -24,7 +24,7 @@ internal sealed partial class ClipboardHistoryListPage : ListPage
{
clipboardHistory = [];
_defaultIconPath = string.Empty;
- Icon = Icons.ClipboardList;
+ Icon = Icons.ClipboardListIcon;
Name = Properties.Resources.clipboard_history_page_name;
Id = "com.microsoft.cmdpal.clipboardHistory";
ShowDetails = true;
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Commands/OpenFileCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Commands/OpenFileCommand.cs
index 478f03ef3a..9d48c64376 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Commands/OpenFileCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Commands/OpenFileCommand.cs
@@ -19,7 +19,7 @@ internal sealed partial class OpenFileCommand : InvokableCommand
{
this._item = item;
this.Name = Resources.Indexer_Command_OpenFile;
- this.Icon = Icons.OpenFile;
+ this.Icon = Icons.OpenFileIcon;
}
public override CommandResult Invoke()
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/FallbackOpenFileItem.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/FallbackOpenFileItem.cs
index a123200b8c..c1f867a4f3 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/FallbackOpenFileItem.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/FallbackOpenFileItem.cs
@@ -28,7 +28,7 @@ internal sealed partial class FallbackOpenFileItem : FallbackCommandItem, System
{
Title = string.Empty;
Subtitle = string.Empty;
- Icon = Icons.FileExplorer;
+ Icon = Icons.FileExplorerIcon;
}
public override void UpdateQuery(string query)
@@ -106,7 +106,7 @@ internal sealed partial class FallbackOpenFileItem : FallbackCommandItem, System
// us to the file search page, prepopulated with this search.
var indexerPage = new IndexerPage(query, _searchEngine, _queryCookie, results);
Title = string.Format(CultureInfo.CurrentCulture, fallbackItemSearchPageTitleCompositeFormat, query);
- Icon = Icons.FileExplorer;
+ Icon = Icons.FileExplorerIcon;
Subtitle = Resources.Indexer_Subtitle;
Command = indexerPage;
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Icons.cs
new file mode 100644
index 0000000000..f57b8a2d07
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Icons.cs
@@ -0,0 +1,22 @@
+// 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.Indexer;
+
+internal sealed class Icons
+{
+ internal static IconInfo FileExplorerSegoeIcon { get; } = new("\uEC50");
+
+ internal static IconInfo FileExplorerIcon { get; } = IconHelpers.FromRelativePath("Assets\\FileExplorer.png");
+
+ internal static IconInfo ActionsIcon { get; } = IconHelpers.FromRelativePath("Assets\\Actions.png");
+
+ internal static IconInfo OpenFileIcon { get; } = new("\uE8E5"); // OpenFile
+
+ internal static IconInfo DocumentIcon { get; } = new("\uE8A5"); // Document
+
+ internal static IconInfo FolderOpenIcon { get; } = new("\uE838"); // FolderOpen
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/IndexerCommandsProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/IndexerCommandsProvider.cs
index 605e3c70ff..ab6584f673 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/IndexerCommandsProvider.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/IndexerCommandsProvider.cs
@@ -18,7 +18,7 @@ public partial class IndexerCommandsProvider : CommandProvider
{
Id = "Files";
DisplayName = Resources.IndexerCommandsProvider_DisplayName;
- Icon = Icons.FileExplorer;
+ Icon = Icons.FileExplorerIcon;
if (IndexerListItem.IsActionsFeatureEnabled && ApiInformation.IsApiContractPresent("Windows.AI.Actions.ActionsContract", 4))
{
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/ActionsListContextItem.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/ActionsListContextItem.cs
index 04f9df00f4..0c2823fed5 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/ActionsListContextItem.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/ActionsListContextItem.cs
@@ -27,7 +27,7 @@ internal sealed partial class ActionsListContextItem : CommandContextItem, IDisp
: base(new NoOpCommand())
{
Title = Resources.Indexer_Command_Actions;
- Icon = Icons.Actions;
+ Icon = Icons.ActionsIcon;
RequestedShortcut = KeyChordHelpers.FromModifiers(alt: true, vkey: VirtualKey.A);
this.fullPath = fullPath;
UpdateMoreCommands();
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/DirectoryExplorePage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/DirectoryExplorePage.cs
index 531398685b..9bb7820a07 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/DirectoryExplorePage.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/DirectoryExplorePage.cs
@@ -28,7 +28,7 @@ public sealed partial class DirectoryExplorePage : DynamicListPage
public DirectoryExplorePage(string path)
{
_path = path;
- Icon = Icons.FileExplorer;
+ Icon = Icons.FileExplorerIcon;
Name = Resources.Indexer_Command_Browse;
Title = path;
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/DirectoryPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/DirectoryPage.cs
index e71b8a089a..a6f989c41e 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/DirectoryPage.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/DirectoryPage.cs
@@ -24,7 +24,7 @@ public sealed partial class DirectoryPage : ListPage
public DirectoryPage(string path)
{
_path = path;
- Icon = Icons.FileExplorer;
+ Icon = Icons.FileExplorerIcon;
Name = Resources.Indexer_Command_Browse;
Title = path;
}
@@ -52,7 +52,7 @@ public sealed partial class DirectoryPage : ListPage
EmptyContent = new CommandItem(
title: Resources.Indexer_File_Is_File_Not_Folder, subtitle: $"{_path}")
{
- Icon = Icons.Document,
+ Icon = Icons.DocumentIcon,
};
return [];
}
@@ -66,7 +66,7 @@ public sealed partial class DirectoryPage : ListPage
EmptyContent = new CommandItem(
title: Resources.Indexer_Folder_Is_Empty, subtitle: $"{_path}")
{
- Icon = Icons.FolderOpen,
+ Icon = Icons.FolderOpenIcon,
Command = listItemForUs.Command,
MoreCommands = listItemForUs.MoreCommands,
};
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/Icons.cs
deleted file mode 100644
index a07bce2016..0000000000
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/Icons.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// 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.Indexer;
-
-internal sealed class Icons
-{
- internal static IconInfo FileExplorerSegoe { get; } = new("\uEC50");
-
- internal static IconInfo FileExplorer { get; } = IconHelpers.FromRelativePath("Assets\\FileExplorer.png");
-
- internal static IconInfo Actions { get; } = IconHelpers.FromRelativePath("Assets\\Actions.png");
-
- internal static IconInfo OpenFile { get; } = new("\uE8E5"); // OpenFile
-
- internal static IconInfo Document { get; } = new("\uE8A5"); // Document
-
- internal static IconInfo FolderOpen { get; } = new("\uE838"); // FolderOpen
-}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/IndexerPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/IndexerPage.cs
index 33938b21e4..a62f03295a 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/IndexerPage.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/IndexerPage.cs
@@ -24,7 +24,7 @@ internal sealed partial class IndexerPage : DynamicListPage, IDisposable
public IndexerPage()
{
Id = "com.microsoft.indexer.fileSearch";
- Icon = Icons.FileExplorer;
+ Icon = Icons.FileExplorerIcon;
Name = Resources.Indexer_Title;
PlaceholderText = Resources.Indexer_PlaceholderText;
_searchEngine = new();
@@ -33,7 +33,7 @@ internal sealed partial class IndexerPage : DynamicListPage, IDisposable
public IndexerPage(string query, SearchEngine searchEngine, uint queryCookie, IList firstPageData)
{
- Icon = Icons.FileExplorer;
+ Icon = Icons.FileExplorerIcon;
Name = Resources.Indexer_Title;
_searchEngine = searchEngine;
_queryCookie = queryCookie;
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/CopyRegistryInfoCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/CopyRegistryInfoCommand.cs
index d876eb7efc..2252c4c1fe 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/CopyRegistryInfoCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/CopyRegistryInfoCommand.cs
@@ -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();
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/OpenKeyInEditorCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/OpenKeyInEditorCommand.cs
index b963c051bf..855b55b37d 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/OpenKeyInEditorCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/OpenKeyInEditorCommand.cs
@@ -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;
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs
index d607ce6b23..c05af5f594 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs
@@ -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),
});
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Icons.cs
new file mode 100644
index 0000000000..7e77abc757
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Icons.cs
@@ -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
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Pages/RegistryListPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Pages/RegistryListPage.cs
index 34ca4e5d21..fbc80d5d1e 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Pages/RegistryListPage.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Pages/RegistryListPage.cs
@@ -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,
};
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/RegistryCommandsProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/RegistryCommandsProvider.cs
index cca02e8d77..3f4218c81b 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/RegistryCommandsProvider.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/RegistryCommandsProvider.cs
@@ -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()
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Commands/ExecuteItem.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Commands/ExecuteItem.cs
index 3bc1ec09d7..74ef0268de 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Commands/ExecuteItem.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Commands/ExecuteItem.cs
@@ -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;
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/FallbackExecuteItem.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/FallbackExecuteItem.cs
index d4fd919a95..437fbcbdf6 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/FallbackExecuteItem.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/FallbackExecuteItem.cs
@@ -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)
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Helpers/ShellListPageHelpers.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Helpers/ShellListPageHelpers.cs
index 204a2cc5da..1bb682f6bd 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Helpers/ShellListPageHelpers.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Helpers/ShellListPageHelpers.cs
@@ -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();
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Icons.cs
index 7586d466fd..b25d53a6c5 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Icons.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Icons.cs
@@ -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
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Pages/ShellListPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Pages/ShellListPage.cs
index 51f6f8e636..d817809e10 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Pages/ShellListPage.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Pages/ShellListPage.cs
@@ -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;
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/ShellCommandsProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/ShellCommandsProvider.cs
index 9e98e036d4..1abc3c9d1c 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/ShellCommandsProvider.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/ShellCommandsProvider.cs
@@ -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 = [
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.System/Helpers/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.System/Helpers/Icons.cs
deleted file mode 100644
index 313ba773f8..0000000000
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.System/Helpers/Icons.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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.System.Helpers;
-
-public static partial class Icons
-{
- public static IconInfo FirmwareSettingsIcon { get; } = new IconInfo("\uE950");
-
- public static IconInfo LockIcon { get; } = new IconInfo("\uE72E");
-
- public static IconInfo LogoffIcon { get; } = new IconInfo("\uF3B1");
-
- public static IconInfo NetworkAdapterIcon { get; } = new IconInfo("\uEDA3");
-
- public static IconInfo RecycleBinIcon { get; } = new IconInfo("\uE74D");
-
- public static IconInfo RestartIcon { get; } = new IconInfo("\uE777");
-
- public static IconInfo RestartShellIcon { get; } = new IconInfo("\uEC50");
-
- public static IconInfo ShutdownIcon { get; } = new IconInfo("\uE7E8");
-
- public static IconInfo SleepIcon { get; } = new IconInfo("\uE708");
-}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.System/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.System/Icons.cs
new file mode 100644
index 0000000000..9993220dee
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.System/Icons.cs
@@ -0,0 +1,28 @@
+// 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.System;
+
+internal sealed class Icons
+{
+ internal static IconInfo FirmwareSettingsIcon { get; } = new IconInfo("\uE950");
+
+ internal static IconInfo LockIcon { get; } = new IconInfo("\uE72E");
+
+ internal static IconInfo LogoffIcon { get; } = new IconInfo("\uF3B1");
+
+ internal static IconInfo NetworkAdapterIcon { get; } = new IconInfo("\uEDA3");
+
+ internal static IconInfo RecycleBinIcon { get; } = new IconInfo("\uE74D");
+
+ internal static IconInfo RestartIcon { get; } = new IconInfo("\uE777");
+
+ internal static IconInfo RestartShellIcon { get; } = new IconInfo("\uEC50");
+
+ internal static IconInfo ShutdownIcon { get; } = new IconInfo("\uE7E8");
+
+ internal static IconInfo SleepIcon { get; } = new IconInfo("\uE708");
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResult.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResult.cs
index 7665de85df..3f54ca8438 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResult.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResult.cs
@@ -42,10 +42,10 @@ internal sealed class AvailableResult
{
return IconType switch
{
- ResultIconType.Time => ResultHelper.TimeIcon,
- ResultIconType.Date => ResultHelper.CalendarIcon,
- ResultIconType.DateTime => ResultHelper.TimeDateIcon,
- ResultIconType.Error => ResultHelper.ErrorIcon,
+ ResultIconType.Time => Icons.TimeIcon,
+ ResultIconType.Date => Icons.CalendarIcon,
+ ResultIconType.DateTime => Icons.TimeDateIcon,
+ ResultIconType.Error => Icons.ErrorIcon,
_ => null,
};
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResultsList.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResultsList.cs
index ee14fdb855..38366345c4 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResultsList.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResultsList.cs
@@ -104,7 +104,7 @@ internal static class AvailableResultsList
dtObject = dateTimeNowUtc;
}
- // Get formated date
+ // Get formatted date
var value = TimeAndDateHelper.ConvertToCustomFormat(dtObject, unixTimestamp, unixTimestampMilliseconds, weekOfYear, eraShort, Regex.Replace(formatSyntax, "^UTC:", string.Empty), firstWeekRule, firstDayOfTheWeek);
try
{
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/ResultHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/ResultHelper.cs
index e2ba932743..896bbd6b84 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/ResultHelper.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/ResultHelper.cs
@@ -26,14 +26,6 @@ internal static class ResultHelper
: Resources.ResourceManager.GetString(stringId + "Now", CultureInfo.CurrentUICulture) ?? string.Empty;
}
- public static IconInfo TimeIcon { get; } = new IconInfo("\uE823");
-
- public static IconInfo CalendarIcon { get; } = new IconInfo("\uE787");
-
- public static IconInfo TimeDateIcon { get; } = new IconInfo("\uEC92");
-
- public static IconInfo ErrorIcon { get; } = IconHelpers.FromRelativePaths("Microsoft.CmdPal.Ext.TimeDate\\Assets\\Warning.light.png", "Microsoft.CmdPal.Ext.TimeDate\\Assets\\Warning.dark.png");
-
///
/// Gets a result with an error message that input can't be parsed
///
@@ -42,7 +34,7 @@ internal static class ResultHelper
internal static ListItem CreateInvalidInputErrorResult() => new ListItem(new NoOpCommand())
{
Title = Resources.Microsoft_plugin_timedate_InvalidInput_ErrorMessageTitle,
- Icon = ErrorIcon,
+ Icon = Icons.ErrorIcon,
Details = new Details()
{
Title = Resources.Microsoft_plugin_timedate_InvalidInput_DetailsHeader,
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Icons.cs
new file mode 100644
index 0000000000..e0464b780f
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Icons.cs
@@ -0,0 +1,20 @@
+// 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.TimeDate;
+
+internal sealed class Icons
+{
+ internal static IconInfo TimeDateExtIcon { get; } = IconHelpers.FromRelativePath("Assets\\TimeDate.svg");
+
+ internal static IconInfo TimeIcon { get; } = new IconInfo("\uE823");
+
+ internal static IconInfo CalendarIcon { get; } = new IconInfo("\uE787");
+
+ internal static IconInfo TimeDateIcon { get; } = new IconInfo("\uEC92");
+
+ internal static IconInfo ErrorIcon { get; } = IconHelpers.FromRelativePaths("Microsoft.CmdPal.Ext.TimeDate\\Assets\\Warning.light.png", "Microsoft.CmdPal.Ext.TimeDate\\Assets\\Warning.dark.png");
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Pages/TimeDateExtensionPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Pages/TimeDateExtensionPage.cs
index ddacc95a62..4eb95034b7 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Pages/TimeDateExtensionPage.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Pages/TimeDateExtensionPage.cs
@@ -23,7 +23,7 @@ internal sealed partial class TimeDateExtensionPage : DynamicListPage
public TimeDateExtensionPage(SettingsManager settingsManager)
{
- Icon = IconHelpers.FromRelativePath("Assets\\TimeDate.svg");
+ Icon = Icons.TimeDateExtIcon;
Title = Resources.Microsoft_plugin_timedate_main_page_title;
Name = Resources.Microsoft_plugin_timedate_main_page_name;
PlaceholderText = Resources.Microsoft_plugin_timedate_placeholder_text;
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Commands/OpenURLCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Commands/OpenURLCommand.cs
index fd3f3a8f18..08d0a114f5 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Commands/OpenURLCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Commands/OpenURLCommand.cs
@@ -2,7 +2,6 @@
// 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.CmdPal.Ext.WebSearch.Helpers;
using Microsoft.CommandPalette.Extensions.Toolkit;
using BrowserInfo = Microsoft.CmdPal.Ext.WebSearch.Helpers.DefaultBrowserInfo;
@@ -11,17 +10,14 @@ namespace Microsoft.CmdPal.Ext.WebSearch.Commands;
internal sealed partial class OpenURLCommand : InvokableCommand
{
- private readonly SettingsManager _settingsManager;
-
public string Url { get; internal set; } = string.Empty;
- internal OpenURLCommand(string url, SettingsManager settingsManager)
+ internal OpenURLCommand(string url)
{
Url = url;
BrowserInfo.UpdateIfTimePassed();
- Icon = IconHelpers.FromRelativePath("Assets\\WebSearch.png");
+ Icon = Icons.WebSearch;
Name = string.Empty;
- _settingsManager = settingsManager;
}
public override CommandResult Invoke()
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Commands/SearchWebCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Commands/SearchWebCommand.cs
index 0dc0265a7d..1004f151a3 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Commands/SearchWebCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Commands/SearchWebCommand.cs
@@ -21,7 +21,7 @@ internal sealed partial class SearchWebCommand : InvokableCommand
{
Arguments = arguments;
BrowserInfo.UpdateIfTimePassed();
- Icon = IconHelpers.FromRelativePath("Assets\\WebSearch.png");
+ Icon = Icons.WebSearch;
Name = Properties.Resources.open_in_default_browser;
_settingsManager = settingsManager;
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/FallbackExecuteSearchItem.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/FallbackExecuteSearchItem.cs
index 9f37a7bf7e..bc87227221 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/FallbackExecuteSearchItem.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/FallbackExecuteSearchItem.cs
@@ -23,7 +23,7 @@ internal sealed partial class FallbackExecuteSearchItem : FallbackCommandItem
Title = string.Empty;
_executeItem.Name = string.Empty;
Subtitle = string.Format(CultureInfo.CurrentCulture, PluginOpen, BrowserInfo.Name ?? BrowserInfo.MSEdgeName);
- Icon = IconHelpers.FromRelativePath("Assets\\WebSearch.png");
+ Icon = Icons.WebSearch;
}
public override void UpdateQuery(string query)
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/FallbackOpenURLItem.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/FallbackOpenURLItem.cs
index 45a65f4902..9f5d9d86ca 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/FallbackOpenURLItem.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/FallbackOpenURLItem.cs
@@ -19,13 +19,13 @@ internal sealed partial class FallbackOpenURLItem : FallbackCommandItem
private static readonly CompositeFormat PluginOpenUrlInBrowser = System.Text.CompositeFormat.Parse(Properties.Resources.plugin_open_url_in_browser);
public FallbackOpenURLItem(SettingsManager settings)
- : base(new OpenURLCommand(string.Empty, settings), Properties.Resources.open_url_fallback_title)
+ : base(new OpenURLCommand(string.Empty), Properties.Resources.open_url_fallback_title)
{
_executeItem = (OpenURLCommand)this.Command!;
Title = string.Empty;
_executeItem.Name = string.Empty;
Subtitle = string.Empty;
- Icon = IconHelpers.FromRelativePath("Assets\\WebSearch.png");
+ Icon = Icons.WebSearch;
}
public override void UpdateQuery(string query)
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Icons.cs
new file mode 100644
index 0000000000..10f6fd32c1
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Icons.cs
@@ -0,0 +1,12 @@
+// 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.WebSearch;
+
+internal sealed class Icons
+{
+ internal static IconInfo WebSearch { get; } = IconHelpers.FromRelativePath("Assets\\WebSearch.png");
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/WebSearchCommandsProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/WebSearchCommandsProvider.cs
index 6768ff8baf..cb2d2ccf1b 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/WebSearchCommandsProvider.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/WebSearchCommandsProvider.cs
@@ -20,7 +20,7 @@ public partial class WebSearchCommandsProvider : CommandProvider
{
Id = "WebSearch";
DisplayName = Resources.extension_name;
- Icon = IconHelpers.FromRelativePath("Assets\\WebSearch.png");
+ Icon = Icons.WebSearch;
Settings = _settingsManager.Settings;
_fallbackItem = new FallbackExecuteSearchItem(_settingsManager);
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/WebSearchTopLevelCommandItem.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/WebSearchTopLevelCommandItem.cs
index d1d2e5ccad..e13436845d 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/WebSearchTopLevelCommandItem.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/WebSearchTopLevelCommandItem.cs
@@ -20,7 +20,7 @@ public partial class WebSearchTopLevelCommandItem : CommandItem, IFallbackHandle
public WebSearchTopLevelCommandItem(SettingsManager settingsManager)
: base(new WebSearchListPage(settingsManager))
{
- Icon = IconHelpers.FromRelativePath("Assets\\WebSearch.png");
+ Icon = Icons.WebSearch;
SetDefaultTitle();
_settingsManager = settingsManager;
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/Icons.cs
new file mode 100644
index 0000000000..524bc25581
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/Icons.cs
@@ -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
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/Pages/InstallPackageCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/Pages/InstallPackageCommand.cs
index cf85359bdf..c4fd7b7a4c 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/Pages/InstallPackageCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/Pages/InstallPackageCommand.cs
@@ -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? 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
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/Pages/InstallPackageListItem.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/Pages/InstallPackageListItem.cs
index 8156095d85..dd51e297a9 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/Pages/InstallPackageListItem.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/Pages/InstallPackageListItem.cs
@@ -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)
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/Pages/WinGetExtensionPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/Pages/WinGetExtensionPage.cs
index 000e2a9bba..1ca113d55c 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/Pages/WinGetExtensionPage.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/Pages/WinGetExtensionPage.cs
@@ -34,17 +34,13 @@ internal sealed partial class WinGetExtensionPage : DynamicListPage, IDisposable
private IEnumerable? _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 results = new(new PackageIdCompare());
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/WinGetExtensionCommandsProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/WinGetExtensionCommandsProvider.cs
index 28586b07ee..44b6da1f17 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/WinGetExtensionCommandsProvider.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WinGet/WinGetExtensionCommandsProvider.cs
@@ -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,
},
];
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Commands/CloseWindowCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Commands/CloseWindowCommand.cs
index aa4ee84a5d..ea2480918c 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Commands/CloseWindowCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Commands/CloseWindowCommand.cs
@@ -20,7 +20,7 @@ internal sealed partial class CloseWindowCommand : InvokableCommand
public CloseWindowCommand(Window window)
{
- Icon = new IconInfo("\uE894");
+ Icon = Icons.CloseWindow;
Name = $"{Resources.windowwalker_Close}";
_window = window;
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Commands/EndTaskCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Commands/EndTaskCommand.cs
index 0918d6bc02..993429d305 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Commands/EndTaskCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Commands/EndTaskCommand.cs
@@ -21,7 +21,7 @@ internal sealed partial class EndTaskCommand : InvokableCommand
public EndTaskCommand(Window window)
{
- Icon = new IconInfo("\uF140");
+ Icon = Icons.EndTask;
Name = $"{Resources.windowwalker_Kill}";
_window = window;
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Components/ResultHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Components/ResultHelper.cs
index 092f1544de..fd7cf9149c 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Components/ResultHelper.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Components/ResultHelper.cs
@@ -119,7 +119,7 @@ internal static class ResultHelper
return new WindowWalkerListItem(null)
{
Title = Resources.windowwalker_ExplorerInfoTitle,
- Icon = new IconInfo("\uE946"), // Info
+ Icon = Icons.Info,
Subtitle = Resources.windowwalker_ExplorerInfoSubTitle,
Command = new ExplorerInfoResultCommand(),
};
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Icons.cs
new file mode 100644
index 0000000000..bfcb47f428
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Icons.cs
@@ -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.WindowWalker;
+
+internal sealed class Icons
+{
+ internal static IconInfo WindowWalkerIcon { get; } = IconHelpers.FromRelativePath("Assets\\WindowWalker.svg");
+
+ internal static IconInfo EndTask { get; } = new IconInfo("\uF140"); // StatusCircleBlock
+
+ internal static IconInfo CloseWindow { get; } = new IconInfo("\uE894"); // Clear
+
+ internal static IconInfo Info { get; } = new IconInfo("\uE946"); // Info
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Pages/WindowWalkerListPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Pages/WindowWalkerListPage.cs
index 96556d8fd5..ff7217498a 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Pages/WindowWalkerListPage.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Pages/WindowWalkerListPage.cs
@@ -19,7 +19,7 @@ internal sealed partial class WindowWalkerListPage : DynamicListPage, IDisposabl
public WindowWalkerListPage()
{
- Icon = IconHelpers.FromRelativePath("Assets\\WindowWalker.svg");
+ Icon = Icons.WindowWalkerIcon;
Name = Resources.windowwalker_name;
Id = "com.microsoft.cmdpal.windowwalker";
PlaceholderText = Resources.windowwalker_PlaceholderText;
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/WindowWalkerCommandsProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/WindowWalkerCommandsProvider.cs
index a1dd46cad1..5b9bc79c9c 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/WindowWalkerCommandsProvider.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/WindowWalkerCommandsProvider.cs
@@ -20,7 +20,7 @@ public partial class WindowWalkerCommandsProvider : CommandProvider
{
Id = "WindowWalker";
DisplayName = Resources.windowwalker_name;
- Icon = IconHelpers.FromRelativePath("Assets\\WindowWalker.svg");
+ Icon = Icons.WindowWalkerIcon;
Settings = SettingsManager.Instance.Settings;
_windowWalkerPageItem = new CommandItem(new WindowWalkerListPage())
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Commands/OpenServicesCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Commands/OpenServicesCommand.cs
index 312a3fc33d..8c7e952ce6 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Commands/OpenServicesCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Commands/OpenServicesCommand.cs
@@ -25,7 +25,7 @@ internal sealed partial class OpenServicesCommand : InvokableCommand
{
_serviceResult = serviceResult;
Name = Resources.wox_plugin_service_open_services;
- Icon = new IconInfo("\xE8A7"); // OpenInNewWindow icon
+ Icon = Icons.OpenIcon;
}
public override CommandResult Invoke()
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Commands/RestartServiceCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Commands/RestartServiceCommand.cs
index 48b2a861ee..882697acf2 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Commands/RestartServiceCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Commands/RestartServiceCommand.cs
@@ -25,7 +25,7 @@ internal sealed partial class RestartServiceCommand : InvokableCommand
{
_serviceResult = serviceResult;
Name = Resources.wox_plugin_service_restart;
- Icon = new IconInfo("\xE72C"); // Refresh icon
+ Icon = Icons.RefreshIcon;
}
public override CommandResult Invoke()
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Commands/ServiceCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Commands/ServiceCommand.cs
index 3d313fe656..ffde320363 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Commands/ServiceCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Commands/ServiceCommand.cs
@@ -28,11 +28,11 @@ internal sealed partial class ServiceCommand : InvokableCommand
Name = action.ToString();
if (serviceResult.IsRunning)
{
- Icon = new IconInfo("\xE71A"); // Stop icon
+ Icon = Icons.StopIcon;
}
else
{
- Icon = new IconInfo("\xEDB5"); // PlayBadge12 icon
+ Icon = Icons.PlayIcon;
}
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Helpers/ServiceHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Helpers/ServiceHelper.cs
index e5d81caa3c..ed67163ca5 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Helpers/ServiceHelper.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Helpers/ServiceHelper.cs
@@ -73,16 +73,16 @@ public static class ServiceHelper
];
}
- IconInfo icon = new("\U0001f7e2"); // unicode LARGE GREEN CIRCLE
+ IconInfo icon = Icons.GreenCircleIcon;
switch (s.Status)
{
case ServiceControllerStatus.Stopped:
- icon = new("\U0001F534"); // unicode LARGE RED CIRCLE
+ icon = Icons.RedCircleIcon;
break;
case ServiceControllerStatus.Running:
break;
case ServiceControllerStatus.Paused:
- icon = new("\u23F8"); // unicode DOUBLE VERTICAL BAR, aka, "Pause"
+ icon = Icons.PauseIcon;
break;
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Icons.cs
new file mode 100644
index 0000000000..91ac6cb779
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Icons.cs
@@ -0,0 +1,26 @@
+// 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.WindowsServices;
+
+internal sealed class Icons
+{
+ internal static IconInfo ServicesIcon { get; } = IconHelpers.FromRelativePath("Assets\\Services.svg");
+
+ internal static IconInfo StopIcon { get; } = new IconInfo("\xE71A"); // Stop icon
+
+ internal static IconInfo PlayIcon { get; } = new IconInfo("\xEDB5"); // PlayBadge12 icon
+
+ internal static IconInfo RefreshIcon { get; } = new IconInfo("\xE72C"); // Refresh icon
+
+ internal static IconInfo OpenIcon { get; } = new IconInfo("\xE8A7"); // OpenInNewWindow icon
+
+ internal static IconInfo GreenCircleIcon { get; } = new("\U0001f7e2"); // unicode LARGE GREEN CIRCLE
+
+ internal static IconInfo RedCircleIcon { get; } = new("\U0001F534"); // unicode LARGE RED CIRCLE
+
+ internal static IconInfo PauseIcon { get; } = new("\u23F8"); // unicode DOUBLE VERTICAL BAR, aka, "Pause"
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Pages/ServicesListPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Pages/ServicesListPage.cs
index 1d7b4d43f1..1f361b6b10 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Pages/ServicesListPage.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Pages/ServicesListPage.cs
@@ -14,7 +14,7 @@ internal sealed partial class ServicesListPage : DynamicListPage
{
public ServicesListPage()
{
- Icon = WindowsServicesCommandsProvider.ServicesIcon;
+ Icon = Icons.ServicesIcon;
Name = "Windows Services";
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/WindowsServicesCommandsProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/WindowsServicesCommandsProvider.cs
index 57110128da..48ca848707 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/WindowsServicesCommandsProvider.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/WindowsServicesCommandsProvider.cs
@@ -11,13 +11,11 @@ namespace Microsoft.CmdPal.Ext.WindowsServices;
public partial class WindowsServicesCommandsProvider : CommandProvider
{
// For giggles, "%windir%\\system32\\filemgmt.dll" also _just works_.
- public static IconInfo ServicesIcon { get; } = IconHelpers.FromRelativePath("Assets\\Services.svg");
-
public WindowsServicesCommandsProvider()
{
Id = "Windows.Services";
DisplayName = Resources.WindowsServicesProvider_DisplayName;
- Icon = ServicesIcon;
+ Icon = Icons.ServicesIcon;
}
public override ICommandItem[] TopLevelCommands()
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Commands/CopySettingCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Commands/CopySettingCommand.cs
index 7f5fa1789e..d992a5fa6b 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Commands/CopySettingCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Commands/CopySettingCommand.cs
@@ -10,7 +10,6 @@ using System.Resources;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CmdPal.Ext.WindowsSettings.Classes;
-using Microsoft.CmdPal.Ext.WindowsSettings.Helpers;
using Microsoft.CmdPal.Ext.WindowsSettings.Properties;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
@@ -27,7 +26,7 @@ internal sealed partial class CopySettingCommand : InvokableCommand
internal CopySettingCommand(WindowsSetting entry)
{
Name = Resources.CopyCommand;
- Icon = new IconInfo("\xE8C8"); // Copy icon
+ Icon = Icons.CopyIcon;
_entry = entry;
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Commands/OpenSettingsCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Commands/OpenSettingsCommand.cs
index 9460cd9240..fd94bc63da 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Commands/OpenSettingsCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Commands/OpenSettingsCommand.cs
@@ -10,7 +10,6 @@ using System.Resources;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CmdPal.Ext.WindowsSettings.Classes;
-using Microsoft.CmdPal.Ext.WindowsSettings.Helpers;
using Microsoft.CmdPal.Ext.WindowsSettings.Properties;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
@@ -27,7 +26,7 @@ internal sealed partial class OpenSettingsCommand : InvokableCommand
internal OpenSettingsCommand(WindowsSetting entry)
{
Name = Resources.OpenSettings;
- Icon = new IconInfo("\xE8C8");
+ Icon = Icons.CopyIcon;
_entry = entry;
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/ResultHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/ResultHelper.cs
index ab457a7956..fb4828688c 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/ResultHelper.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/ResultHelper.cs
@@ -8,7 +8,6 @@ using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
-
using Microsoft.CmdPal.Ext.WindowsSettings.Commands;
using Microsoft.CmdPal.Ext.WindowsSettings.Helpers;
using Microsoft.CmdPal.Ext.WindowsSettings.Properties;
@@ -30,7 +29,7 @@ internal static class ResultHelper
{
var result = new ListItem(new OpenSettingsCommand(entry))
{
- Icon = IconHelpers.FromRelativePath("Assets\\WindowsSettings.svg"),
+ Icon = Icons.WindowsSettingsIcon,
Subtitle = entry.JoinedFullSettingsPath,
Title = entry.Name,
MoreCommands = ContextMenuHelper.GetContextMenu(entry).ToArray(),
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Icons.cs
new file mode 100644
index 0000000000..9534523f60
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Icons.cs
@@ -0,0 +1,14 @@
+// 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.WindowsSettings;
+
+internal sealed class Icons
+{
+ internal static IconInfo WindowsSettingsIcon { get; } = IconHelpers.FromRelativePath("Assets\\WindowsSettings.svg");
+
+ internal static IconInfo CopyIcon { get; } = new IconInfo("\xE8C8"); // Copy icon
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Pages/FallbackWindowsSettingsItem.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Pages/FallbackWindowsSettingsItem.cs
index a7a7291e91..a63a2965bd 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Pages/FallbackWindowsSettingsItem.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Pages/FallbackWindowsSettingsItem.cs
@@ -24,7 +24,7 @@ internal sealed partial class FallbackWindowsSettingsItem : FallbackCommandItem
public FallbackWindowsSettingsItem(Classes.WindowsSettings windowsSettings)
: base(new NoOpCommand(), Resources.settings_title)
{
- Icon = IconHelpers.FromRelativePath("Assets\\WindowsSettings.svg");
+ Icon = Icons.WindowsSettingsIcon;
_windowsSettings = windowsSettings;
}
@@ -59,10 +59,10 @@ internal sealed partial class FallbackWindowsSettingsItem : FallbackCommandItem
Title = setting.Name;
Subtitle = setting.JoinedFullSettingsPath;
- Icon = IconHelpers.FromRelativePath("Assets\\WindowsSettings.svg");
+ Icon = Icons.WindowsSettingsIcon;
Command = new OpenSettingsCommand(setting)
{
- Icon = IconHelpers.FromRelativePath("Assets\\WindowsSettings.svg"),
+ Icon = Icons.WindowsSettingsIcon,
Name = setting.Name,
};
@@ -80,7 +80,7 @@ internal sealed partial class FallbackWindowsSettingsItem : FallbackCommandItem
// us to the Windows Settings search page, prepopulated with this search.
var settingsPage = new WindowsSettingsListPage(_windowsSettings, query);
Title = string.Format(CultureInfo.CurrentCulture, _title, query);
- Icon = IconHelpers.FromRelativePath("Assets\\WindowsSettings.svg");
+ Icon = Icons.WindowsSettingsIcon;
Subtitle = _subtitle;
Command = settingsPage;
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Pages/WindowsSettingsListPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Pages/WindowsSettingsListPage.cs
index 3ac04005e2..3c27d28537 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Pages/WindowsSettingsListPage.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Pages/WindowsSettingsListPage.cs
@@ -19,7 +19,7 @@ internal sealed partial class WindowsSettingsListPage : DynamicListPage
public WindowsSettingsListPage(Classes.WindowsSettings windowsSettings)
{
- Icon = IconHelpers.FromRelativePath("Assets\\WindowsSettings.svg");
+ Icon = Icons.WindowsSettingsIcon;
Name = Resources.settings_title;
Id = "com.microsoft.cmdpal.windowsSettings";
_windowsSettings = windowsSettings;
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/WindowsSettingsCommandsProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/WindowsSettingsCommandsProvider.cs
index 25559b394e..600e621c99 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/WindowsSettingsCommandsProvider.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/WindowsSettingsCommandsProvider.cs
@@ -24,7 +24,7 @@ public partial class WindowsSettingsCommandsProvider : CommandProvider
{
Id = "Windows.Settings";
DisplayName = Resources.WindowsSettingsProvider_DisplayName;
- Icon = IconHelpers.FromRelativePath("Assets\\WindowsSettings.svg");
+ Icon = Icons.WindowsSettingsIcon;
_windowsSettings = JsonSettingsListHelper.ReadAllPossibleSettings();
_searchSettingsListItem = new CommandItem(new WindowsSettingsListPage(_windowsSettings))
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Commands/LaunchProfileAsAdminCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Commands/LaunchProfileAsAdminCommand.cs
index 1d1fcac873..f215ba5e94 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Commands/LaunchProfileAsAdminCommand.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Commands/LaunchProfileAsAdminCommand.cs
@@ -29,7 +29,7 @@ internal sealed partial class LaunchProfileAsAdminCommand : InvokableCommand
this._openQuake = openQuake;
this.Name = Resources.launch_profile_as_admin;
- this.Icon = new IconInfo("\xE7EF"); // Admin icon
+ this.Icon = Icons.AdminIcon;
}
private void LaunchElevated(string id, string profile)
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Icons.cs
new file mode 100644
index 0000000000..57abd2c01d
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Icons.cs
@@ -0,0 +1,14 @@
+// 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.WindowsTerminal;
+
+internal sealed class Icons
+{
+ internal static IconInfo TerminalIcon { get; } = IconHelpers.FromRelativePath("Assets\\WindowsTerminal.svg");
+
+ internal static IconInfo AdminIcon { get; } = new IconInfo("\xE7EF"); // Admin icon
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Pages/ProfilesListPage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Pages/ProfilesListPage.cs
index 752aca5574..b426e96914 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Pages/ProfilesListPage.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Pages/ProfilesListPage.cs
@@ -24,7 +24,7 @@ internal sealed partial class ProfilesListPage : ListPage
public ProfilesListPage(SettingsManager terminalSettings)
{
- Icon = WindowsTerminalCommandsProvider.TerminalIcon;
+ Icon = Icons.TerminalIcon;
Name = Resources.profiles_list_page_name;
_terminalSettings = terminalSettings;
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/TerminalTopLevelCommandItem.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/TerminalTopLevelCommandItem.cs
index 8f0f81c7c1..0eebd98adf 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/TerminalTopLevelCommandItem.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/TerminalTopLevelCommandItem.cs
@@ -14,7 +14,7 @@ public partial class TerminalTopLevelCommandItem : CommandItem
public TerminalTopLevelCommandItem(SettingsManager settingsManager)
: base(new ProfilesListPage(settingsManager))
{
- Icon = WindowsTerminalCommandsProvider.TerminalIcon;
+ Icon = Icons.TerminalIcon;
Title = Resources.list_item_title;
}
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/WindowsTerminalCommandsProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/WindowsTerminalCommandsProvider.cs
index cc311541ef..bd825cbddb 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/WindowsTerminalCommandsProvider.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/WindowsTerminalCommandsProvider.cs
@@ -14,13 +14,11 @@ public partial class WindowsTerminalCommandsProvider : CommandProvider
private readonly TerminalTopLevelCommandItem _terminalCommand;
private readonly SettingsManager _settingsManager = new();
- public static IconInfo TerminalIcon { get; } = IconHelpers.FromRelativePath("Assets\\WindowsTerminal.svg");
-
public WindowsTerminalCommandsProvider()
{
Id = "WindowsTerminalProfiles";
DisplayName = Resources.extension_name;
- Icon = TerminalIcon;
+ Icon = Icons.TerminalIcon;
Settings = _settingsManager.Settings;
_terminalCommand = new TerminalTopLevelCommandItem(_settingsManager)
diff --git a/src/modules/cmdpal/ext/SamplePagesExtension/Pages/SampleListPage.cs b/src/modules/cmdpal/ext/SamplePagesExtension/Pages/SampleListPage.cs
index 1777fb217c..2c3fabf5c6 100644
--- a/src/modules/cmdpal/ext/SamplePagesExtension/Pages/SampleListPage.cs
+++ b/src/modules/cmdpal/ext/SamplePagesExtension/Pages/SampleListPage.cs
@@ -99,7 +99,7 @@ internal sealed partial class SampleListPage : ListPage
new CommandContextItem(
new ToastCommand("Nested B invoked") { Name = "Do it", Icon = new IconInfo("B") })
{
- Title = "Nested B...",
+ Title = "Nested B with a really, really long title that should be trimmed",
RequestedShortcut = KeyChordHelpers.FromModifiers(ctrl: true, vkey: VirtualKey.B),
MoreCommands = [
new CommandContextItem(