mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
- Move all source files from Core.ViewModels to UI.ViewModels - Update namespace from Microsoft.CmdPal.Core.ViewModels to Microsoft.CmdPal.UI.ViewModels - Remove Core.ViewModels project from solution files - Update all using statements in dependent projects - Delete the Core folder which is now empty
48 lines
1.5 KiB
C#
48 lines
1.5 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 System.Diagnostics.CodeAnalysis;
|
|
using Microsoft.CmdPal.UI.ViewModels.Models;
|
|
using Microsoft.CommandPalette.Extensions;
|
|
using Microsoft.CommandPalette.Extensions.Toolkit;
|
|
|
|
namespace Microsoft.CmdPal.UI.ViewModels;
|
|
|
|
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
|
|
public partial class CommandContextItemViewModel(ICommandContextItem contextItem, WeakReference<IPageContext> context) : CommandItemViewModel(new(contextItem), context), IContextItemViewModel
|
|
{
|
|
private readonly KeyChord nullKeyChord = new(0, 0, 0);
|
|
|
|
public new ExtensionObject<ICommandContextItem> Model { get; } = new(contextItem);
|
|
|
|
public bool IsCritical { get; private set; }
|
|
|
|
public KeyChord? RequestedShortcut { get; private set; }
|
|
|
|
public bool HasRequestedShortcut => RequestedShortcut is not null && (RequestedShortcut.Value != nullKeyChord);
|
|
|
|
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);
|
|
}
|
|
}
|