2020-04-09 04:53:09 +08:00
|
|
|
|
// 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.
|
2020-04-15 00:24:11 +08:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|