/
githubmirror
/
PowerToys
Обзор
Документация
Войти
/
githubmirror
/
PowerToys
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandContextItemViewModel.cs
53 строки
2 KB
Mike Griese
CmdPal: Add context commands for pinning nested commands (#45673)
26 фев 2026, 19:09
Не верифицирован
26 фев 2026, 19:09
7a0e4ac
Код
Авторство
О чём код?
// 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.CommandPalette.Extensions; namespace Microsoft.CmdPal.UI.ViewModels; [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] public partial class CommandContextItemViewModel : CommandItemViewModel, IContextItemViewModel { private readonly KeyChord nullKeyChord = new(0, 0, 0); public new ExtensionObject<ICommandContextItem> Model { get; } public bool IsCritical { get; private set; } public KeyChord? RequestedShortcut { get; private set; } public bool HasRequestedShortcut => RequestedShortcut is not null && (RequestedShortcut.Value != nullKeyChord); public CommandContextItemViewModel(ICommandContextItem contextItem, WeakReference<IPageContext> context) : base(new(contextItem), context, contextMenuFactory: null) { Model = new(contextItem); IsContextMenuItem = true; } public override void InitializeProperties() { if (IsInitialized) { return; } base.InitializeProperties(); var contextItem = Model.Unsafe; if (contextItem is null) { return; // throw? } IsCritical = contextItem.IsCritical; RequestedShortcut = new( contextItem.RequestedShortcut.Modifiers, contextItem.RequestedShortcut.Vkey, contextItem.RequestedShortcut.ScanCode); } }