mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01:00
* [x] Re-adds the context menu shortcut text * [x] Hooks up the keybindings to the search box so that you can just press the keys while you have an item selected, and do a context command * [x] Hook these keybindings up to the context flyout itself * [x] Adds a sample for testing Solves #38271
66 lines
1.8 KiB
C#
66 lines
1.8 KiB
C#
// 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 CommandPaletteHost? ExtensionHost { get; private set; }
|
|
|
|
public PerformCommandMessage(ExtensionObject<ICommand> command)
|
|
{
|
|
Command = command;
|
|
Context = null;
|
|
}
|
|
|
|
public PerformCommandMessage(TopLevelViewModel topLevelCommand)
|
|
{
|
|
Command = topLevelCommand.CommandViewModel.Model;
|
|
Context = null;
|
|
ExtensionHost = topLevelCommand.ExtensionHost;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|