From 8cf6ed6de50c1f554e3749e8042a6555da90a103 Mon Sep 17 00:00:00 2001 From: kaitao-ms Date: Mon, 1 Dec 2025 16:29:43 +0800 Subject: [PATCH] OK, screen ruler --- .../LightSwitchModuleInterface/dllmain.cpp | 111 ++++++++++++++---- .../Assets/LightSwitch.png | Bin 0 -> 1535 bytes .../LightSwitch/ToggleLightSwitchCommand.cs | 35 ++++++ .../ScreenRuler/ToggleScreenRulerCommand.cs | 32 +++++ .../Helpers/ModuleCommandCatalog.cs | 4 +- .../Helpers/PowerToysEventNames.cs | 1 + .../Helpers/PowerToysResourcesHelper.cs | 2 + .../DefaultSettingsModuleCommandProvider.cs | 46 -------- .../LightSwitchModuleCommandProvider.cs | 38 ++++++ .../PowerToysRunModuleCommandProvider.cs | 27 +++++ .../ScreenRulerModuleCommandProvider.cs | 34 ++++++ 11 files changed, 258 insertions(+), 72 deletions(-) create mode 100644 src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Assets/LightSwitch.png create mode 100644 src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/LightSwitch/ToggleLightSwitchCommand.cs create mode 100644 src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/ScreenRuler/ToggleScreenRulerCommand.cs delete mode 100644 src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/DefaultSettingsModuleCommandProvider.cs create mode 100644 src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/LightSwitchModuleCommandProvider.cs create mode 100644 src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/PowerToysRunModuleCommandProvider.cs create mode 100644 src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/ScreenRulerModuleCommandProvider.cs diff --git a/src/modules/LightSwitch/LightSwitchModuleInterface/dllmain.cpp b/src/modules/LightSwitch/LightSwitchModuleInterface/dllmain.cpp index 170dde5b0a..6cfb5ad540 100644 --- a/src/modules/LightSwitch/LightSwitchModuleInterface/dllmain.cpp +++ b/src/modules/LightSwitch/LightSwitchModuleInterface/dllmain.cpp @@ -8,6 +8,8 @@ #include #include #include "ThemeHelper.h" +#include +#include extern "C" IMAGE_DOS_HEADER __ImageBase; @@ -98,12 +100,18 @@ private: HANDLE m_force_light_event_handle; HANDLE m_force_dark_event_handle; HANDLE m_manual_override_event_handle; + HANDLE m_toggle_event_handle{ nullptr }; + std::thread m_toggle_thread; + std::atomic m_toggle_thread_running{ false }; static const constexpr int NUM_DEFAULT_HOTKEYS = 4; Hotkey m_toggle_theme_hotkey = { .win = true, .ctrl = true, .shift = true, .alt = false, .key = 'D' }; void init_settings(); + void ToggleTheme(); + void StartToggleListener(); + void StopToggleListener(); public: LightSwitchInterface() @@ -113,6 +121,7 @@ public: m_force_light_event_handle = CreateDefaultEvent(L"POWERTOYS_LIGHTSWITCH_FORCE_LIGHT"); m_force_dark_event_handle = CreateDefaultEvent(L"POWERTOYS_LIGHTSWITCH_FORCE_DARK"); m_manual_override_event_handle = CreateEventW(nullptr, TRUE, FALSE, L"POWERTOYS_LIGHTSWITCH_MANUAL_OVERRIDE"); + m_toggle_event_handle = CreateDefaultEvent(L"Local\\PowerToys-LightSwitch-ToggleEvent-d8dc2f29-8c94-4ca1-8c5f-3e2b1e3c4f5a"); init_settings(); }; @@ -437,6 +446,8 @@ public: Logger::info(L"Light Switch process launched successfully (PID: {}).", pi.dwProcessId); m_process = pi.hProcess; CloseHandle(pi.hThread); + + StartToggleListener(); } // Disable the powertoy @@ -462,6 +473,8 @@ public: CloseHandle(m_process); m_process = nullptr; } + + StopToggleListener(); } // Returns if the powertoys is enabled @@ -523,31 +536,8 @@ public: } else if (hotkeyId == 0) { - // get current will return true if in light mode; otherwise false Logger::info(L"[Light Switch] Hotkey triggered: Toggle Theme"); - if (g_settings.m_changeSystem) - { - SetSystemTheme(!GetCurrentSystemTheme()); - } - if (g_settings.m_changeApps) - { - SetAppsTheme(!GetCurrentAppsTheme()); - } - - if (!m_manual_override_event_handle) - { - m_manual_override_event_handle = OpenEventW(SYNCHRONIZE | EVENT_MODIFY_STATE, FALSE, L"POWERTOYS_LIGHTSWITCH_MANUAL_OVERRIDE"); - if (!m_manual_override_event_handle) - { - m_manual_override_event_handle = CreateEventW(nullptr, TRUE, FALSE, L"POWERTOYS_LIGHTSWITCH_MANUAL_OVERRIDE"); - } - } - - if (m_manual_override_event_handle) - { - SetEvent(m_manual_override_event_handle); - Logger::debug(L"[Light Switch] Manual override event set"); - } + ToggleTheme(); } return true; @@ -560,6 +550,77 @@ public: { return WaitForSingleObject(m_process, 0) == WAIT_TIMEOUT; } + + void ToggleTheme() + { + if (g_settings.m_changeSystem) + { + SetSystemTheme(!GetCurrentSystemTheme()); + } + if (g_settings.m_changeApps) + { + SetAppsTheme(!GetCurrentAppsTheme()); + } + + if (!m_manual_override_event_handle) + { + m_manual_override_event_handle = OpenEventW(SYNCHRONIZE | EVENT_MODIFY_STATE, FALSE, L"POWERTOYS_LIGHTSWITCH_MANUAL_OVERRIDE"); + if (!m_manual_override_event_handle) + { + m_manual_override_event_handle = CreateEventW(nullptr, TRUE, FALSE, L"POWERTOYS_LIGHTSWITCH_MANUAL_OVERRIDE"); + } + } + + if (m_manual_override_event_handle) + { + SetEvent(m_manual_override_event_handle); + Logger::debug(L"[Light Switch] Manual override event set"); + } + } + + void StartToggleListener() + { + if (m_toggle_thread_running || !m_toggle_event_handle) + { + return; + } + + m_toggle_thread_running = true; + m_toggle_thread = std::thread([this]() { + while (m_toggle_thread_running) + { + const DWORD wait_result = WaitForSingleObject(m_toggle_event_handle, 500); + if (!m_toggle_thread_running) + { + break; + } + + if (wait_result == WAIT_OBJECT_0) + { + ToggleTheme(); + ResetEvent(m_toggle_event_handle); + } + } + }); + } + + void StopToggleListener() + { + if (!m_toggle_thread_running) + { + return; + } + + m_toggle_thread_running = false; + if (m_toggle_event_handle) + { + SetEvent(m_toggle_event_handle); + } + if (m_toggle_thread.joinable()) + { + m_toggle_thread.join(); + } + } }; std::wstring utf8_to_wstring(const std::string& str) @@ -639,4 +700,4 @@ void LightSwitchInterface::init_settings() extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create() { return new LightSwitchInterface(); -} \ No newline at end of file +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Assets/LightSwitch.png b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Assets/LightSwitch.png new file mode 100644 index 0000000000000000000000000000000000000000..d4ce00c74a523f134b546d39db3e313bbb450146 GIT binary patch literal 1535 zcmV*@4+!j zv$!;eZ}-!WKf3g<0Hr_pFpUZaQCK1>oM}LTGPXmfjLWAUt^pP?1VQD%V;3)flF9rn zAkGSl)m}lnyKz5Zf(5BuFapBT9YJs^m|)7|KZ#va1Ga68xwW-5v0nmWQZr=}MGyMj z%b8pSp!B(O4)ct09CCyL-zvUYv+)mrc;_IV>FR>ckV!^nvv0EED3W_$tin@PV=%=mLp9zG1OzxFEZ+O->q zLEwJ=J}lo^f}CZJ|BVhj!uZj<5CW;ZP?!c zhYmHt&1@FDa+%9?np=8Pq-ybQUlqfzZk|qSx-;4KKg+qV^$)R~i(6 z_KiTWd{1LT1H91Nt0NN!FZA{GC5-fY=TkWER74TNRA&{9tY}Dko(HE+odi2>YZg@y zNM>a^P~gJ;`TWV}z&UV0jU_xI)@Lx&ctygGhO`b*ru>Cgu*28X)z(6Ld%INZ`Rl0& zZGEijH&x?W2ZNU8r{p+(<8fimW7N@pv(0+tD`6+rR{BSnOz!0xgE3#RQXTt+IKX-P^5vc{ITStJX;6Kl;RK|4F;qfIVX>_zP=vH=-B=V zITmA)fKlZ@=MV6eXzG27RZgNIc7WR`QX7ddI(uUpYHVA}=Z{@uLvu?j)L`CH{>E1$ zAezUoL{O)ca2Cxo8cZk$;j@YvSRM(};m#Wo(IgF-otcKeYJ2zX6G5SU6IkBD|5@DF z<7=w`qq}5AlmrEw=cqeNOF=0Ro%&$VKU&+MvGH*&FJK4+Gs$EUCMTyvDv(CATgVWb zz%|`G%$Yu=ZS3gZveX21i@_fc9>U_{g2=)|q#4N&S5o&#o#-kDMdTslrBVr|rlzz3 zXl~X(vcDDA2NtQ)zDtM7gPQllS%tk}8t~QE-(bjl+WFO6M4Lw=QO4gqI~NL@Fg`vG zzpt!FK)fngFl5gDFqu1k;@KV?aC{3$6od~zg5ZNB#G-JV)zwv4y?0NPg9wBAsHGv? zUrNOyY;0`63IZAVY*gkSWEJ0;v8(PSSzOInKP?w;;#Y#f_Kd89EdWb(SrDhs{b4S9 z3#?cSx-n~8Rt!wj3zApoM7^-n};J4n+X*_STtqE})u0MZ31T6iNc3`2wfg4JLu0P&VO^L7tv8%7O|Di6Yk)ICYR6+_}uP4o=` zzp3vp9v+d0POX#}1`(_iF~V}xVEtpRI}z5u<0U^ea5lx+LdA|MuEFgwoS%Z|tEhE; zR7Gl{$CgoRX2YOE6Rw-zu6IX3s=YZdaLk~@!SHRD{y^nEsZ3tvsW?b6Cf3M>+ve#q l774`Q=AhcDt=j&>_9wrj^}lW?twaC-002ovPDHLkV1njM&T#+$ literal 0 HcmV?d00001 diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/LightSwitch/ToggleLightSwitchCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/LightSwitch/ToggleLightSwitchCommand.cs new file mode 100644 index 0000000000..2ab8562ba3 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/LightSwitch/ToggleLightSwitchCommand.cs @@ -0,0 +1,35 @@ +// 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.Threading; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Helpers; + +namespace PowerToysExtension.Commands; + +/// +/// Toggles Light Switch via the shared event. +/// +internal sealed partial class ToggleLightSwitchCommand : InvokableCommand +{ + public ToggleLightSwitchCommand() + { + Name = "Toggle Light Switch"; + } + + public override CommandResult Invoke() + { + try + { + using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, PowerToysEventNames.LightSwitchToggle); + evt.Set(); + return CommandResult.Dismiss(); + } + catch (Exception ex) + { + return CommandResult.ShowToast($"Failed to toggle Light Switch: {ex.Message}"); + } + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/ScreenRuler/ToggleScreenRulerCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/ScreenRuler/ToggleScreenRulerCommand.cs new file mode 100644 index 0000000000..c879632759 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/ScreenRuler/ToggleScreenRulerCommand.cs @@ -0,0 +1,32 @@ +// 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.Threading; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Helpers; + +namespace PowerToysExtension.Commands; + +internal sealed partial class ToggleScreenRulerCommand : InvokableCommand +{ + public ToggleScreenRulerCommand() + { + Name = "Toggle Screen Ruler"; + } + + public override CommandResult Invoke() + { + try + { + using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, PowerToysEventNames.MeasureToolTrigger); + evt.Set(); + return CommandResult.Dismiss(); + } + catch (Exception ex) + { + return CommandResult.ShowToast($"Failed to toggle Screen Ruler: {ex.Message}"); + } + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/ModuleCommandCatalog.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/ModuleCommandCatalog.cs index 1270f49d2d..3bb3eba796 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/ModuleCommandCatalog.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/ModuleCommandCatalog.cs @@ -22,8 +22,10 @@ internal static class ModuleCommandCatalog new AwakeModuleCommandProvider(), new AdvancedPasteModuleCommandProvider(), new WorkspacesModuleCommandProvider(), + new LightSwitchModuleCommandProvider(), + new PowerToysRunModuleCommandProvider(), + new ScreenRulerModuleCommandProvider(), new ColorPickerModuleCommandProvider(), - new DefaultSettingsModuleCommandProvider(), ]; public static IListItem[] FilteredItems(string query) diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/PowerToysEventNames.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/PowerToysEventNames.cs index 80700aa876..2e4fa69981 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/PowerToysEventNames.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/PowerToysEventNames.cs @@ -25,6 +25,7 @@ internal static class PowerToysEventNames internal const string PowerToysRunInvoke = "Local\\PowerToysRunInvokeEvent-30f26ad7-d36d-4c0e-ab02-68bb5ff3c4ab"; internal const string RegistryPreviewTrigger = "Local\\RegistryPreviewEvent-4C559468-F75A-4E7F-BC4F-9C9688316687"; internal const string ShortcutGuideTrigger = "Local\\ShortcutGuide-TriggerEvent-d4275ad3-2531-4d19-9252-c0becbd9b496"; + internal const string LightSwitchToggle = "Local\\PowerToys-LightSwitch-ToggleEvent-d8dc2f29-8c94-4ca1-8c5f-3e2b1e3c4f5a"; internal const string WorkspacesLaunchEditor = "Local\\Workspaces-LaunchEditorEvent-a55ff427-cf62-4994-a2cd-9f72139296bf"; internal const string WorkspacesHotkey = "Local\\PowerToys-Workspaces-HotkeyEvent-2625C3C8-BAC9-4DB3-BCD6-3B4391A26FD0"; internal const string CropAndLockThumbnail = "Local\\PowerToysCropAndLockThumbnailEvent-1637be50-da72-46b2-9220-b32b206b2434"; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/PowerToysResourcesHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/PowerToysResourcesHelper.cs index bdf1ed2c39..3f0ecf89ca 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/PowerToysResourcesHelper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/PowerToysResourcesHelper.cs @@ -38,6 +38,7 @@ internal static class PowerToysResourcesHelper SettingsWindow.FileLocksmith => "Assets\\FileLocksmith.png", SettingsWindow.NewPlus => "Assets\\NewPlus.png", SettingsWindow.Peek => "Assets\\Peek.png", + SettingsWindow.LightSwitch => "Assets\\LightSwitch.png", SettingsWindow.AlwaysOnTop => "Assets\\AlwaysOnTop.png", SettingsWindow.CmdNotFound => "Assets\\CommandNotFound.png", SettingsWindow.MouseWithoutBorders => "Assets\\MouseWithoutBorders.png", @@ -79,6 +80,7 @@ internal static class PowerToysResourcesHelper SettingsWindow.FileLocksmith => "File Locksmith", SettingsWindow.NewPlus => "New+", SettingsWindow.Peek => "Peek", + SettingsWindow.LightSwitch => "Light Switch", SettingsWindow.AlwaysOnTop => "Always On Top", SettingsWindow.CmdNotFound => "Command Not Found", SettingsWindow.MouseWithoutBorders => "Mouse Without Borders", diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/DefaultSettingsModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/DefaultSettingsModuleCommandProvider.cs deleted file mode 100644 index bdef511bb1..0000000000 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/DefaultSettingsModuleCommandProvider.cs +++ /dev/null @@ -1,46 +0,0 @@ -// 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.Linq; -using Common.UI; -using Microsoft.CommandPalette.Extensions.Toolkit; -using PowerToysExtension.Commands; -using PowerToysExtension.Helpers; - -namespace PowerToysExtension.Modules; - -/// -/// Provides open-settings commands for modules without specialized commands. -/// -internal sealed class DefaultSettingsModuleCommandProvider : ModuleCommandProvider -{ - private static readonly SettingsDeepLink.SettingsWindow[] _excluded = - [ - SettingsDeepLink.SettingsWindow.Dashboard, - SettingsDeepLink.SettingsWindow.Workspaces, - SettingsDeepLink.SettingsWindow.Awake, - SettingsDeepLink.SettingsWindow.ColorPicker, - ]; - - public override IEnumerable BuildCommands() - { - foreach (var module in Enum.GetValues()) - { - if (_excluded.Contains(module)) - { - continue; - } - - var title = module.ModuleDisplayName(); - yield return new ListItem(new OpenInSettingsCommand(module, title)) - { - Title = title, - Subtitle = "Open module settings", - Icon = module.ModuleIcon(), - }; - } - } -} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/LightSwitchModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/LightSwitchModuleCommandProvider.cs new file mode 100644 index 0000000000..e602917f1d --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/LightSwitchModuleCommandProvider.cs @@ -0,0 +1,38 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class LightSwitchModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.LightSwitch.ModuleDisplayName(); + var icon = SettingsWindow.LightSwitch.ModuleIcon(); + + var items = new List + { + new ListItem(new ToggleLightSwitchCommand()) + { + Title = "Toggle Light Switch", + Subtitle = "Toggle system/apps theme immediately", + Icon = icon, + }, + new ListItem(new OpenInSettingsCommand(SettingsWindow.LightSwitch, title)) + { + Title = title, + Subtitle = "Open Light Switch settings", + Icon = icon, + }, + }; + + return items; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/PowerToysRunModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/PowerToysRunModuleCommandProvider.cs new file mode 100644 index 0000000000..593bebb3a9 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/PowerToysRunModuleCommandProvider.cs @@ -0,0 +1,27 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class PowerToysRunModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.PowerLauncher.ModuleDisplayName(); + var icon = SettingsWindow.PowerLauncher.ModuleIcon(); + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.PowerLauncher, title)) + { + Title = title, + Subtitle = "Open PowerToys Run settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/ScreenRulerModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/ScreenRulerModuleCommandProvider.cs new file mode 100644 index 0000000000..abbf7cb3c9 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/ScreenRulerModuleCommandProvider.cs @@ -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. + +using System.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class ScreenRulerModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.MeasureTool.ModuleDisplayName(); + var icon = SettingsWindow.MeasureTool.ModuleIcon(); + + yield return new ListItem(new ToggleScreenRulerCommand()) + { + Title = "Toggle Screen Ruler", + Subtitle = "Start or close Screen Ruler", + Icon = icon, + }; + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.MeasureTool, title)) + { + Title = title, + Subtitle = "Open Screen Ruler settings", + Icon = icon, + }; + } +}