[Settings]Refactor module data for Dashboard and Flyout (#29555)
* Intoducing ModuleType enum, restructuring Dashboard AllApps page * Restructuring LauncherViewModel + fix spell checker * Restructuring Dashboard page * Fixing MousePointerCrossHair icon path, refactoring UpdatingGeneralSettingsCallback method * Updating Flyout Launch page. * Fix logging
This commit is contained in:
Родитель
97a8aeb118
Коммит
2c83d36954
|
@ -0,0 +1,34 @@
|
|||
// 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.
|
||||
|
||||
namespace ManagedCommon
|
||||
{
|
||||
public enum ModuleType
|
||||
{
|
||||
AlwaysOnTop,
|
||||
Awake,
|
||||
ColorPicker,
|
||||
CropAndLock,
|
||||
EnvironmentVariables,
|
||||
FancyZones,
|
||||
FileLocksmith,
|
||||
FindMyMouse,
|
||||
Hosts,
|
||||
ImageResizer,
|
||||
KeyboardManager,
|
||||
MouseHighlighter,
|
||||
MouseJump,
|
||||
MousePointerCrosshairs,
|
||||
MouseWithoutBorders,
|
||||
PastePlain,
|
||||
Peek,
|
||||
PowerRename,
|
||||
PowerLauncher,
|
||||
PowerAccent,
|
||||
RegistryPreview,
|
||||
MeasureTool,
|
||||
ShortcutGuide,
|
||||
PowerOCR,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
// 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 global::PowerToys.GPOWrapper;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Helpers
|
||||
{
|
||||
internal sealed class ModuleHelper
|
||||
{
|
||||
public static string GetModuleLabelResourceName(ModuleType moduleType)
|
||||
{
|
||||
switch (moduleType)
|
||||
{
|
||||
case ModuleType.PowerAccent: return "QuickAccent/ModuleTitle";
|
||||
case ModuleType.PowerOCR: return "TextExtractor/ModuleTitle";
|
||||
case ModuleType.FindMyMouse:
|
||||
case ModuleType.MouseHighlighter:
|
||||
case ModuleType.MouseJump:
|
||||
case ModuleType.MousePointerCrosshairs: return $"MouseUtils_{moduleType}/Header";
|
||||
default: return $"{moduleType}/ModuleTitle";
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetModuleTypeFluentIconName(ModuleType moduleType)
|
||||
{
|
||||
switch (moduleType)
|
||||
{
|
||||
case ModuleType.MousePointerCrosshairs: return "ms-appx:///Assets/Settings/FluentIcons/FluentIconsMouseCrosshairs.png";
|
||||
case ModuleType.MeasureTool: return "ms-appx:///Assets/Settings/FluentIcons/FluentIconsScreenRuler.png";
|
||||
case ModuleType.PowerLauncher: return $"ms-appx:///Assets/Settings/FluentIcons/FluentIconsPowerToysRun.png";
|
||||
default: return $"ms-appx:///Assets/Settings/FluentIcons/FluentIcons{moduleType}.png";
|
||||
}
|
||||
}
|
||||
|
||||
public static bool GetIsModuleEnabled(Library.GeneralSettings generalSettingsConfig, ModuleType moduleType)
|
||||
{
|
||||
switch (moduleType)
|
||||
{
|
||||
case ModuleType.AlwaysOnTop: return generalSettingsConfig.Enabled.AlwaysOnTop;
|
||||
case ModuleType.Awake: return generalSettingsConfig.Enabled.Awake;
|
||||
case ModuleType.ColorPicker: return generalSettingsConfig.Enabled.ColorPicker;
|
||||
case ModuleType.CropAndLock: return generalSettingsConfig.Enabled.CropAndLock;
|
||||
case ModuleType.EnvironmentVariables: return generalSettingsConfig.Enabled.EnvironmentVariables;
|
||||
case ModuleType.FancyZones: return generalSettingsConfig.Enabled.FancyZones;
|
||||
case ModuleType.FileLocksmith: return generalSettingsConfig.Enabled.FileLocksmith;
|
||||
case ModuleType.FindMyMouse: return generalSettingsConfig.Enabled.FindMyMouse;
|
||||
case ModuleType.Hosts: return generalSettingsConfig.Enabled.Hosts;
|
||||
case ModuleType.ImageResizer: return generalSettingsConfig.Enabled.ImageResizer;
|
||||
case ModuleType.KeyboardManager: return generalSettingsConfig.Enabled.KeyboardManager;
|
||||
case ModuleType.MouseHighlighter: return generalSettingsConfig.Enabled.MouseHighlighter;
|
||||
case ModuleType.MouseJump: return generalSettingsConfig.Enabled.MouseJump;
|
||||
case ModuleType.MousePointerCrosshairs: return generalSettingsConfig.Enabled.MousePointerCrosshairs;
|
||||
case ModuleType.MouseWithoutBorders: return generalSettingsConfig.Enabled.MouseWithoutBorders;
|
||||
case ModuleType.PastePlain: return generalSettingsConfig.Enabled.PastePlain;
|
||||
case ModuleType.Peek: return generalSettingsConfig.Enabled.Peek;
|
||||
case ModuleType.PowerRename: return generalSettingsConfig.Enabled.PowerRename;
|
||||
case ModuleType.PowerLauncher: return generalSettingsConfig.Enabled.PowerLauncher;
|
||||
case ModuleType.PowerAccent: return generalSettingsConfig.Enabled.PowerAccent;
|
||||
case ModuleType.RegistryPreview: return generalSettingsConfig.Enabled.RegistryPreview;
|
||||
case ModuleType.MeasureTool: return generalSettingsConfig.Enabled.MeasureTool;
|
||||
case ModuleType.ShortcutGuide: return generalSettingsConfig.Enabled.ShortcutGuide;
|
||||
case ModuleType.PowerOCR: return generalSettingsConfig.Enabled.PowerOCR;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal static void SetIsModuleEnabled(GeneralSettings generalSettingsConfig, ModuleType moduleType, bool isEnabled)
|
||||
{
|
||||
switch (moduleType)
|
||||
{
|
||||
case ModuleType.AlwaysOnTop: generalSettingsConfig.Enabled.AlwaysOnTop = isEnabled; break;
|
||||
case ModuleType.Awake: generalSettingsConfig.Enabled.Awake = isEnabled; break;
|
||||
case ModuleType.ColorPicker: generalSettingsConfig.Enabled.ColorPicker = isEnabled; break;
|
||||
case ModuleType.CropAndLock: generalSettingsConfig.Enabled.CropAndLock = isEnabled; break;
|
||||
case ModuleType.EnvironmentVariables: generalSettingsConfig.Enabled.EnvironmentVariables = isEnabled; break;
|
||||
case ModuleType.FancyZones: generalSettingsConfig.Enabled.FancyZones = isEnabled; break;
|
||||
case ModuleType.FileLocksmith: generalSettingsConfig.Enabled.FileLocksmith = isEnabled; break;
|
||||
case ModuleType.FindMyMouse: generalSettingsConfig.Enabled.FindMyMouse = isEnabled; break;
|
||||
case ModuleType.Hosts: generalSettingsConfig.Enabled.Hosts = isEnabled; break;
|
||||
case ModuleType.ImageResizer: generalSettingsConfig.Enabled.ImageResizer = isEnabled; break;
|
||||
case ModuleType.KeyboardManager: generalSettingsConfig.Enabled.KeyboardManager = isEnabled; break;
|
||||
case ModuleType.MouseHighlighter: generalSettingsConfig.Enabled.MouseHighlighter = isEnabled; break;
|
||||
case ModuleType.MouseJump: generalSettingsConfig.Enabled.MouseJump = isEnabled; break;
|
||||
case ModuleType.MousePointerCrosshairs: generalSettingsConfig.Enabled.MousePointerCrosshairs = isEnabled; break;
|
||||
case ModuleType.MouseWithoutBorders: generalSettingsConfig.Enabled.MouseWithoutBorders = isEnabled; break;
|
||||
case ModuleType.PastePlain: generalSettingsConfig.Enabled.PastePlain = isEnabled; break;
|
||||
case ModuleType.Peek: generalSettingsConfig.Enabled.Peek = isEnabled; break;
|
||||
case ModuleType.PowerRename: generalSettingsConfig.Enabled.PowerRename = isEnabled; break;
|
||||
case ModuleType.PowerLauncher: generalSettingsConfig.Enabled.PowerLauncher = isEnabled; break;
|
||||
case ModuleType.PowerAccent: generalSettingsConfig.Enabled.PowerAccent = isEnabled; break;
|
||||
case ModuleType.RegistryPreview: generalSettingsConfig.Enabled.RegistryPreview = isEnabled; break;
|
||||
case ModuleType.MeasureTool: generalSettingsConfig.Enabled.MeasureTool = isEnabled; break;
|
||||
case ModuleType.ShortcutGuide: generalSettingsConfig.Enabled.ShortcutGuide = isEnabled; break;
|
||||
case ModuleType.PowerOCR: generalSettingsConfig.Enabled.PowerOCR = isEnabled; break;
|
||||
}
|
||||
}
|
||||
|
||||
public static GpoRuleConfigured GetModuleGpoConfiguration(ModuleType moduleType)
|
||||
{
|
||||
switch (moduleType)
|
||||
{
|
||||
case ModuleType.AlwaysOnTop: return GPOWrapper.GetConfiguredAlwaysOnTopEnabledValue();
|
||||
case ModuleType.Awake: return GPOWrapper.GetConfiguredAwakeEnabledValue();
|
||||
case ModuleType.ColorPicker: return GPOWrapper.GetConfiguredColorPickerEnabledValue();
|
||||
case ModuleType.CropAndLock: return GPOWrapper.GetConfiguredCropAndLockEnabledValue();
|
||||
case ModuleType.EnvironmentVariables: return GPOWrapper.GetConfiguredEnvironmentVariablesEnabledValue();
|
||||
case ModuleType.FancyZones: return GPOWrapper.GetConfiguredFancyZonesEnabledValue();
|
||||
case ModuleType.FileLocksmith: return GPOWrapper.GetConfiguredFileLocksmithEnabledValue();
|
||||
case ModuleType.FindMyMouse: return GPOWrapper.GetConfiguredFindMyMouseEnabledValue();
|
||||
case ModuleType.Hosts: return GPOWrapper.GetConfiguredHostsFileEditorEnabledValue();
|
||||
case ModuleType.ImageResizer: return GPOWrapper.GetConfiguredImageResizerEnabledValue();
|
||||
case ModuleType.KeyboardManager: return GPOWrapper.GetConfiguredKeyboardManagerEnabledValue();
|
||||
case ModuleType.MouseHighlighter: return GPOWrapper.GetConfiguredMouseHighlighterEnabledValue();
|
||||
case ModuleType.MouseJump: return GPOWrapper.GetConfiguredMouseJumpEnabledValue();
|
||||
case ModuleType.MousePointerCrosshairs: return GPOWrapper.GetConfiguredMousePointerCrosshairsEnabledValue();
|
||||
case ModuleType.MouseWithoutBorders: return GPOWrapper.GetConfiguredMouseWithoutBordersEnabledValue();
|
||||
case ModuleType.PastePlain: return GPOWrapper.GetConfiguredPastePlainEnabledValue();
|
||||
case ModuleType.Peek: return GPOWrapper.GetConfiguredPeekEnabledValue();
|
||||
case ModuleType.PowerRename: return GPOWrapper.GetConfiguredPowerRenameEnabledValue();
|
||||
case ModuleType.PowerLauncher: return GPOWrapper.GetConfiguredPowerLauncherEnabledValue();
|
||||
case ModuleType.PowerAccent: return GPOWrapper.GetConfiguredQuickAccentEnabledValue();
|
||||
case ModuleType.RegistryPreview: return GPOWrapper.GetConfiguredRegistryPreviewEnabledValue();
|
||||
case ModuleType.MeasureTool: return GPOWrapper.GetConfiguredScreenRulerEnabledValue();
|
||||
case ModuleType.ShortcutGuide: return GPOWrapper.GetConfiguredShortcutGuideEnabledValue();
|
||||
case ModuleType.PowerOCR: return GPOWrapper.GetConfiguredTextExtractorEnabledValue();
|
||||
default: return GpoRuleConfigured.Unavailable;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using System.Threading;
|
||||
using global::Windows.System;
|
||||
using interop;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Controls;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Telemetry.Events;
|
||||
|
@ -37,16 +38,16 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
|
|||
// Closing manually the flyout to workaround focus gain problems
|
||||
App.GetFlyoutWindow()?.Hide();
|
||||
|
||||
switch ((string)selectedModuleBtn.Tag)
|
||||
switch ((ModuleType)selectedModuleBtn.Tag)
|
||||
{
|
||||
case "ColorPicker": // Launch ColorPicker
|
||||
case ModuleType.ColorPicker: // Launch ColorPicker
|
||||
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.ShowColorPickerSharedEvent()))
|
||||
{
|
||||
eventHandle.Set();
|
||||
}
|
||||
|
||||
break;
|
||||
case "EnvironmentVariables": // Launch Environment Variables
|
||||
case ModuleType.EnvironmentVariables: // Launch Environment Variables
|
||||
{
|
||||
bool launchAdmin = SettingsRepository<EnvironmentVariablesSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.LaunchAdministrator;
|
||||
string eventName = !App.IsElevated && launchAdmin
|
||||
|
@ -61,7 +62,7 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
|
|||
|
||||
break;
|
||||
|
||||
case "FancyZones": // Launch FancyZones Editor
|
||||
case ModuleType.FancyZones: // Launch FancyZones Editor
|
||||
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.FZEToggleEvent()))
|
||||
{
|
||||
eventHandle.Set();
|
||||
|
@ -69,7 +70,7 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
|
|||
|
||||
break;
|
||||
|
||||
case "Hosts": // Launch Hosts
|
||||
case ModuleType.Hosts: // Launch Hosts
|
||||
{
|
||||
bool launchAdmin = SettingsRepository<HostsSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.LaunchAdministrator;
|
||||
string eventName = !App.IsElevated && launchAdmin
|
||||
|
@ -84,14 +85,14 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
|
|||
|
||||
break;
|
||||
|
||||
case "RegistryPreview": // Launch Registry Preview
|
||||
case ModuleType.RegistryPreview: // Launch Registry Preview
|
||||
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.RegistryPreviewTriggerEvent()))
|
||||
{
|
||||
eventHandle.Set();
|
||||
}
|
||||
|
||||
break;
|
||||
case "MeasureTool": // Launch Screen Ruler
|
||||
case ModuleType.MeasureTool: // Launch Screen Ruler
|
||||
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.MeasureToolTriggerEvent()))
|
||||
{
|
||||
eventHandle.Set();
|
||||
|
@ -99,7 +100,7 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
|
|||
|
||||
break;
|
||||
|
||||
case "PowerLauncher": // Launch Run
|
||||
case ModuleType.PowerLauncher: // Launch Run
|
||||
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.PowerLauncherSharedEvent()))
|
||||
{
|
||||
eventHandle.Set();
|
||||
|
@ -107,7 +108,7 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
|
|||
|
||||
break;
|
||||
|
||||
case "PowerOCR": // Launch Text Extractor
|
||||
case ModuleType.PowerOCR: // Launch Text Extractor
|
||||
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.ShowPowerOCRSharedEvent()))
|
||||
{
|
||||
eventHandle.Set();
|
||||
|
@ -115,7 +116,7 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
|
|||
|
||||
break;
|
||||
|
||||
case "ShortcutGuide": // Launch Shortcut Guide
|
||||
case ModuleType.ShortcutGuide: // Launch Shortcut Guide
|
||||
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.ShortcutGuideTriggerEvent()))
|
||||
{
|
||||
eventHandle.Set();
|
||||
|
@ -130,7 +131,7 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
|
|||
|
||||
if (moduleRun)
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new TrayFlyoutModuleRunEvent() { ModuleName = (string)selectedModuleBtn.Tag });
|
||||
PowerToysTelemetry.Log.WriteEvent(new TrayFlyoutModuleRunEvent() { ModuleName = ((ModuleType)selectedModuleBtn.Tag).ToString() });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,92 +81,15 @@ namespace Microsoft.PowerToys.Settings.UI
|
|||
});
|
||||
|
||||
// open main window
|
||||
ShellPage.SetUpdatingGeneralSettingsCallback((string module, bool isEnabled) =>
|
||||
ShellPage.SetUpdatingGeneralSettingsCallback((ModuleType moduleType, bool isEnabled) =>
|
||||
{
|
||||
SettingsRepository<GeneralSettings> repository = SettingsRepository<GeneralSettings>.GetInstance(new SettingsUtils());
|
||||
GeneralSettings generalSettingsConfig = repository.SettingsConfig;
|
||||
bool needToUpdate = false;
|
||||
switch (module)
|
||||
{
|
||||
case "AlwaysOnTop":
|
||||
needToUpdate = generalSettingsConfig.Enabled.AlwaysOnTop != isEnabled;
|
||||
generalSettingsConfig.Enabled.AlwaysOnTop = isEnabled; break;
|
||||
case "Awake":
|
||||
needToUpdate = generalSettingsConfig.Enabled.Awake != isEnabled;
|
||||
generalSettingsConfig.Enabled.Awake = isEnabled; break;
|
||||
case "ColorPicker":
|
||||
needToUpdate = generalSettingsConfig.Enabled.ColorPicker != isEnabled;
|
||||
generalSettingsConfig.Enabled.ColorPicker = isEnabled; break;
|
||||
case "CropAndLock":
|
||||
needToUpdate = generalSettingsConfig.Enabled.CropAndLock != isEnabled;
|
||||
generalSettingsConfig.Enabled.CropAndLock = isEnabled; break;
|
||||
case "EnvironmentVariables":
|
||||
needToUpdate = generalSettingsConfig.Enabled.EnvironmentVariables != isEnabled;
|
||||
generalSettingsConfig.Enabled.EnvironmentVariables = isEnabled; break;
|
||||
case "FancyZones":
|
||||
needToUpdate = generalSettingsConfig.Enabled.FancyZones != isEnabled;
|
||||
generalSettingsConfig.Enabled.FancyZones = isEnabled; break;
|
||||
case "FileLocksmith":
|
||||
needToUpdate = generalSettingsConfig.Enabled.FileLocksmith != isEnabled;
|
||||
generalSettingsConfig.Enabled.FileLocksmith = isEnabled; break;
|
||||
case "FindMyMouse":
|
||||
needToUpdate = generalSettingsConfig.Enabled.FindMyMouse != isEnabled;
|
||||
generalSettingsConfig.Enabled.FindMyMouse = isEnabled; break;
|
||||
case "Hosts":
|
||||
needToUpdate = generalSettingsConfig.Enabled.Hosts != isEnabled;
|
||||
generalSettingsConfig.Enabled.Hosts = isEnabled; break;
|
||||
case "ImageResizer":
|
||||
needToUpdate = generalSettingsConfig.Enabled.ImageResizer != isEnabled;
|
||||
generalSettingsConfig.Enabled.ImageResizer = isEnabled; break;
|
||||
case "KeyboardManager":
|
||||
needToUpdate = generalSettingsConfig.Enabled.KeyboardManager != isEnabled;
|
||||
generalSettingsConfig.Enabled.KeyboardManager = isEnabled; break;
|
||||
case "MouseHighlighter":
|
||||
needToUpdate = generalSettingsConfig.Enabled.MouseHighlighter != isEnabled;
|
||||
generalSettingsConfig.Enabled.MouseHighlighter = isEnabled; break;
|
||||
case "MouseJump":
|
||||
needToUpdate = generalSettingsConfig.Enabled.MouseJump != isEnabled;
|
||||
generalSettingsConfig.Enabled.MouseJump = isEnabled; break;
|
||||
case "MousePointerCrosshairs":
|
||||
needToUpdate = generalSettingsConfig.Enabled.MousePointerCrosshairs != isEnabled;
|
||||
generalSettingsConfig.Enabled.MousePointerCrosshairs = isEnabled; break;
|
||||
case "MouseWithoutBorders":
|
||||
needToUpdate = generalSettingsConfig.Enabled.MouseWithoutBorders != isEnabled;
|
||||
generalSettingsConfig.Enabled.MouseWithoutBorders = isEnabled; break;
|
||||
case "PastePlain":
|
||||
needToUpdate = generalSettingsConfig.Enabled.PastePlain != isEnabled;
|
||||
generalSettingsConfig.Enabled.PastePlain = isEnabled; break;
|
||||
case "Peek":
|
||||
needToUpdate = generalSettingsConfig.Enabled.Peek != isEnabled;
|
||||
generalSettingsConfig.Enabled.Peek = isEnabled; break;
|
||||
case "PowerRename":
|
||||
needToUpdate = generalSettingsConfig.Enabled.PowerRename != isEnabled;
|
||||
generalSettingsConfig.Enabled.PowerRename = isEnabled; break;
|
||||
case "PowerLauncher":
|
||||
needToUpdate = generalSettingsConfig.Enabled.PowerLauncher != isEnabled;
|
||||
generalSettingsConfig.Enabled.PowerLauncher = isEnabled; break;
|
||||
case "PowerAccent":
|
||||
needToUpdate = generalSettingsConfig.Enabled.PowerAccent != isEnabled;
|
||||
generalSettingsConfig.Enabled.PowerAccent = isEnabled; break;
|
||||
case "RegistryPreview":
|
||||
needToUpdate = generalSettingsConfig.Enabled.RegistryPreview != isEnabled;
|
||||
generalSettingsConfig.Enabled.RegistryPreview = isEnabled; break;
|
||||
case "MeasureTool":
|
||||
needToUpdate = generalSettingsConfig.Enabled.MeasureTool != isEnabled;
|
||||
generalSettingsConfig.Enabled.MeasureTool = isEnabled; break;
|
||||
case "ShortcutGuide":
|
||||
needToUpdate = generalSettingsConfig.Enabled.ShortcutGuide != isEnabled;
|
||||
generalSettingsConfig.Enabled.ShortcutGuide = isEnabled; break;
|
||||
case "PowerOCR":
|
||||
needToUpdate = generalSettingsConfig.Enabled.PowerOCR != isEnabled;
|
||||
generalSettingsConfig.Enabled.PowerOCR = isEnabled; break;
|
||||
case "VideoConference":
|
||||
needToUpdate = generalSettingsConfig.Enabled.VideoConference != isEnabled;
|
||||
generalSettingsConfig.Enabled.VideoConference = isEnabled; break;
|
||||
}
|
||||
bool needToUpdate = ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, moduleType) != isEnabled;
|
||||
|
||||
if (needToUpdate)
|
||||
{
|
||||
ModuleHelper.SetIsModuleEnabled(generalSettingsConfig, moduleType, isEnabled);
|
||||
var outgoing = new OutGoingGeneralSettings(generalSettingsConfig);
|
||||
this.DispatcherQueue.TryEnqueue(Microsoft.UI.Dispatching.DispatcherQueuePriority.Normal, () =>
|
||||
{
|
||||
|
|
|
@ -49,10 +49,5 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||
{
|
||||
ViewModel.SWVersionButtonClicked();
|
||||
}
|
||||
|
||||
private void SettingsButtonClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.SettingsButtonClicked(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Services;
|
||||
using Microsoft.PowerToys.Settings.UI.ViewModels;
|
||||
|
@ -34,7 +35,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||
/// <summary>
|
||||
/// Declaration for the updating the general settings callback function.
|
||||
/// </summary>
|
||||
public delegate bool UpdatingGeneralSettingsCallback(string module, bool isEnabled);
|
||||
public delegate bool UpdatingGeneralSettingsCallback(ModuleType moduleType, bool isEnabled);
|
||||
|
||||
/// <summary>
|
||||
/// Declaration for the opening oobe window callback function.
|
||||
|
|
|
@ -6,6 +6,7 @@ using System;
|
|||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ManagedCommon;
|
||||
using Microsoft.UI;
|
||||
using Windows.UI;
|
||||
|
||||
|
@ -22,7 +23,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
|
||||
public string ToolTip { get; set; }
|
||||
|
||||
public string Tag { get; set; }
|
||||
public ModuleType Tag { get; set; }
|
||||
|
||||
public Color AccentColor { get; set; } = Colors.Transparent;
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ 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;
|
||||
|
@ -23,7 +25,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
public class DashboardViewModel : Observable
|
||||
{
|
||||
private const string JsonFileType = ".json";
|
||||
private readonly IFileSystemWatcher _watcher;
|
||||
private IFileSystemWatcher _watcher;
|
||||
private DashboardModuleKBMItem _kbmItem;
|
||||
private Dispatcher dispatcher;
|
||||
|
||||
|
@ -53,325 +55,11 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
|
||||
_allModules = new List<DashboardListItem>();
|
||||
|
||||
GpoRuleConfigured gpo;
|
||||
gpo = GPOWrapper.GetConfiguredAlwaysOnTopEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
foreach (ModuleType moduleType in Enum.GetValues(typeof(ModuleType)))
|
||||
{
|
||||
Tag = "AlwaysOnTop",
|
||||
Label = resourceLoader.GetString("AlwaysOnTop/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.AlwaysOnTop),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsAlwaysOnTop.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 74, 196, 242), // #4ac4f2
|
||||
DashboardModuleItems = GetModuleItemsAlwaysOnTop(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredAwakeEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "Awake",
|
||||
Label = resourceLoader.GetString("Awake/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.Awake),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsAwake.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 40, 177, 233), // #28b1e9
|
||||
DashboardModuleItems = GetModuleItemsAwake(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredColorPickerEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "ColorPicker",
|
||||
Label = resourceLoader.GetString("ColorPicker/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.ColorPicker),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsColorPicker.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 7, 129, 211), // #0781d3
|
||||
DashboardModuleItems = GetModuleItemsColorPicker(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredCropAndLockEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "CropAndLock",
|
||||
Label = resourceLoader.GetString("CropAndLock/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.CropAndLock),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsCropAndLock.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 32, 166, 228), // #20a6e4
|
||||
DashboardModuleItems = GetModuleItemsCropAndLock(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredEnvironmentVariablesEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "EnvironmentVariables",
|
||||
Label = resourceLoader.GetString("EnvironmentVariables/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.EnvironmentVariables),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsEnvironmentVariables.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 16, 132, 208), // #1084d0
|
||||
DashboardModuleItems = GetModuleItemsEnvironmentVariables(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredFancyZonesEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "FancyZones",
|
||||
Label = resourceLoader.GetString("FancyZones/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.FancyZones),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsFancyZones.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 65, 209, 247), // #41d1f7
|
||||
DashboardModuleItems = GetModuleItemsFancyZones(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredFileLocksmithEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "FileLocksmith",
|
||||
Label = resourceLoader.GetString("FileLocksmith/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.FileLocksmith),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsFileLocksmith.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 245, 161, 20), // #f5a114
|
||||
DashboardModuleItems = GetModuleItemsFileLocksmith(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredFindMyMouseEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "FindMyMouse",
|
||||
Label = resourceLoader.GetString("MouseUtils_FindMyMouse/Header"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.FindMyMouse),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsFindMyMouse.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 104, 109, 112), // #686d70
|
||||
DashboardModuleItems = GetModuleItemsFindMyMouse(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredHostsFileEditorEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "Hosts",
|
||||
Label = resourceLoader.GetString("Hosts/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.Hosts),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsHosts.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 16, 132, 208), // #1084d0
|
||||
DashboardModuleItems = GetModuleItemsHosts(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredImageResizerEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "ImageResizer",
|
||||
Label = resourceLoader.GetString("ImageResizer/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.ImageResizer),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsImageResizer.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 85, 207, 248), // #55cff8
|
||||
DashboardModuleItems = GetModuleItemsImageResizer(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredKeyboardManagerEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "KeyboardManager",
|
||||
Label = resourceLoader.GetString("KeyboardManager/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.KeyboardManager),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsKeyboardManager.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 224, 231, 238), // #e0e7ee
|
||||
DashboardModuleItems = GetModuleItemsKeyboardManager(),
|
||||
});
|
||||
|
||||
if (gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.KeyboardManager))
|
||||
{
|
||||
KeyboardManagerSettings kbmSettings = GetKBMSettings();
|
||||
_watcher = Library.Utilities.Helper.GetFileWatcher(KeyboardManagerSettings.ModuleName, kbmSettings.Properties.ActiveConfiguration.Value + JsonFileType, () => LoadKBMSettingsFromJson());
|
||||
AddDashboardListItem(moduleType);
|
||||
}
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredMouseHighlighterEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "MouseHighlighter",
|
||||
Label = resourceLoader.GetString("MouseUtils_MouseHighlighter/Header"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.MouseHighlighter),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsMouseHighlighter.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 17, 126, 199), // #117ec7
|
||||
DashboardModuleItems = GetModuleItemsMouseHighlighter(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredMouseJumpEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "MouseJump",
|
||||
Label = resourceLoader.GetString("MouseUtils_MouseJump/Header"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.MouseJump),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsMouseJump.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 240, 240, 239), // #f0f0ef
|
||||
DashboardModuleItems = GetModuleItemsMouseJump(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredMousePointerCrosshairsEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "MousePointerCrosshairs",
|
||||
Label = resourceLoader.GetString("MouseUtils_MousePointerCrosshairs/Header"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.MousePointerCrosshairs),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsMouseCrosshairs.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 25, 115, 182), // #1973b6
|
||||
DashboardModuleItems = GetModuleItemsMouseCrosshairs(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredMouseWithoutBordersEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "MouseWithoutBorders",
|
||||
Label = resourceLoader.GetString("MouseWithoutBorders/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.MouseWithoutBorders),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsMouseWithoutBorders.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 31, 164, 227), // #1fa4e3
|
||||
DashboardModuleItems = GetModuleItemsMouseWithoutBorders(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredPastePlainEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "PastePlain",
|
||||
Label = resourceLoader.GetString("PastePlain/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.PastePlain),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsPastePlain.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 243, 156, 16), // #f39c10
|
||||
DashboardModuleItems = GetModuleItemsPastePlain(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredPeekEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "Peek",
|
||||
Label = resourceLoader.GetString("Peek/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.Peek),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsPeek.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 255, 214, 103), // #ffd667
|
||||
DashboardModuleItems = GetModuleItemsPeek(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredPowerRenameEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "PowerRename",
|
||||
Label = resourceLoader.GetString("PowerRename/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.PowerRename),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsPowerRename.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 43, 186, 243), // #2bbaf3
|
||||
DashboardModuleItems = GetModuleItemsPowerRename(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredPowerLauncherEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "PowerLauncher",
|
||||
Label = resourceLoader.GetString("PowerLauncher/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.PowerLauncher),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsPowerToysRun.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 51, 191, 240), // #33bff0
|
||||
DashboardModuleItems = GetModuleItemsRun(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredQuickAccentEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "PowerAccent",
|
||||
Label = resourceLoader.GetString("QuickAccent/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.PowerAccent),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsPowerAccent.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 84, 89, 92), // #54595c
|
||||
DashboardModuleItems = GetModuleItemsPowerAccent(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredRegistryPreviewEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "RegistryPreview",
|
||||
Label = resourceLoader.GetString("RegistryPreview/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.RegistryPreview),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsRegistryPreview.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 17, 80, 138), // #11508a
|
||||
DashboardModuleItems = GetModuleItemsRegistryPreview(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredScreenRulerEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "MeasureTool",
|
||||
Label = resourceLoader.GetString("MeasureTool/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.MeasureTool),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsScreenRuler.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 135, 144, 153), // #879099
|
||||
DashboardModuleItems = GetModuleItemsScreenRuler(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredShortcutGuideEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "ShortcutGuide",
|
||||
Label = resourceLoader.GetString("ShortcutGuide/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.ShortcutGuide),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsShortcutGuide.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 193, 202, 209), // #c1cad1
|
||||
DashboardModuleItems = GetModuleItemsShortcutGuide(),
|
||||
});
|
||||
|
||||
gpo = GPOWrapper.GetConfiguredTextExtractorEnabledValue();
|
||||
_allModules.Add(new DashboardListItem()
|
||||
{
|
||||
Tag = "PowerOCR",
|
||||
Label = resourceLoader.GetString("TextExtractor/ModuleTitle"),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.PowerOCR),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsPowerOCR.png",
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
AccentColor = Color.FromArgb(255, 24, 153, 224), // #1899e0
|
||||
DashboardModuleItems = GetModuleItemsPowerOCR(),
|
||||
});
|
||||
|
||||
ActiveModules = new ObservableCollection<DashboardListItem>(_allModules.Where(x => x.IsEnabled));
|
||||
DisabledModules = new ObservableCollection<DashboardListItem>(_allModules.Where(x => !x.IsEnabled));
|
||||
|
||||
|
@ -379,6 +67,59 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
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();
|
||||
|
@ -408,52 +149,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
return moduleSettingsRepository.SettingsConfig;
|
||||
}
|
||||
|
||||
internal void SettingsButtonClicked(object sender)
|
||||
{
|
||||
Button button = sender as Button;
|
||||
if (button == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string tag = button.Tag as string;
|
||||
if (tag == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Type type = null;
|
||||
switch (tag)
|
||||
{
|
||||
case "AlwaysOnTop": type = typeof(AlwaysOnTopPage); break;
|
||||
case "Awake": type = typeof(AwakePage); break;
|
||||
case "ColorPicker": type = typeof(ColorPickerPage); break;
|
||||
case "CropAndLock": type = typeof(CropAndLockPage); break;
|
||||
case "FancyZones": type = typeof(FancyZonesPage); break;
|
||||
case "FileLocksmith": type = typeof(FileLocksmithPage); break;
|
||||
case "FindMyMouse": type = typeof(MouseUtilsPage); break;
|
||||
case "Hosts": type = typeof(HostsPage); break;
|
||||
case "ImageResizer": type = typeof(ImageResizerPage); break;
|
||||
case "KeyboardManager": type = typeof(KeyboardManagerPage); break;
|
||||
case "MouseHighlighter": type = typeof(MouseUtilsPage); break;
|
||||
case "MouseJump": type = typeof(MouseUtilsPage); break;
|
||||
case "MousePointerCrosshairs": type = typeof(MouseUtilsPage); break;
|
||||
case "MouseWithoutBorders": type = typeof(MouseWithoutBordersPage); break;
|
||||
case "PastePlain": type = typeof(PastePlainPage); break;
|
||||
case "Peek": type = typeof(PeekPage); break;
|
||||
case "PowerRename": type = typeof(PowerRenamePage); break;
|
||||
case "PowerLauncher": type = typeof(PowerLauncherPage); break;
|
||||
case "PowerAccent": type = typeof(PowerAccentPage); break;
|
||||
case "RegistryPreview": type = typeof(RegistryPreviewPage); break;
|
||||
case "MeasureTool": type = typeof(MeasureToolPage); break;
|
||||
case "ShortcutGuide": type = typeof(ShortcutGuidePage); break;
|
||||
case "PowerOCR": type = typeof(PowerOcrPage); break;
|
||||
case "VideoConference": type = typeof(VideoConferencePage); break;
|
||||
}
|
||||
|
||||
NavigationService.Navigate(type);
|
||||
}
|
||||
|
||||
private void EnabledChangedOnUI(DashboardListItem dashboardListItem)
|
||||
{
|
||||
Views.ShellPage.UpdateGeneralSettingsCallback(dashboardListItem.Tag, dashboardListItem.IsEnabled);
|
||||
|
@ -466,35 +161,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
generalSettingsConfig = _settingsRepository.SettingsConfig;
|
||||
foreach (DashboardListItem item in _allModules)
|
||||
{
|
||||
switch (item.Tag)
|
||||
{
|
||||
case "AlwaysOnTop": item.IsEnabled = generalSettingsConfig.Enabled.AlwaysOnTop; break;
|
||||
case "Awake": item.IsEnabled = generalSettingsConfig.Enabled.Awake; break;
|
||||
case "ColorPicker": item.IsEnabled = generalSettingsConfig.Enabled.ColorPicker; break;
|
||||
case "CropAndLock": item.IsEnabled = generalSettingsConfig.Enabled.CropAndLock; break;
|
||||
case "EnvironmentVariables": item.IsEnabled = generalSettingsConfig.Enabled.EnvironmentVariables; break;
|
||||
case "FancyZones": item.IsEnabled = generalSettingsConfig.Enabled.FancyZones; break;
|
||||
case "FileLocksmith": item.IsEnabled = generalSettingsConfig.Enabled.FileLocksmith; break;
|
||||
case "FindMyMouse": item.IsEnabled = generalSettingsConfig.Enabled.FindMyMouse; break;
|
||||
case "Hosts": item.IsEnabled = generalSettingsConfig.Enabled.Hosts; break;
|
||||
case "ImageResizer": item.IsEnabled = generalSettingsConfig.Enabled.ImageResizer; break;
|
||||
case "KeyboardManager": item.IsEnabled = generalSettingsConfig.Enabled.KeyboardManager; break;
|
||||
case "MouseHighlighter": item.IsEnabled = generalSettingsConfig.Enabled.MouseHighlighter; break;
|
||||
case "MouseJump": item.IsEnabled = generalSettingsConfig.Enabled.MouseJump; break;
|
||||
case "MousePointerCrosshairs": item.IsEnabled = generalSettingsConfig.Enabled.MousePointerCrosshairs; break;
|
||||
case "MouseWithoutBorders": item.IsEnabled = generalSettingsConfig.Enabled.MouseWithoutBorders; break;
|
||||
case "PastePlain": item.IsEnabled = generalSettingsConfig.Enabled.PastePlain; break;
|
||||
case "Peek": item.IsEnabled = generalSettingsConfig.Enabled.Peek; break;
|
||||
case "PowerRename": item.IsEnabled = generalSettingsConfig.Enabled.PowerRename; break;
|
||||
case "PowerLauncher": item.IsEnabled = generalSettingsConfig.Enabled.PowerLauncher; break;
|
||||
case "PowerAccent": item.IsEnabled = generalSettingsConfig.Enabled.PowerAccent; break;
|
||||
case "RegistryPreview": item.IsEnabled = generalSettingsConfig.Enabled.RegistryPreview; break;
|
||||
case "MeasureTool": item.IsEnabled = generalSettingsConfig.Enabled.MeasureTool; break;
|
||||
case "ShortcutGuide": item.IsEnabled = generalSettingsConfig.Enabled.ShortcutGuide; break;
|
||||
case "PowerOCR": item.IsEnabled = generalSettingsConfig.Enabled.PowerOCR; break;
|
||||
case "VideoConference": item.IsEnabled = generalSettingsConfig.Enabled.VideoConference; break;
|
||||
}
|
||||
|
||||
item.IsEnabled = ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, item.Tag);
|
||||
if (item.IsEnabled)
|
||||
{
|
||||
ActiveModules.Add(item);
|
||||
|
@ -509,6 +176,38 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
OnPropertyChanged(nameof(DisabledModules));
|
||||
}
|
||||
|
||||
private ObservableCollection<DashboardModuleItem> 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<DashboardModuleItem>(), // never called, all values listed above
|
||||
};
|
||||
}
|
||||
|
||||
private ObservableCollection<DashboardModuleItem> GetModuleItemsAlwaysOnTop()
|
||||
{
|
||||
ISettingsRepository<AlwaysOnTopSettings> moduleSettingsRepository = SettingsRepository<AlwaysOnTopSettings>.GetInstance(new SettingsUtils());
|
||||
|
@ -668,7 +367,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
return new ObservableCollection<DashboardModuleItem>(list);
|
||||
}
|
||||
|
||||
private ObservableCollection<DashboardModuleItem> GetModuleItemsMouseCrosshairs()
|
||||
private ObservableCollection<DashboardModuleItem> GetModuleItemsMousePointerCrosshairs()
|
||||
{
|
||||
ISettingsRepository<MousePointerCrosshairsSettings> moduleSettingsRepository = SettingsRepository<MousePointerCrosshairsSettings>.GetInstance(new SettingsUtils());
|
||||
var list = new List<DashboardModuleItem>
|
||||
|
@ -716,7 +415,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
return new ObservableCollection<DashboardModuleItem>(list);
|
||||
}
|
||||
|
||||
private ObservableCollection<DashboardModuleItem> GetModuleItemsRun()
|
||||
private ObservableCollection<DashboardModuleItem> GetModuleItemsPowerLauncher()
|
||||
{
|
||||
ISettingsRepository<PowerLauncherSettings> moduleSettingsRepository = SettingsRepository<PowerLauncherSettings>.GetInstance(new SettingsUtils());
|
||||
var list = new List<DashboardModuleItem>
|
||||
|
@ -755,7 +454,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
return new ObservableCollection<DashboardModuleItem>(list);
|
||||
}
|
||||
|
||||
private ObservableCollection<DashboardModuleItem> GetModuleItemsScreenRuler()
|
||||
private ObservableCollection<DashboardModuleItem> GetModuleItemsMeasureTool()
|
||||
{
|
||||
ISettingsRepository<MeasureToolSettings> moduleSettingsRepository = SettingsRepository<MeasureToolSettings>.GetInstance(new SettingsUtils());
|
||||
var list = new List<DashboardModuleItem>
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Threading.Tasks;
|
||||
using global::PowerToys.GPOWrapper;
|
||||
using Microsoft.PowerToys.Settings.UI.Flyout;
|
||||
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;
|
||||
|
@ -30,86 +30,32 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
generalSettingsConfig = settingsRepository.SettingsConfig;
|
||||
generalSettingsConfig.AddEnabledModuleChangeNotification(ModuleEnabledChangedOnSettingsPage);
|
||||
|
||||
resourceLoader = Helpers.ResourceLoaderInstance.ResourceLoader;
|
||||
FlyoutMenuItems = new ObservableCollection<FlyoutMenuItem>();
|
||||
|
||||
resourceLoader = Helpers.ResourceLoaderInstance.ResourceLoader;
|
||||
|
||||
AddFlyoutMenuItem("AlwaysOnTop", generalSettingsConfig.Enabled.AlwaysOnTop, "AlwaysOnTop/ModuleTitle", "AlwaysOnTop");
|
||||
AddFlyoutMenuItem("Awake", generalSettingsConfig.Enabled.Awake, "Awake/ModuleTitle", "Awake");
|
||||
AddFlyoutMenuItem("ColorPicker", generalSettingsConfig.Enabled.ColorPicker, "ColorPicker/ModuleTitle", "ColorPicker");
|
||||
AddFlyoutMenuItem("CropAndLock", generalSettingsConfig.Enabled.CropAndLock, "CropAndLock/ModuleTitle", "CropAndLock");
|
||||
AddFlyoutMenuItem("EnvironmentVariables", generalSettingsConfig.Enabled.EnvironmentVariables, "EnvironmentVariables/ModuleTitle", "EnvironmentVariables");
|
||||
AddFlyoutMenuItem("FancyZones", generalSettingsConfig.Enabled.FancyZones, "FancyZones/ModuleTitle", "FancyZones");
|
||||
AddFlyoutMenuItem("FileLocksmith", generalSettingsConfig.Enabled.FileLocksmith, "FileLocksmith/ModuleTitle", "FileLocksmith");
|
||||
AddFlyoutMenuItem("FindMyMouse", generalSettingsConfig.Enabled.FindMyMouse, "MouseUtils_FindMyMouse/Header", "FindMyMouse");
|
||||
AddFlyoutMenuItem("Hosts", generalSettingsConfig.Enabled.Hosts, "Hosts/ModuleTitle", "Hosts");
|
||||
AddFlyoutMenuItem("ImageResizer", generalSettingsConfig.Enabled.ImageResizer, "ImageResizer/ModuleTitle", "ImageResizer");
|
||||
AddFlyoutMenuItem("KeyboardManager", generalSettingsConfig.Enabled.KeyboardManager, "KeyboardManager/ModuleTitle", "KeyboardManager");
|
||||
AddFlyoutMenuItem("MouseHighlighter", generalSettingsConfig.Enabled.MouseHighlighter, "MouseUtils_MouseHighlighter/Header", "MouseHighlighter");
|
||||
AddFlyoutMenuItem("MouseJump", generalSettingsConfig.Enabled.MouseJump, "MouseUtils_MouseJump/Header", "MouseJump");
|
||||
AddFlyoutMenuItem("MousePointerCrosshairs", generalSettingsConfig.Enabled.MousePointerCrosshairs, "MouseUtils_MousePointerCrosshairs/Header", "MouseCrosshairs");
|
||||
AddFlyoutMenuItem("MouseWithoutBorders", generalSettingsConfig.Enabled.MouseWithoutBorders, "MouseWithoutBorders/ModuleTitle", "MouseWithoutBorders");
|
||||
AddFlyoutMenuItem("PastePlain", generalSettingsConfig.Enabled.PastePlain, "PastePlain/ModuleTitle", "PastePlain");
|
||||
AddFlyoutMenuItem("Peek", generalSettingsConfig.Enabled.Peek, "Peek/ModuleTitle", "Peek");
|
||||
AddFlyoutMenuItem("PowerRename", generalSettingsConfig.Enabled.PowerRename, "PowerRename/ModuleTitle", "PowerRename");
|
||||
AddFlyoutMenuItem("PowerLauncher", generalSettingsConfig.Enabled.PowerLauncher, "PowerLauncher/ModuleTitle", "PowerToysRun");
|
||||
AddFlyoutMenuItem("PowerAccent", generalSettingsConfig.Enabled.PowerAccent, "QuickAccent/ModuleTitle", "PowerAccent");
|
||||
AddFlyoutMenuItem("RegistryPreview", generalSettingsConfig.Enabled.RegistryPreview, "RegistryPreview/ModuleTitle", "RegistryPreview");
|
||||
AddFlyoutMenuItem("MeasureTool", generalSettingsConfig.Enabled.MeasureTool, "MeasureTool/ModuleTitle", "ScreenRuler");
|
||||
AddFlyoutMenuItem("ShortcutGuide", generalSettingsConfig.Enabled.ShortcutGuide, "ShortcutGuide/ModuleTitle", "ShortcutGuide");
|
||||
AddFlyoutMenuItem("PowerOCR", generalSettingsConfig.Enabled.PowerOCR, "TextExtractor/ModuleTitle", "PowerOCR");
|
||||
foreach (ModuleType moduleType in Enum.GetValues(typeof(ModuleType)))
|
||||
{
|
||||
AddFlyoutMenuItem(moduleType);
|
||||
}
|
||||
|
||||
// set the callback functions value to handle outgoing IPC message.
|
||||
SendConfigMSG = ipcMSGCallBackFunc;
|
||||
}
|
||||
|
||||
private void AddFlyoutMenuItem(string moduleName, bool isModuleEnabled, string moduleLabelResourceName, string moduleFluentIconName)
|
||||
private void AddFlyoutMenuItem(ModuleType moduleType)
|
||||
{
|
||||
GpoRuleConfigured gpo = GetModuleGpoConfiguration(moduleName);
|
||||
|
||||
GpoRuleConfigured gpo = ModuleHelper.GetModuleGpoConfiguration(moduleType);
|
||||
FlyoutMenuItems.Add(new FlyoutMenuItem()
|
||||
{
|
||||
Label = resourceLoader.GetString(moduleLabelResourceName),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && isModuleEnabled),
|
||||
Label = resourceLoader.GetString(ModuleHelper.GetModuleLabelResourceName(moduleType)),
|
||||
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, moduleType)),
|
||||
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
|
||||
Tag = moduleName,
|
||||
Icon = $"ms-appx:///Assets/Settings/FluentIcons/FluentIcons{moduleFluentIconName}.png",
|
||||
Tag = moduleType,
|
||||
Icon = ModuleHelper.GetModuleTypeFluentIconName(moduleType),
|
||||
EnabledChangedCallback = EnabledChangedOnUI,
|
||||
});
|
||||
}
|
||||
|
||||
private GpoRuleConfigured GetModuleGpoConfiguration(string moduleName)
|
||||
{
|
||||
switch (moduleName)
|
||||
{
|
||||
case "AlwaysOnTop": return GPOWrapper.GetConfiguredAlwaysOnTopEnabledValue();
|
||||
case "Awake": return GPOWrapper.GetConfiguredAwakeEnabledValue();
|
||||
case "ColorPicker": return GPOWrapper.GetConfiguredColorPickerEnabledValue();
|
||||
case "CropAndLock": return GPOWrapper.GetConfiguredCropAndLockEnabledValue();
|
||||
case "EnvironmentVariables": return GPOWrapper.GetConfiguredEnvironmentVariablesEnabledValue();
|
||||
case "FancyZones": return GPOWrapper.GetConfiguredFancyZonesEnabledValue();
|
||||
case "FileLocksmith": return GPOWrapper.GetConfiguredFileLocksmithEnabledValue();
|
||||
case "FindMyMouse": return GPOWrapper.GetConfiguredFindMyMouseEnabledValue();
|
||||
case "Hosts": return GPOWrapper.GetConfiguredHostsFileEditorEnabledValue();
|
||||
case "ImageResizer": return GPOWrapper.GetConfiguredImageResizerEnabledValue();
|
||||
case "KeyboardManager": return GPOWrapper.GetConfiguredKeyboardManagerEnabledValue();
|
||||
case "MouseHighlighter": return GPOWrapper.GetConfiguredMouseHighlighterEnabledValue();
|
||||
case "MouseJump": return GPOWrapper.GetConfiguredMouseJumpEnabledValue();
|
||||
case "MousePointerCrosshairs": return GPOWrapper.GetConfiguredMousePointerCrosshairsEnabledValue();
|
||||
case "MouseWithoutBorders": return GPOWrapper.GetConfiguredMouseWithoutBordersEnabledValue();
|
||||
case "PastePlain": return GPOWrapper.GetConfiguredPastePlainEnabledValue();
|
||||
case "Peek": return GPOWrapper.GetConfiguredPeekEnabledValue();
|
||||
case "PowerRename": return GPOWrapper.GetConfiguredPowerRenameEnabledValue();
|
||||
case "PowerLauncher": return GPOWrapper.GetConfiguredPowerLauncherEnabledValue();
|
||||
case "PowerAccent": return GPOWrapper.GetConfiguredQuickAccentEnabledValue();
|
||||
case "RegistryPreview": return GPOWrapper.GetConfiguredRegistryPreviewEnabledValue();
|
||||
case "MeasureTool": return GPOWrapper.GetConfiguredScreenRulerEnabledValue();
|
||||
case "ShortcutGuide": return GPOWrapper.GetConfiguredShortcutGuideEnabledValue();
|
||||
case "PowerOCR": return GPOWrapper.GetConfiguredTextExtractorEnabledValue();
|
||||
default: return GpoRuleConfigured.Unavailable;
|
||||
}
|
||||
}
|
||||
|
||||
private void EnabledChangedOnUI(FlyoutMenuItem flyoutMenuItem)
|
||||
{
|
||||
if (Views.ShellPage.UpdateGeneralSettingsCallback(flyoutMenuItem.Tag, flyoutMenuItem.IsEnabled))
|
||||
|
@ -124,34 +70,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
generalSettingsConfig.AddEnabledModuleChangeNotification(ModuleEnabledChangedOnSettingsPage);
|
||||
foreach (FlyoutMenuItem item in FlyoutMenuItems)
|
||||
{
|
||||
switch (item.Tag)
|
||||
{
|
||||
case "AlwaysOnTop": item.IsEnabled = generalSettingsConfig.Enabled.AlwaysOnTop; break;
|
||||
case "Awake": item.IsEnabled = generalSettingsConfig.Enabled.Awake; break;
|
||||
case "ColorPicker": item.IsEnabled = generalSettingsConfig.Enabled.ColorPicker; break;
|
||||
case "CropAndLock": item.IsEnabled = generalSettingsConfig.Enabled.CropAndLock; break;
|
||||
case "EnvironmentVariables": item.IsEnabled = generalSettingsConfig.Enabled.EnvironmentVariables; break;
|
||||
case "FancyZones": item.IsEnabled = generalSettingsConfig.Enabled.FancyZones; break;
|
||||
case "FileLocksmith": item.IsEnabled = generalSettingsConfig.Enabled.FileLocksmith; break;
|
||||
case "FindMyMouse": item.IsEnabled = generalSettingsConfig.Enabled.FindMyMouse; break;
|
||||
case "Hosts": item.IsEnabled = generalSettingsConfig.Enabled.Hosts; break;
|
||||
case "ImageResizer": item.IsEnabled = generalSettingsConfig.Enabled.ImageResizer; break;
|
||||
case "KeyboardManager": item.IsEnabled = generalSettingsConfig.Enabled.KeyboardManager; break;
|
||||
case "MouseHighlighter": item.IsEnabled = generalSettingsConfig.Enabled.MouseHighlighter; break;
|
||||
case "MouseJump": item.IsEnabled = generalSettingsConfig.Enabled.MouseJump; break;
|
||||
case "MousePointerCrosshairs": item.IsEnabled = generalSettingsConfig.Enabled.MousePointerCrosshairs; break;
|
||||
case "MouseWithoutBorders": item.IsEnabled = generalSettingsConfig.Enabled.MouseWithoutBorders; break;
|
||||
case "PastePlain": item.IsEnabled = generalSettingsConfig.Enabled.PastePlain; break;
|
||||
case "Peek": item.IsEnabled = generalSettingsConfig.Enabled.Peek; break;
|
||||
case "PowerRename": item.IsEnabled = generalSettingsConfig.Enabled.PowerRename; break;
|
||||
case "PowerLauncher": item.IsEnabled = generalSettingsConfig.Enabled.PowerLauncher; break;
|
||||
case "PowerAccent": item.IsEnabled = generalSettingsConfig.Enabled.PowerAccent; break;
|
||||
case "RegistryPreview": item.IsEnabled = generalSettingsConfig.Enabled.RegistryPreview; break;
|
||||
case "MeasureTool": item.IsEnabled = generalSettingsConfig.Enabled.MeasureTool; break;
|
||||
case "ShortcutGuide": item.IsEnabled = generalSettingsConfig.Enabled.ShortcutGuide; break;
|
||||
case "PowerOCR": item.IsEnabled = generalSettingsConfig.Enabled.PowerOCR; break;
|
||||
case "VideoConference": item.IsEnabled = generalSettingsConfig.Enabled.VideoConference; break;
|
||||
}
|
||||
item.IsEnabled = ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, item.Tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.UI.Xaml;
|
||||
using ManagedCommon;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
|
||||
public string ToolTip { get; set; }
|
||||
|
||||
public string Tag { get; set; }
|
||||
public ModuleType Tag { get; set; }
|
||||
|
||||
public bool IsLocked { get; set; }
|
||||
|
||||
|
|
|
@ -5,10 +5,12 @@
|
|||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
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.Views;
|
||||
using Microsoft.Windows.ApplicationModel.Resources;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
|
@ -21,6 +23,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
private GeneralSettings generalSettingsConfig;
|
||||
private UpdatingSettings updatingSettingsConfig;
|
||||
private ISettingsRepository<GeneralSettings> _settingsRepository;
|
||||
private ResourceLoader resourceLoader;
|
||||
|
||||
private Func<string, int> SendIPCMessage { get; }
|
||||
|
||||
|
@ -32,112 +35,18 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
|
||||
// set the callback functions value to handle outgoing IPC message.
|
||||
SendIPCMessage = ipcMSGCallBackFunc;
|
||||
var resourceLoader = Helpers.ResourceLoaderInstance.ResourceLoader;
|
||||
resourceLoader = ResourceLoaderInstance.ResourceLoader;
|
||||
FlyoutMenuItems = new ObservableCollection<FlyoutMenuItem>();
|
||||
if (GPOWrapper.GetConfiguredColorPickerEnabledValue() != GpoRuleConfigured.Disabled)
|
||||
{
|
||||
FlyoutMenuItems.Add(new FlyoutMenuItem()
|
||||
{
|
||||
Label = resourceLoader.GetString("ColorPicker/ModuleTitle"),
|
||||
Tag = "ColorPicker",
|
||||
Visible = generalSettingsConfig.Enabled.ColorPicker,
|
||||
ToolTip = SettingsRepository<ColorPickerSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ActivationShortcut.ToString(),
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsColorPicker.png",
|
||||
});
|
||||
}
|
||||
|
||||
if (GPOWrapper.GetConfiguredEnvironmentVariablesEnabledValue() != GpoRuleConfigured.Disabled)
|
||||
{
|
||||
FlyoutMenuItems.Add(new FlyoutMenuItem()
|
||||
{
|
||||
Label = resourceLoader.GetString("EnvironmentVariables/ModuleTitle"),
|
||||
Tag = "EnvironmentVariables",
|
||||
Visible = generalSettingsConfig.Enabled.EnvironmentVariables,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsEnvironmentVariables.png",
|
||||
});
|
||||
}
|
||||
|
||||
if (GPOWrapper.GetConfiguredFancyZonesEnabledValue() != GpoRuleConfigured.Disabled)
|
||||
{
|
||||
FlyoutMenuItems.Add(new FlyoutMenuItem()
|
||||
{
|
||||
Label = resourceLoader.GetString("FZEditorString"),
|
||||
Tag = "FancyZones",
|
||||
Visible = generalSettingsConfig.Enabled.FancyZones,
|
||||
ToolTip = SettingsRepository<FancyZonesSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.FancyzonesEditorHotkey.Value.ToString(),
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsFancyZones.png",
|
||||
});
|
||||
}
|
||||
|
||||
if (GPOWrapper.GetConfiguredHostsFileEditorEnabledValue() != GpoRuleConfigured.Disabled)
|
||||
{
|
||||
FlyoutMenuItems.Add(new FlyoutMenuItem()
|
||||
{
|
||||
Label = resourceLoader.GetString("Hosts/ModuleTitle"),
|
||||
Tag = "Hosts",
|
||||
Visible = generalSettingsConfig.Enabled.Hosts,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsHosts.png",
|
||||
});
|
||||
}
|
||||
|
||||
if (GPOWrapper.GetConfiguredPowerLauncherEnabledValue() != GpoRuleConfigured.Disabled)
|
||||
{
|
||||
FlyoutMenuItems.Add(new FlyoutMenuItem()
|
||||
{
|
||||
Label = resourceLoader.GetString("PowerLauncher/ModuleTitle"),
|
||||
Tag = "PowerLauncher",
|
||||
Visible = generalSettingsConfig.Enabled.PowerLauncher,
|
||||
ToolTip = SettingsRepository<PowerLauncherSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.OpenPowerLauncher.ToString(),
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsPowerToysRun.png",
|
||||
});
|
||||
}
|
||||
|
||||
if (GPOWrapper.GetConfiguredTextExtractorEnabledValue() != GpoRuleConfigured.Disabled)
|
||||
{
|
||||
FlyoutMenuItems.Add(new FlyoutMenuItem()
|
||||
{
|
||||
Label = resourceLoader.GetString("TextExtractor/ModuleTitle"),
|
||||
Tag = "PowerOCR",
|
||||
Visible = generalSettingsConfig.Enabled.PowerOCR,
|
||||
ToolTip = SettingsRepository<PowerOcrSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ActivationShortcut.ToString(),
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsPowerOcr.png",
|
||||
});
|
||||
}
|
||||
|
||||
if (GPOWrapper.GetConfiguredRegistryPreviewEnabledValue() != GpoRuleConfigured.Disabled)
|
||||
{
|
||||
FlyoutMenuItems.Add(new FlyoutMenuItem()
|
||||
{
|
||||
Label = resourceLoader.GetString("RegistryPreview/ModuleTitle"),
|
||||
Tag = "RegistryPreview",
|
||||
Visible = generalSettingsConfig.Enabled.RegistryPreview,
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsRegistryPreview.png",
|
||||
});
|
||||
}
|
||||
|
||||
if (GPOWrapper.GetConfiguredScreenRulerEnabledValue() != GpoRuleConfigured.Disabled)
|
||||
{
|
||||
FlyoutMenuItems.Add(new FlyoutMenuItem()
|
||||
{
|
||||
Label = resourceLoader.GetString("MeasureTool/ModuleTitle"),
|
||||
Tag = "MeasureTool",
|
||||
Visible = generalSettingsConfig.Enabled.MeasureTool,
|
||||
ToolTip = SettingsRepository<MeasureToolSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ActivationShortcut.ToString(),
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsScreenRuler.png",
|
||||
});
|
||||
}
|
||||
|
||||
if (GPOWrapper.GetConfiguredShortcutGuideEnabledValue() != GpoRuleConfigured.Disabled)
|
||||
{
|
||||
FlyoutMenuItems.Add(new FlyoutMenuItem()
|
||||
{
|
||||
Label = resourceLoader.GetString("ShortcutGuide/ModuleTitle"),
|
||||
Tag = "ShortcutGuide",
|
||||
Visible = generalSettingsConfig.Enabled.ShortcutGuide,
|
||||
ToolTip = SettingsRepository<ShortcutGuideSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.OpenShortcutGuide.ToString(),
|
||||
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsShortcutGuide.png",
|
||||
});
|
||||
}
|
||||
AddFlyoutMenuItem(ModuleType.ColorPicker);
|
||||
AddFlyoutMenuItem(ModuleType.EnvironmentVariables);
|
||||
AddFlyoutMenuItem(ModuleType.FancyZones);
|
||||
AddFlyoutMenuItem(ModuleType.Hosts);
|
||||
AddFlyoutMenuItem(ModuleType.PowerLauncher);
|
||||
AddFlyoutMenuItem(ModuleType.PowerOCR);
|
||||
AddFlyoutMenuItem(ModuleType.RegistryPreview);
|
||||
AddFlyoutMenuItem(ModuleType.MeasureTool);
|
||||
AddFlyoutMenuItem(ModuleType.ShortcutGuide);
|
||||
|
||||
if (updatingSettingsConfig == null)
|
||||
{
|
||||
|
@ -156,23 +65,44 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
private void AddFlyoutMenuItem(ModuleType moduleType)
|
||||
{
|
||||
if (ModuleHelper.GetModuleGpoConfiguration(moduleType) == GpoRuleConfigured.Disabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FlyoutMenuItems.Add(new FlyoutMenuItem()
|
||||
{
|
||||
Label = resourceLoader.GetString(ModuleHelper.GetModuleLabelResourceName(moduleType)),
|
||||
Tag = moduleType,
|
||||
Visible = ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, moduleType),
|
||||
ToolTip = GetModuleTooltip(moduleType),
|
||||
Icon = ModuleHelper.GetModuleTypeFluentIconName(moduleType),
|
||||
});
|
||||
}
|
||||
|
||||
private string GetModuleTooltip(ModuleType moduleType)
|
||||
{
|
||||
return moduleType switch
|
||||
{
|
||||
ModuleType.ColorPicker => SettingsRepository<ColorPickerSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ActivationShortcut.ToString(),
|
||||
ModuleType.FancyZones => SettingsRepository<FancyZonesSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.FancyzonesEditorHotkey.Value.ToString(),
|
||||
ModuleType.PowerLauncher => SettingsRepository<PowerLauncherSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.OpenPowerLauncher.ToString(),
|
||||
ModuleType.PowerOCR => SettingsRepository<PowerOcrSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ActivationShortcut.ToString(),
|
||||
ModuleType.MeasureTool => SettingsRepository<MeasureToolSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ActivationShortcut.ToString(),
|
||||
ModuleType.ShortcutGuide => SettingsRepository<ShortcutGuideSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.OpenShortcutGuide.ToString(),
|
||||
_ => string.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
private void ModuleEnabledChanged()
|
||||
{
|
||||
generalSettingsConfig = _settingsRepository.SettingsConfig;
|
||||
generalSettingsConfig.AddEnabledModuleChangeNotification(ModuleEnabledChanged);
|
||||
foreach (FlyoutMenuItem item in FlyoutMenuItems)
|
||||
{
|
||||
switch (item.Tag)
|
||||
{
|
||||
case "ColorPicker": item.Visible = generalSettingsConfig.Enabled.ColorPicker; break;
|
||||
case "FancyZones": item.Visible = generalSettingsConfig.Enabled.FancyZones; break;
|
||||
case "Hosts": item.Visible = generalSettingsConfig.Enabled.Hosts; break;
|
||||
case "PowerLauncher": item.Visible = generalSettingsConfig.Enabled.PowerLauncher; break;
|
||||
case "PowerOCR": item.Visible = generalSettingsConfig.Enabled.PowerOCR; break;
|
||||
case "RegistryPreview": item.Visible = generalSettingsConfig.Enabled.RegistryPreview; break;
|
||||
case "MeasureTool": item.Visible = generalSettingsConfig.Enabled.MeasureTool; break;
|
||||
case "ShortcutGuide": item.Visible = generalSettingsConfig.Enabled.ShortcutGuide; break;
|
||||
}
|
||||
item.Visible = ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, item.Tag);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче