// 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; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO.Abstractions; using System.Linq; using System.Windows.Threading; using global::PowerToys.GPOWrapper; using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Helpers; using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Services; using Microsoft.PowerToys.Settings.UI.Views; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Windows.UI; namespace Microsoft.PowerToys.Settings.UI.ViewModels { public class DashboardViewModel : Observable { private const string JsonFileType = ".json"; private IFileSystemWatcher _watcher; private DashboardModuleKBMItem _kbmItem; private Dispatcher dispatcher; public Func SendConfigMSG { get; } public ObservableCollection ActiveModules { get; set; } = new ObservableCollection(); public ObservableCollection DisabledModules { get; set; } = new ObservableCollection(); public bool UpdateAvailable { get; set; } private List _allModules; private ISettingsRepository _settingsRepository; private GeneralSettings generalSettingsConfig; private Windows.ApplicationModel.Resources.ResourceLoader resourceLoader = Helpers.ResourceLoaderInstance.ResourceLoader; public DashboardViewModel(ISettingsRepository settingsRepository, Func ipcMSGCallBackFunc) { dispatcher = Dispatcher.CurrentDispatcher; _settingsRepository = settingsRepository; generalSettingsConfig = settingsRepository.SettingsConfig; generalSettingsConfig.AddEnabledModuleChangeNotification(ModuleEnabledChangedOnSettingsPage); // set the callback functions value to handle outgoing IPC message. SendConfigMSG = ipcMSGCallBackFunc; _allModules = new List(); foreach (ModuleType moduleType in Enum.GetValues(typeof(ModuleType))) { AddDashboardListItem(moduleType); } ActiveModules = new ObservableCollection(_allModules.Where(x => x.IsEnabled)); DisabledModules = new ObservableCollection(_allModules.Where(x => !x.IsEnabled)); UpdatingSettings updatingSettingsConfig = UpdatingSettings.LoadSettings(); UpdateAvailable = updatingSettingsConfig != null && (updatingSettingsConfig.State == UpdatingSettings.UpdatingState.ReadyToInstall || updatingSettingsConfig.State == UpdatingSettings.UpdatingState.ReadyToDownload); } private void AddDashboardListItem(ModuleType moduleType) { GpoRuleConfigured gpo = ModuleHelper.GetModuleGpoConfiguration(moduleType); _allModules.Add(new DashboardListItem() { Tag = moduleType, Label = resourceLoader.GetString(ModuleHelper.GetModuleLabelResourceName(moduleType)), IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, moduleType)), IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled, Icon = ModuleHelper.GetModuleTypeFluentIconName(moduleType), EnabledChangedCallback = EnabledChangedOnUI, AccentColor = GetModuleAccentColor(moduleType), DashboardModuleItems = GetModuleItems(moduleType), }); if (moduleType == ModuleType.KeyboardManager && gpo != GpoRuleConfigured.Disabled) { KeyboardManagerSettings kbmSettings = GetKBMSettings(); _watcher = Library.Utilities.Helper.GetFileWatcher(KeyboardManagerSettings.ModuleName, kbmSettings.Properties.ActiveConfiguration.Value + JsonFileType, () => LoadKBMSettingsFromJson()); } } private Color GetModuleAccentColor(ModuleType moduleType) { return moduleType switch { ModuleType.AlwaysOnTop => Color.FromArgb(255, 74, 196, 242), // #4ac4f2 ModuleType.Awake => Color.FromArgb(255, 40, 177, 233), // #28b1e9 ModuleType.ColorPicker => Color.FromArgb(255, 7, 129, 211), // #0781d3 ModuleType.CropAndLock => Color.FromArgb(255, 32, 166, 228), // #20a6e4 ModuleType.EnvironmentVariables => Color.FromArgb(255, 16, 132, 208), // #1084d0 ModuleType.FancyZones => Color.FromArgb(255, 65, 209, 247), // #41d1f7 ModuleType.FileLocksmith => Color.FromArgb(255, 245, 161, 20), // #f5a114 ModuleType.FindMyMouse => Color.FromArgb(255, 104, 109, 112), // #686d70 ModuleType.Hosts => Color.FromArgb(255, 16, 132, 208), // #1084d0 ModuleType.ImageResizer => Color.FromArgb(255, 85, 207, 248), // #55cff8 ModuleType.KeyboardManager => Color.FromArgb(255, 224, 231, 238), // #e0e7ee ModuleType.MouseHighlighter => Color.FromArgb(255, 17, 126, 199), // #117ec7 ModuleType.MouseJump => Color.FromArgb(255, 240, 240, 239), // #f0f0ef ModuleType.MousePointerCrosshairs => Color.FromArgb(255, 25, 115, 182), // #1973b6 ModuleType.MouseWithoutBorders => Color.FromArgb(255, 31, 164, 227), // #1fa4e3 ModuleType.PastePlain => Color.FromArgb(255, 243, 156, 16), // #f39c10 ModuleType.Peek => Color.FromArgb(255, 255, 214, 103), // #ffd667 ModuleType.PowerRename => Color.FromArgb(255, 43, 186, 243), // #2bbaf3 ModuleType.PowerLauncher => Color.FromArgb(255, 51, 191, 240), // #33bff0 ModuleType.PowerAccent => Color.FromArgb(255, 84, 89, 92), // #54595c ModuleType.RegistryPreview => Color.FromArgb(255, 17, 80, 138), // #11508a ModuleType.MeasureTool => Color.FromArgb(255, 135, 144, 153), // #879099 ModuleType.ShortcutGuide => Color.FromArgb(255, 193, 202, 209), // #c1cad1 ModuleType.PowerOCR => Color.FromArgb(255, 24, 153, 224), // #1899e0 _ => Color.FromArgb(255, 255, 255, 255), // never called, all values listed above }; } private void LoadKBMSettingsFromJson() { KeyboardManagerProfile kbmProfile = GetKBMProfile(); _kbmItem.RemapKeys = kbmProfile?.RemapKeys.InProcessRemapKeys; _kbmItem.RemapShortcuts = KeyboardManagerViewModel.CombineShortcutLists(kbmProfile?.RemapShortcuts.GlobalRemapShortcuts, kbmProfile?.RemapShortcuts.AppSpecificRemapShortcuts); dispatcher.Invoke(new Action(() => UpdateKBMItems())); } private void UpdateKBMItems() { _kbmItem.NotifyPropertyChanged(nameof(_kbmItem.RemapKeys)); _kbmItem.NotifyPropertyChanged(nameof(_kbmItem.RemapShortcuts)); } private KeyboardManagerProfile GetKBMProfile() { KeyboardManagerSettings kbmSettings = GetKBMSettings(); const string PowerToyName = KeyboardManagerSettings.ModuleName; string fileName = kbmSettings.Properties.ActiveConfiguration.Value + JsonFileType; return new SettingsUtils().GetSettingsOrDefault(PowerToyName, fileName); } private KeyboardManagerSettings GetKBMSettings() { var settingsUtils = new SettingsUtils(); ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(settingsUtils); return moduleSettingsRepository.SettingsConfig; } private void EnabledChangedOnUI(DashboardListItem dashboardListItem) { Views.ShellPage.UpdateGeneralSettingsCallback(dashboardListItem.Tag, dashboardListItem.IsEnabled); } public void ModuleEnabledChangedOnSettingsPage() { ActiveModules.Clear(); DisabledModules.Clear(); generalSettingsConfig = _settingsRepository.SettingsConfig; foreach (DashboardListItem item in _allModules) { item.IsEnabled = ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, item.Tag); if (item.IsEnabled) { ActiveModules.Add(item); } else { DisabledModules.Add(item); } } OnPropertyChanged(nameof(ActiveModules)); OnPropertyChanged(nameof(DisabledModules)); } private ObservableCollection GetModuleItems(ModuleType moduleType) { return moduleType switch { ModuleType.AlwaysOnTop => GetModuleItemsAlwaysOnTop(), ModuleType.Awake => GetModuleItemsAwake(), ModuleType.ColorPicker => GetModuleItemsColorPicker(), ModuleType.CropAndLock => GetModuleItemsCropAndLock(), ModuleType.EnvironmentVariables => GetModuleItemsEnvironmentVariables(), ModuleType.FancyZones => GetModuleItemsFancyZones(), ModuleType.FileLocksmith => GetModuleItemsFileLocksmith(), ModuleType.FindMyMouse => GetModuleItemsFindMyMouse(), ModuleType.Hosts => GetModuleItemsHosts(), ModuleType.ImageResizer => GetModuleItemsImageResizer(), ModuleType.KeyboardManager => GetModuleItemsKeyboardManager(), ModuleType.MouseHighlighter => GetModuleItemsMouseHighlighter(), ModuleType.MouseJump => GetModuleItemsMouseJump(), ModuleType.MousePointerCrosshairs => GetModuleItemsMousePointerCrosshairs(), ModuleType.MouseWithoutBorders => GetModuleItemsMouseWithoutBorders(), ModuleType.PastePlain => GetModuleItemsPastePlain(), ModuleType.Peek => GetModuleItemsPeek(), ModuleType.PowerRename => GetModuleItemsPowerRename(), ModuleType.PowerLauncher => GetModuleItemsPowerLauncher(), ModuleType.PowerAccent => GetModuleItemsPowerAccent(), ModuleType.RegistryPreview => GetModuleItemsRegistryPreview(), ModuleType.MeasureTool => GetModuleItemsMeasureTool(), ModuleType.ShortcutGuide => GetModuleItemsShortcutGuide(), ModuleType.PowerOCR => GetModuleItemsPowerOCR(), _ => new ObservableCollection(), // never called, all values listed above }; } private ObservableCollection GetModuleItemsAlwaysOnTop() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(new SettingsUtils()); var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("AlwaysOnTop_ShortDescription"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.Hotkey.Value.GetKeysList() }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsAwake() { var list = new List { new DashboardModuleTextItem() { Label = resourceLoader.GetString("Awake_ShortDescription") }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsColorPicker() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(new SettingsUtils()); var settings = moduleSettingsRepository.SettingsConfig; var hotkey = settings.Properties.ActivationShortcut; var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("ColorPicker_ShortDescription"), Shortcut = hotkey.GetKeysList() }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsCropAndLock() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(new SettingsUtils()); var settings = moduleSettingsRepository.SettingsConfig; var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("CropAndLock_Thumbnail"), Shortcut = settings.Properties.ThumbnailHotkey.Value.GetKeysList() }, new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("CropAndLock_Reparent"), Shortcut = settings.Properties.ReparentHotkey.Value.GetKeysList() }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsEnvironmentVariables() { var list = new List { new DashboardModuleButtonItem() { ButtonTitle = resourceLoader.GetString("EnvironmentVariables_LaunchButtonControl/Header"), IsButtonDescriptionVisible = true, ButtonDescription = resourceLoader.GetString("EnvironmentVariables_LaunchButtonControl/Description"), ButtonGlyph = "\uEA37", ButtonClickHandler = EnvironmentVariablesLaunchClicked }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsFancyZones() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(new SettingsUtils()); var settings = moduleSettingsRepository.SettingsConfig; string activationMode = $"{resourceLoader.GetString(settings.Properties.FancyzonesShiftDrag.Value ? "FancyZones_ShiftDragCheckBoxControl_Header/Content" : "FancyZones_ActivationNoShiftDrag")}."; if (settings.Properties.FancyzonesMouseSwitch.Value) { activationMode += $" {resourceLoader.GetString("FancyZones_MouseDragCheckBoxControl_Header/Content")}."; } var list = new List { new DashboardModuleTextItem() { Label = activationMode }, new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("FancyZones_OpenEditor"), Shortcut = settings.Properties.FancyzonesEditorHotkey.Value.GetKeysList() }, new DashboardModuleButtonItem() { ButtonTitle = resourceLoader.GetString("FancyZones_LaunchEditorButtonControl/Header"), IsButtonDescriptionVisible = true, ButtonDescription = resourceLoader.GetString("FancyZones_LaunchEditorButtonControl/Description"), ButtonGlyph = "\uEB3C", ButtonClickHandler = FancyZoneLaunchClicked }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsFileLocksmith() { var list = new List { new DashboardModuleTextItem() { Label = resourceLoader.GetString("FileLocksmith_ShortDescription") }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsFindMyMouse() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(new SettingsUtils()); string shortDescription = resourceLoader.GetString("FindMyMouse_ShortDescription"); var settings = moduleSettingsRepository.SettingsConfig; var activationMethod = settings.Properties.ActivationMethod.Value; var list = new List(); if (activationMethod == 3) { var hotkey = settings.Properties.ActivationShortcut; list.Add(new DashboardModuleShortcutItem() { Label = shortDescription, Shortcut = hotkey.GetKeysList() }); } else { switch (activationMethod) { case 2: shortDescription += $". {resourceLoader.GetString("Dashboard_Activation")}: {resourceLoader.GetString("MouseUtils_FindMyMouse_ActivationShakeMouse/Content")}"; break; case 1: shortDescription += $". {resourceLoader.GetString("Dashboard_Activation")}: {resourceLoader.GetString("MouseUtils_FindMyMouse_ActivationDoubleRightControlPress/Content")}"; break; case 0: default: shortDescription += $". {resourceLoader.GetString("Dashboard_Activation")}: {resourceLoader.GetString("MouseUtils_FindMyMouse_ActivationDoubleControlPress/Content")}"; break; } list.Add(new DashboardModuleTextItem() { Label = shortDescription }); } return new ObservableCollection(list); } private ObservableCollection GetModuleItemsHosts() { var list = new List { new DashboardModuleButtonItem() { ButtonTitle = resourceLoader.GetString("Hosts_LaunchButtonControl/Header"), IsButtonDescriptionVisible = true, ButtonDescription = resourceLoader.GetString("Hosts_LaunchButtonControl/Description"), ButtonGlyph = "\uEA37", ButtonClickHandler = HostLaunchClicked }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsImageResizer() { var list = new List { new DashboardModuleTextItem() { Label = resourceLoader.GetString("ImageResizer_ShortDescription") }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsKeyboardManager() { KeyboardManagerProfile kbmProfile = GetKBMProfile(); _kbmItem = new DashboardModuleKBMItem() { RemapKeys = kbmProfile?.RemapKeys.InProcessRemapKeys, RemapShortcuts = KeyboardManagerViewModel.CombineShortcutLists(kbmProfile?.RemapShortcuts.GlobalRemapShortcuts, kbmProfile?.RemapShortcuts.AppSpecificRemapShortcuts) }; var list = new List { _kbmItem, new DashboardModuleButtonItem() { ButtonTitle = resourceLoader.GetString("KeyboardManager_RemapKeyboardButton/Header"), IsButtonDescriptionVisible = true, ButtonDescription = resourceLoader.GetString("KeyboardManager_RemapKeyboardButton/Description"), ButtonGlyph = "\uE92E", ButtonClickHandler = KbmKeyLaunchClicked }, new DashboardModuleButtonItem() { ButtonTitle = resourceLoader.GetString("KeyboardManager_RemapShortcutsButton/Header"), IsButtonDescriptionVisible = true, ButtonDescription = resourceLoader.GetString("KeyboardManager_RemapShortcutsButton/Description"), ButtonGlyph = "\uE92E", ButtonClickHandler = KbmShortcutLaunchClicked }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsMouseHighlighter() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(new SettingsUtils()); var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("MouseHighlighter_ShortDescription"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.ActivationShortcut.GetKeysList() }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsMouseJump() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(new SettingsUtils()); var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("MouseJump_ShortDescription"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.ActivationShortcut.GetKeysList() }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsMousePointerCrosshairs() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(new SettingsUtils()); var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("MouseCrosshairs_ShortDescription"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.ActivationShortcut.GetKeysList() }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsMouseWithoutBorders() { var list = new List { new DashboardModuleTextItem() { Label = resourceLoader.GetString("MouseWithoutBorders_ShortDescription") }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsPastePlain() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(new SettingsUtils()); var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("PastePlain_ShortDescription"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.ActivationShortcut.GetKeysList() }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsPeek() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(new SettingsUtils()); var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("Peek_ShortDescription"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.ActivationShortcut.GetKeysList() }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsPowerRename() { var list = new List { new DashboardModuleTextItem() { Label = resourceLoader.GetString("PowerRename_ShortDescription") }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsPowerLauncher() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(new SettingsUtils()); var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("Run_ShortDescription"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.OpenPowerLauncher.GetKeysList() }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsPowerAccent() { string shortDescription = resourceLoader.GetString("PowerAccent_ShortDescription"); var settingsUtils = new SettingsUtils(); PowerAccentSettings moduleSettings = settingsUtils.GetSettingsOrDefault(PowerAccentSettings.ModuleName); var activationMethod = moduleSettings.Properties.ActivationKey; switch (activationMethod) { case Library.Enumerations.PowerAccentActivationKey.LeftRightArrow: shortDescription += $". {resourceLoader.GetString("Dashboard_Activation")}: {resourceLoader.GetString("QuickAccent_Activation_Key_Arrows/Content")}"; break; case Library.Enumerations.PowerAccentActivationKey.Space: shortDescription += $". {resourceLoader.GetString("Dashboard_Activation")}: {resourceLoader.GetString("QuickAccent_Activation_Key_Space/Content")}"; break; case Library.Enumerations.PowerAccentActivationKey.Both: shortDescription += $". {resourceLoader.GetString("Dashboard_Activation")}: {resourceLoader.GetString("QuickAccent_Activation_Key_Either/Content")}"; break; } var list = new List { new DashboardModuleTextItem() { Label = shortDescription }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsRegistryPreview() { var list = new List { new DashboardModuleButtonItem() { ButtonTitle = resourceLoader.GetString("RegistryPreview_LaunchButtonControl/Header"), ButtonGlyph = "\uEA37", ButtonClickHandler = RegistryPreviewLaunchClicked }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsMeasureTool() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(new SettingsUtils()); var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("ScreenRuler_ShortDescription"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.ActivationShortcut.GetKeysList() }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsShortcutGuide() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(new SettingsUtils()); var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("ShortcutGuide_ShortDescription"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.OpenShortcutGuide.GetKeysList() }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsPowerOCR() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(new SettingsUtils()); var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("PowerOcr_ShortDescription"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.ActivationShortcut.GetKeysList() }, }; return new ObservableCollection(list); } internal void SWVersionButtonClicked() { NavigationService.Navigate(typeof(GeneralPage)); } private void EnvironmentVariablesLaunchClicked(object sender, RoutedEventArgs e) { var settingsUtils = new SettingsUtils(); var environmentVariablesViewModel = new EnvironmentVariablesViewModel(settingsUtils, SettingsRepository.GetInstance(settingsUtils), SettingsRepository.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage, App.IsElevated); environmentVariablesViewModel.Launch(); } private void HostLaunchClicked(object sender, RoutedEventArgs e) { var settingsUtils = new SettingsUtils(); var hostsViewModel = new HostsViewModel(settingsUtils, SettingsRepository.GetInstance(settingsUtils), SettingsRepository.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage, App.IsElevated); hostsViewModel.Launch(); } private void FancyZoneLaunchClicked(object sender, RoutedEventArgs e) { // send message to launch the zones editor; SendConfigMSG("{\"action\":{\"FancyZones\":{\"action_name\":\"ToggledFZEditor\", \"value\":\"\"}}}"); } private void KbmKeyLaunchClicked(object sender, RoutedEventArgs e) { var settingsUtils = new SettingsUtils(); var kbmViewModel = new KeyboardManagerViewModel(settingsUtils, SettingsRepository.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage, KeyboardManagerPage.FilterRemapKeysList); kbmViewModel.OnRemapKeyboard(); } private void KbmShortcutLaunchClicked(object sender, RoutedEventArgs e) { var settingsUtils = new SettingsUtils(); var kbmViewModel = new KeyboardManagerViewModel(settingsUtils, SettingsRepository.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage, KeyboardManagerPage.FilterRemapKeysList); kbmViewModel.OnEditShortcut(); } private void RegistryPreviewLaunchClicked(object sender, RoutedEventArgs e) { var actionName = "Launch"; SendConfigMSG("{\"action\":{\"RegistryPreview\":{\"action_name\":\"" + actionName + "\", \"value\":\"\"}}}"); } } }