PowerToys/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/KeyboardManagerViewModel.cs
udit3333 a88d66b48b
Integrate keyboard manager with settings v2[Part-2] (#2107)
* Added CustomAction Data Models

* Updated data model

* Updated Button command trigger for keyboard manager

* Integerated custom actions in Keyboard manager module backend

* Allow Runner to launch windows on foreground

* Refactor and moved the execution logic to background thread

* Removed non-required unlock calls

* Fixed typo

* Resolve PR comments
2020-04-14 09:24:11 -07:00

51 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 System.Threading.Tasks;
using System.Windows.Input;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Lib.Utilities;
using Microsoft.PowerToys.Settings.UI.Views;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class KeyboardManagerViewModel : Observable
{
private ICommand remapKeyboardCommand;
private ICommand editShortcutCommand;
public ICommand RemapKeyboardCommand => remapKeyboardCommand ?? (remapKeyboardCommand = new RelayCommand(OnRemapKeyboard));
public ICommand EditShortcutCommand => editShortcutCommand ?? (editShortcutCommand = new RelayCommand(OnEditShortcut));
public KeyboardManagerViewModel()
{
}
private async void OnRemapKeyboard()
{
await Task.Run(() => OnRemapKeyboardBackground());
}
private async void OnEditShortcut()
{
await Task.Run(() => OnEditShortcutBackground());
}
private async Task OnRemapKeyboardBackground()
{
Helper.AllowRunnerToForeground();
ShellPage.DefaultSndMSGCallback(Helper.GetSerializedCustomAction("Keyboard Manager", "RemapKeyboard", "Create Remap Keyboard Window"));
await Task.CompletedTask;
}
private async Task OnEditShortcutBackground()
{
Helper.AllowRunnerToForeground();
ShellPage.DefaultSndMSGCallback(Helper.GetSerializedCustomAction("Keyboard Manager", "EditShortcut", "Create Edit Shortcut Window"));
await Task.CompletedTask;
}
}
}