/
githubmirror
/
PowerToys
Обзор
Документация
Войти
/
githubmirror
/
PowerToys
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/PerformCommandMessage.cs
74 строки
2 KB
Jiří Polášek
CmdPal: Add an optional icon and an optional action button to toasts (#49260)
12 июл 2026, 02:19
Не верифицирован
12 июл 2026, 02:19
a1bef58
Код
Авторство
О чём код?
// 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.CommandPalette.Extensions; namespace Microsoft.CmdPal.UI.ViewModels.Messages; /// <summary> /// Used to do a command - navigate to a page or invoke it /// </summary> public record PerformCommandMessage { public ExtensionObject<ICommand> Command { get; } public object? Context { get; } public bool WithAnimation { get; set; } = true; public bool TransientPage { get; set; } /// <summary> /// Optional callback raised by <see cref="ShellViewModel"/> just before a /// <see cref="ShowConfirmationMessage"/> is dispatched for this command's /// result. Lets the sender prepare UI (for example, the dock uses this to /// open the cmdpal window anchored at the invoking dock item so that the /// confirmation dialog appears in the right place). /// </summary> public Action? OnBeforeShowConfirmation { get; set; } /// <summary> /// When set, and the command turns out to be a page, the main window is /// summoned before navigating. Used by senders that run while the palette /// is hidden (for example the toast's action button). /// </summary> public bool ShowWindowIfPage { get; set; } public PerformCommandMessage(ExtensionObject<ICommand> command) { Command = command; Context = null; } public PerformCommandMessage(ExtensionObject<ICommand> command, ExtensionObject<IListItem> context) { Command = command; Context = context.Unsafe; } public PerformCommandMessage(ExtensionObject<ICommand> command, ExtensionObject<ICommandItem> context) { Command = command; Context = context.Unsafe; } public PerformCommandMessage(ExtensionObject<ICommand> command, ExtensionObject<ICommandContextItem> context) { Command = command; Context = context.Unsafe; } public PerformCommandMessage(CommandContextItemViewModel contextCommand) { Command = contextCommand.Command.Model; Context = contextCommand.Model.Unsafe; } public PerformCommandMessage(ConfirmResultViewModel vm) { Command = vm.PrimaryCommand.Model; Context = null; } }