ShowDetailsCommand.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using CommunityToolkit.Mvvm.Messaging; 6 using Microsoft.CmdPal.Core.ViewModels.Messages; 7 using Microsoft.CommandPalette.Extensions.Toolkit; 8 9 namespace Microsoft.CmdPal.Core.ViewModels.Commands; 10 11 public sealed partial class ShowDetailsCommand : InvokableCommand 12 { 13 public static string ShowDetailsCommandId { get; } = "com.microsoft.cmdpal.showDetails"; 14 15 private static IconInfo IconInfo { get; } = new IconInfo("\uF000"); // KnowledgeArticle Icon 16 17 private DetailsViewModel Details { get; set; } 18 19 public ShowDetailsCommand(DetailsViewModel details) 20 { 21 Id = ShowDetailsCommandId; 22 Name = Properties.Resources.ShowDetailsCommand; 23 Icon = IconInfo; 24 Details = details; 25 } 26 27 public override CommandResult Invoke() 28 { 29 // Send the ShowDetailsMessage when the action is invoked 30 WeakReferenceMessenger.Default.Send<ShowDetailsMessage>(new(Details)); 31 return CommandResult.KeepOpen(); 32 } 33 }