// 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.Threading.Tasks; using System.Windows.Threading; using CommunityToolkit.WinUI.Controls; 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.HotkeyConflicts; using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Utilities; using Microsoft.PowerToys.Settings.UI.Services; using Microsoft.PowerToys.Settings.UI.Views; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Settings.UI.Library; namespace Microsoft.PowerToys.Settings.UI.ViewModels { public partial class DashboardViewModel : PageViewModelBase { protected override string ModuleName => "Dashboard"; private Dispatcher dispatcher; public Func SendConfigMSG { get; } public ObservableCollection AllModules { get; set; } = new ObservableCollection(); public ObservableCollection ShortcutModules { get; set; } = new ObservableCollection(); public ObservableCollection ActionModules { get; set; } = new ObservableCollection(); // Master list of module items that is sorted and projected into AllModules. private List _moduleItems = new List(); // Flag to prevent circular updates when a UI toggle triggers settings changes. private bool _isUpdatingFromUI; private AllHotkeyConflictsData _allHotkeyConflictsData = new AllHotkeyConflictsData(); public AllHotkeyConflictsData AllHotkeyConflictsData { get => _allHotkeyConflictsData; set { if (Set(ref _allHotkeyConflictsData, value)) { OnPropertyChanged(); } } } public string PowerToysVersion { get { return Helper.GetProductVersion(); } } private DashboardSortOrder _dashboardSortOrder = DashboardSortOrder.Alphabetical; public DashboardSortOrder DashboardSortOrder { get => generalSettingsConfig.DashboardSortOrder; set { if (Set(ref _dashboardSortOrder, value)) { generalSettingsConfig.DashboardSortOrder = value; OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(generalSettingsConfig); SendConfigMSG(outgoing.ToString()); SortModuleList(); } } } 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); // Initialize dashboard sort order from settings _dashboardSortOrder = generalSettingsConfig.DashboardSortOrder; // set the callback functions value to handle outgoing IPC message. SendConfigMSG = ipcMSGCallBackFunc; BuildModuleList(); SortModuleList(); RefreshShortcutModules(); } protected override void OnConflictsUpdated(object sender, AllHotkeyConflictsEventArgs e) { dispatcher.BeginInvoke(() => { var allConflictData = e.Conflicts; foreach (var inAppConflict in allConflictData.InAppConflicts) { var hotkey = inAppConflict.Hotkey; var hotkeySetting = new HotkeySettings(hotkey.Win, hotkey.Ctrl, hotkey.Alt, hotkey.Shift, hotkey.Key); inAppConflict.ConflictIgnored = HotkeyConflictIgnoreHelper.IsIgnoringConflicts(hotkeySetting); } foreach (var systemConflict in allConflictData.SystemConflicts) { var hotkey = systemConflict.Hotkey; var hotkeySetting = new HotkeySettings(hotkey.Win, hotkey.Ctrl, hotkey.Alt, hotkey.Shift, hotkey.Key); systemConflict.ConflictIgnored = HotkeyConflictIgnoreHelper.IsIgnoringConflicts(hotkeySetting); } AllHotkeyConflictsData = e.Conflicts ?? new AllHotkeyConflictsData(); }); } private void RequestConflictData() { // Request current conflicts data GlobalHotkeyConflictManager.Instance?.RequestAllConflicts(); } /// /// Builds the master list of module items. Called once during initialization. /// Each module item contains its configuration, enabled state, and GPO lock status. /// private void BuildModuleList() { _moduleItems.Clear(); foreach (ModuleType moduleType in Enum.GetValues()) { GpoRuleConfigured gpo = ModuleHelper.GetModuleGpoConfiguration(moduleType); var newItem = 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), IsNew = moduleType == ModuleType.CursorWrap, DashboardModuleItems = GetModuleItems(moduleType), }; newItem.EnabledChangedCallback = EnabledChangedOnUI; _moduleItems.Add(newItem); } } /// /// Sorts the module list according to the current sort order and updates the AllModules collection. /// On first call, populates AllModules. On subsequent calls, uses Move() to reorder items in-place /// to avoid destroying and recreating UI elements. /// private void SortModuleList() { var sortedItems = (DashboardSortOrder switch { DashboardSortOrder.ByStatus => _moduleItems.OrderByDescending(x => x.IsEnabled).ThenBy(x => x.Label), _ => _moduleItems.OrderBy(x => x.Label), // Default alphabetical }).ToList(); // If AllModules is empty (first load), just populate it. if (AllModules.Count == 0) { foreach (var item in sortedItems) { AllModules.Add(item); } return; } // Otherwise, update the collection in place using Move to avoid UI glitches. for (int i = 0; i < sortedItems.Count; i++) { var currentItem = sortedItems[i]; var currentIndex = AllModules.IndexOf(currentItem); if (currentIndex != -1 && currentIndex != i) { AllModules.Move(currentIndex, i); } } // Notify that DashboardSortOrder changed so the menu updates its checked state. OnPropertyChanged(nameof(DashboardSortOrder)); } /// /// Refreshes module enabled/locked states by re-reading GPO configuration. Only /// updates properties that have actually changed to minimize UI notifications /// then re-sorts the list according to the current sort order. /// private void RefreshModuleList() { foreach (var item in _moduleItems) { GpoRuleConfigured gpo = ModuleHelper.GetModuleGpoConfiguration(item.Tag); // GPO can force-enable (Enabled) or force-disable (Disabled) a module. // If Enabled: module is on and the user cannot disable it. // If Disabled: module is off and the user cannot enable it. // Otherwise, the setting is unlocked and the user can enable/disable it. bool newEnabledState = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, item.Tag)); // Lock the toggle when GPO is controlling the module. bool newLockedState = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled; // Only update if there's an actual change to minimize UI notifications. if (item.IsEnabled != newEnabledState) { item.IsEnabled = newEnabledState; } if (item.IsLocked != newLockedState) { item.IsLocked = newLockedState; } } SortModuleList(); } /// /// Callback invoked when a user toggles a module's enabled state in the UI. /// Sets the _isUpdatingFromUI flag to prevent circular updates, then updates /// settings, re-sorts if needed, and refreshes dependent collections. /// private void EnabledChangedOnUI(DashboardListItem dashboardListItem) { _isUpdatingFromUI = true; try { Views.ShellPage.UpdateGeneralSettingsCallback(dashboardListItem.Tag, dashboardListItem.IsEnabled); if (dashboardListItem.Tag == ModuleType.NewPlus && dashboardListItem.IsEnabled == true) { var settingsUtils = SettingsUtils.Default; var settings = NewPlusViewModel.LoadSettings(settingsUtils); NewPlusViewModel.CopyTemplateExamples(settings.Properties.TemplateLocation.Value); } // Re-sort only required if sorting by enabled status. if (DashboardSortOrder == DashboardSortOrder.ByStatus) { SortModuleList(); } // Always refresh shortcuts/actions to reflect enabled state changes. RefreshShortcutModules(); // Request updated conflicts after module state change. RequestConflictData(); } finally { _isUpdatingFromUI = false; } } /// /// Callback invoked when module enabled state changes from other parts of the /// settings UI. Ignores the notification if it was triggered by a UI toggle /// we're already handling, to prevent circular updates. /// public void ModuleEnabledChangedOnSettingsPage() { // Ignore if this was triggered by a UI change that we're already handling. if (_isUpdatingFromUI) { return; } try { RefreshModuleList(); RefreshShortcutModules(); OnPropertyChanged(nameof(ShortcutModules)); // Request updated conflicts after module state change. RequestConflictData(); } catch (Exception ex) { Logger.LogError($"Updating active/disabled modules list failed: {ex.Message}"); } } /// /// Rebuilds ShortcutModules and ActionModules collections by filtering AllModules /// to only include enabled modules and their respective shortcut/action items. /// private void RefreshShortcutModules() { ShortcutModules.Clear(); ActionModules.Clear(); foreach (var x in AllModules.Where(x => x.IsEnabled)) { var filteredItems = x.DashboardModuleItems .Where(m => m is DashboardModuleShortcutItem || m is DashboardModuleActivationItem) .ToList(); if (filteredItems.Count != 0) { var newItem = new DashboardListItem { Icon = x.Icon, IsLocked = x.IsLocked, Label = x.Label, Tag = x.Tag, IsEnabled = x.IsEnabled, DashboardModuleItems = new ObservableCollection(filteredItems), }; ShortcutModules.Add(newItem); newItem.EnabledChangedCallback = x.EnabledChangedCallback; } } foreach (var x in AllModules.Where(x => x.IsEnabled)) { var filteredItems = x.DashboardModuleItems .Where(m => m is DashboardModuleButtonItem) .ToList(); if (filteredItems.Count != 0) { var newItem = new DashboardListItem { Icon = x.Icon, IsLocked = x.IsLocked, Label = x.Label, Tag = x.Tag, IsEnabled = x.IsEnabled, DashboardModuleItems = new ObservableCollection(filteredItems), }; ActionModules.Add(newItem); newItem.EnabledChangedCallback = x.EnabledChangedCallback; } } } private ObservableCollection GetModuleItems(ModuleType moduleType) { return moduleType switch { ModuleType.AdvancedPaste => GetModuleItemsAdvancedPaste(), ModuleType.AlwaysOnTop => GetModuleItemsAlwaysOnTop(), ModuleType.CmdPal => GetModuleItemsCmdPal(), ModuleType.ColorPicker => GetModuleItemsColorPicker(), ModuleType.CropAndLock => GetModuleItemsCropAndLock(), ModuleType.EnvironmentVariables => GetModuleItemsEnvironmentVariables(), ModuleType.FancyZones => GetModuleItemsFancyZones(), ModuleType.FindMyMouse => GetModuleItemsFindMyMouse(), ModuleType.Hosts => GetModuleItemsHosts(), ModuleType.LightSwitch => GetModuleItemsLightSwitch(), ModuleType.MouseHighlighter => GetModuleItemsMouseHighlighter(), ModuleType.MouseJump => GetModuleItemsMouseJump(), ModuleType.MousePointerCrosshairs => GetModuleItemsMousePointerCrosshairs(), ModuleType.Peek => GetModuleItemsPeek(), ModuleType.PowerLauncher => GetModuleItemsPowerLauncher(), ModuleType.PowerAccent => GetModuleItemsPowerAccent(), ModuleType.Workspaces => GetModuleItemsWorkspaces(), 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(SettingsUtils.Default); var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("AlwaysOnTop_ShortDescription"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.Hotkey.Value.GetKeysList() }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsCmdPal() { var hotkey = new CmdPalProperties().Hotkey; var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("CmdPal_ActivationDescription"), Shortcut = hotkey.GetKeysList() }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsColorPicker() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(SettingsUtils.Default); 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 GetModuleItemsLightSwitch() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(SettingsUtils.Default); var settings = moduleSettingsRepository.SettingsConfig; var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("LightSwitch_ForceDarkMode"), Shortcut = settings.Properties.ToggleThemeHotkey.Value.GetKeysList() }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsCropAndLock() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(SettingsUtils.Default); 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() }, new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("CropAndLock_Screenshot"), Shortcut = settings.Properties.ScreenshotHotkey.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 = "ms-appx:///Assets/Settings/Icons/EnvironmentVariables.png", ButtonClickHandler = EnvironmentVariablesLaunchClicked }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsFancyZones() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(SettingsUtils.Default); var settings = moduleSettingsRepository.SettingsConfig; string activationMode = $"{resourceLoader.GetString(settings.Properties.FancyzonesShiftDrag.Value ? "FancyZones_ActivationShiftDrag" : "FancyZones_ActivationNoShiftDrag")}."; var list = new List { new DashboardModuleActivationItem() { Label = resourceLoader.GetString("Activate_Zones"), Activation = 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 = "ms-appx:///Assets/Settings/Icons/FancyZones.png", ButtonClickHandler = FancyZoneLaunchClicked }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsFindMyMouse() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(SettingsUtils.Default); 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 { string activation = string.Empty; switch (activationMethod) { case 2: activation = resourceLoader.GetString("MouseUtils_FindMyMouse_ActivationShakeMouse/Content"); break; case 1: activation = resourceLoader.GetString("MouseUtils_FindMyMouse_ActivationDoubleRightControlPress/Content"); break; case 0: default: activation = resourceLoader.GetString("MouseUtils_FindMyMouse_ActivationDoubleControlPress/Content"); break; } list.Add(new DashboardModuleActivationItem() { Label = resourceLoader.GetString("Dashboard_Activation"), Activation = activation }); } 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 = "ms-appx:///Assets/Settings/Icons/Hosts.png", ButtonClickHandler = HostLaunchClicked }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsMouseHighlighter() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(SettingsUtils.Default); 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(SettingsUtils.Default); 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(SettingsUtils.Default); var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("MouseCrosshairs_ShortDescription"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.ActivationShortcut.GetKeysList() }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsAdvancedPaste() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(SettingsUtils.Default); var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("AdvancedPasteUI_Shortcut/Header"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.AdvancedPasteUIShortcut.GetKeysList() }, new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("PasteAsPlainText_Shortcut/Header"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.PasteAsPlainTextShortcut.GetKeysList() }, }; if (moduleSettingsRepository.SettingsConfig.Properties.PasteAsMarkdownShortcut.GetKeysList().Count > 0) { list.Add(new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("PasteAsMarkdown_Shortcut/Header"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.PasteAsMarkdownShortcut.GetKeysList() }); } if (moduleSettingsRepository.SettingsConfig.Properties.PasteAsJsonShortcut.GetKeysList().Count > 0) { list.Add(new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("PasteAsJson_Shortcut/Header"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.PasteAsJsonShortcut.GetKeysList() }); } return new ObservableCollection(list); } private ObservableCollection GetModuleItemsPeek() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(SettingsUtils.Default); var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("Peek_ShortDescription"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.ActivationShortcut.GetKeysList() }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsPowerLauncher() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(SettingsUtils.Default); var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("Run_ShortDescription"), Shortcut = moduleSettingsRepository.SettingsConfig.Properties.OpenPowerLauncher.GetKeysList() }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsPowerAccent() { var settingsUtils = SettingsUtils.Default; PowerAccentSettings moduleSettings = settingsUtils.GetSettingsOrDefault(PowerAccentSettings.ModuleName); var activationMethod = moduleSettings.Properties.ActivationKey; string activation = string.Empty; switch (activationMethod) { case Library.Enumerations.PowerAccentActivationKey.LeftRightArrow: activation = resourceLoader.GetString("QuickAccent_Activation_Key_Arrows/Content"); break; case Library.Enumerations.PowerAccentActivationKey.Space: activation = resourceLoader.GetString("QuickAccent_Activation_Key_Space/Content"); break; case Library.Enumerations.PowerAccentActivationKey.Both: activation = resourceLoader.GetString("QuickAccent_Activation_Key_Either/Content"); break; } var list = new List { new DashboardModuleActivationItem() { Label = resourceLoader.GetString("Dashboard_Activation"), Activation = activation }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsWorkspaces() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(SettingsUtils.Default); var settings = moduleSettingsRepository.SettingsConfig; var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("Workspaces_ShortDescription"), Shortcut = settings.Properties.Hotkey.Value.GetKeysList() }, new DashboardModuleButtonItem() { ButtonTitle = resourceLoader.GetString("Workspaces_LaunchEditorButtonControl/Header"), IsButtonDescriptionVisible = true, ButtonDescription = resourceLoader.GetString("FancyZones_LaunchEditorButtonControl/Description"), ButtonGlyph = "ms-appx:///Assets/Settings/Icons/Workspaces.png", ButtonClickHandler = WorkspacesLaunchClicked }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsRegistryPreview() { var list = new List { new DashboardModuleButtonItem() { ButtonTitle = resourceLoader.GetString("RegistryPreview_LaunchButtonControl/Header"), ButtonGlyph = "ms-appx:///Assets/Settings/Icons/RegistryPreview.png", ButtonClickHandler = RegistryPreviewLaunchClicked }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsMeasureTool() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(SettingsUtils.Default); 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(SettingsUtils.Default); var shortcut = moduleSettingsRepository.SettingsConfig.Properties.UseLegacyPressWinKeyBehavior.Value ? new List { 92 } // Right Windows key code : moduleSettingsRepository.SettingsConfig.Properties.OpenShortcutGuide.GetKeysList(); var list = new List { new DashboardModuleShortcutItem() { Label = resourceLoader.GetString("ShortcutGuide_ShortDescription"), Shortcut = shortcut }, }; return new ObservableCollection(list); } private ObservableCollection GetModuleItemsPowerOCR() { ISettingsRepository moduleSettingsRepository = SettingsRepository.GetInstance(SettingsUtils.Default); 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 = SettingsUtils.Default; 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 = SettingsUtils.Default; 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 WorkspacesLaunchClicked(object sender, RoutedEventArgs e) { // send message to launch the Workspaces editor; SendConfigMSG("{\"action\":{\"Workspaces\":{\"action_name\":\"LaunchEditor\", \"value\":\"\"}}}"); } private void RegistryPreviewLaunchClicked(object sender, RoutedEventArgs e) { var actionName = "Launch"; SendConfigMSG("{\"action\":{\"RegistryPreview\":{\"action_name\":\"" + actionName + "\", \"value\":\"\"}}}"); } internal void DashboardListItemClick(object sender) { if (sender is SettingsCard card && card.Tag is ModuleType moduleType) { NavigationService.Navigate(ModuleHelper.GetModulePageType(moduleType)); } } } }