diff --git a/.pipelines/ESRPSigning_core.json b/.pipelines/ESRPSigning_core.json index a769e488e6..dac486b7a2 100644 --- a/.pipelines/ESRPSigning_core.json +++ b/.pipelines/ESRPSigning_core.json @@ -123,8 +123,6 @@ "modules\\MouseUtils\\PowerToys.MousePointerCrosshairs.dll", "modules\\PowerAccent\\PowerAccent.Core.dll", - "modules\\PowerAccent\\PowerAccent.dll", - "modules\\PowerAccent\\PowerAccent.exe", "modules\\PowerAccent\\PowerToys.PowerAccent.dll", "modules\\PowerAccent\\PowerToys.PowerAccent.exe", "modules\\PowerAccent\\PowerToys.PowerAccentModuleInterface.dll", diff --git a/PowerToys.sln b/PowerToys.sln index d6372908a2..1d85f27dde 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -421,8 +421,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PowerAccent", "PowerAccent" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PowerAccentModuleInterface", "src\modules\poweraccent\PowerAccentModuleInterface\PowerAccentModuleInterface.vcxproj", "{34A354C5-23C7-4343-916C-C52DAF4FC39D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerAccent", "src\modules\poweraccent\PowerAccent\PowerAccent.csproj", "{7B4CDB0D-28C9-4F95-88AA-73FCC06E354C}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerAccent.Core", "src\modules\poweraccent\PowerAccent.Core\PowerAccent.Core.csproj", "{3264DF53-C805-4B0C-867C-FCEAF7AEF762}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerAccent.UI", "src\modules\poweraccent\PowerAccent.UI\PowerAccent.UI.csproj", "{31CAD28E-778A-441C-85BC-40AB3EAA2A10}" @@ -468,7 +466,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FileLocksmithLibInterop", " EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GPOWrapper", "src\common\GPOWrapper\GPOWrapper.vcxproj", "{E599C30B-9DC8-4E5A-BF27-93D4CCEDE788}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GPOWrapperProjection", "src\common\GPOWrapperProjection\GPOWrapperProjection.csproj", "{00EE9BA6-4E8F-43CA-960D-D4882F0FBB97}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GPOWrapperProjection", "src\common\GPOWrapperProjection\GPOWrapperProjection.csproj", "{00EE9BA6-4E8F-43CA-960D-D4882F0FBB97}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -1699,18 +1697,6 @@ Global {34A354C5-23C7-4343-916C-C52DAF4FC39D}.Release|x64.Build.0 = Release|x64 {34A354C5-23C7-4343-916C-C52DAF4FC39D}.Release|x86.ActiveCfg = Release|x64 {34A354C5-23C7-4343-916C-C52DAF4FC39D}.Release|x86.Build.0 = Release|x64 - {7B4CDB0D-28C9-4F95-88AA-73FCC06E354C}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {7B4CDB0D-28C9-4F95-88AA-73FCC06E354C}.Debug|ARM64.Build.0 = Debug|ARM64 - {7B4CDB0D-28C9-4F95-88AA-73FCC06E354C}.Debug|x64.ActiveCfg = Debug|x64 - {7B4CDB0D-28C9-4F95-88AA-73FCC06E354C}.Debug|x64.Build.0 = Debug|x64 - {7B4CDB0D-28C9-4F95-88AA-73FCC06E354C}.Debug|x86.ActiveCfg = Debug|x64 - {7B4CDB0D-28C9-4F95-88AA-73FCC06E354C}.Debug|x86.Build.0 = Debug|x64 - {7B4CDB0D-28C9-4F95-88AA-73FCC06E354C}.Release|ARM64.ActiveCfg = Release|ARM64 - {7B4CDB0D-28C9-4F95-88AA-73FCC06E354C}.Release|ARM64.Build.0 = Release|ARM64 - {7B4CDB0D-28C9-4F95-88AA-73FCC06E354C}.Release|x64.ActiveCfg = Release|x64 - {7B4CDB0D-28C9-4F95-88AA-73FCC06E354C}.Release|x64.Build.0 = Release|x64 - {7B4CDB0D-28C9-4F95-88AA-73FCC06E354C}.Release|x86.ActiveCfg = Release|x64 - {7B4CDB0D-28C9-4F95-88AA-73FCC06E354C}.Release|x86.Build.0 = Release|x64 {3264DF53-C805-4B0C-867C-FCEAF7AEF762}.Debug|ARM64.ActiveCfg = Debug|ARM64 {3264DF53-C805-4B0C-867C-FCEAF7AEF762}.Debug|ARM64.Build.0 = Debug|ARM64 {3264DF53-C805-4B0C-867C-FCEAF7AEF762}.Debug|x64.ActiveCfg = Debug|x64 @@ -2049,7 +2035,6 @@ Global {18B3DB45-4FFE-4D01-97D6-5223FEEE1853} = {6C7F47CC-2151-44A3-A546-41C70025132C} {0F14491C-6369-4C45-AAA8-135814E66E6B} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC} {34A354C5-23C7-4343-916C-C52DAF4FC39D} = {0F14491C-6369-4C45-AAA8-135814E66E6B} - {7B4CDB0D-28C9-4F95-88AA-73FCC06E354C} = {0F14491C-6369-4C45-AAA8-135814E66E6B} {3264DF53-C805-4B0C-867C-FCEAF7AEF762} = {0F14491C-6369-4C45-AAA8-135814E66E6B} {31CAD28E-778A-441C-85BC-40AB3EAA2A10} = {0F14491C-6369-4C45-AAA8-135814E66E6B} {A50C70A6-2DA0-4027-B90E-B1A40755A8A5} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC} diff --git a/installer/PowerToysSetup/Product.wxs b/installer/PowerToysSetup/Product.wxs index 2a96496591..c79e9912d1 100644 --- a/installer/PowerToysSetup/Product.wxs +++ b/installer/PowerToysSetup/Product.wxs @@ -139,7 +139,7 @@ - + + + - - - - - + + + - + \ No newline at end of file diff --git a/src/modules/poweraccent/PowerAccent.UI/App.xaml.cs b/src/modules/poweraccent/PowerAccent.UI/App.xaml.cs index 7bdade3e0c..e4c77b9d0b 100644 --- a/src/modules/poweraccent/PowerAccent.UI/App.xaml.cs +++ b/src/modules/poweraccent/PowerAccent.UI/App.xaml.cs @@ -1,32 +1,64 @@ -// Copyright (c) Microsoft Corporation +// 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 System.Windows; +using Common.UI; +using PowerAccent.Core.Tools; namespace PowerAccent.UI { /// /// Interaction logic for App.xaml /// - public partial class App : Application + public partial class App : Application, IDisposable { private static Mutex _mutex; + private bool _disposed; + private ThemeManager _themeManager; protected override void OnStartup(StartupEventArgs e) { - const string appName = "QuickAccent"; - - _mutex = new Mutex(true, appName, out bool createdNew); + _mutex = new Mutex(true, "QuickAccent", out bool createdNew); if (!createdNew) { - // app is already running! Exiting the application + Logger.LogWarning("Another running QuickAccent instance was detected. Exiting QuickAccent"); Application.Current.Shutdown(); } + _themeManager = new ThemeManager(this); base.OnStartup(e); } + + protected override void OnExit(ExitEventArgs e) + { + _mutex?.ReleaseMutex(); + base.OnExit(e); + } + + protected virtual void Dispose(bool disposing) + { + if (_disposed) + { + return; + } + + if (disposing) + { + _mutex?.Dispose(); + _themeManager?.Dispose(); + } + + _disposed = true; + } + + public void Dispose() + { + Dispose(disposing: true); + GC.SuppressFinalize(this); + } } } diff --git a/src/modules/poweraccent/PowerAccent.UI/PowerAccent.UI.csproj b/src/modules/poweraccent/PowerAccent.UI/PowerAccent.UI.csproj index e1ca4058b4..18db1b36e4 100644 --- a/src/modules/poweraccent/PowerAccent.UI/PowerAccent.UI.csproj +++ b/src/modules/poweraccent/PowerAccent.UI/PowerAccent.UI.csproj @@ -7,25 +7,24 @@ disable true True - a-icon.ico - PowerAccent + icon.ico + PowerToys.PowerAccent True + PowerAccent.UI.Program + $(SolutionDir)$(Platform)\$(Configuration)\modules\PowerAccent + false + false - - - - - + PreserveNewest - - + @@ -33,7 +32,4 @@ - - - diff --git a/src/modules/poweraccent/PowerAccent/Program.cs b/src/modules/poweraccent/PowerAccent.UI/Program.cs similarity index 60% rename from src/modules/poweraccent/PowerAccent/Program.cs rename to src/modules/poweraccent/PowerAccent.UI/Program.cs index 13e783a4f6..8c664ffba1 100644 --- a/src/modules/poweraccent/PowerAccent/Program.cs +++ b/src/modules/poweraccent/PowerAccent.UI/Program.cs @@ -1,7 +1,6 @@ // 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. -#pragma warning disable SA1310 // FieldNamesMustNotContainUnderscore using System; using System.Diagnostics; @@ -11,43 +10,31 @@ using System.Windows; using interop; using ManagedCommon; using PowerAccent.Core.Tools; -using PowerAccent.UI; -namespace PowerAccent; +namespace PowerAccent.UI; internal static class Program { - private static readonly CancellationTokenSource _tokenSource = new (); - private const string PROGRAM_NAME = "QuickAccent"; - private const string PROGRAM_APP_NAME = "PowerToys.PowerAccent"; + private static readonly CancellationTokenSource _tokenSource = new CancellationTokenSource(); private static App _application; private static int _powerToysRunnerPid; [STAThread] public static void Main(string[] args) { - _ = new Mutex(true, PROGRAM_APP_NAME, out bool instantiated); - if (PowerToys.GPOWrapper.GPOWrapper.GetConfiguredQuickAccentEnabledValue() == PowerToys.GPOWrapper.GpoRuleConfigured.Disabled) { Logger.LogWarning("Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator."); return; } - if (instantiated) - { - Arguments(args); + Arguments(args); - InitEvents(); + InitEvents(); - _application = new App(); - _application.InitializeComponent(); - _application.Run(); - } - else - { - Logger.LogWarning("Another running QuickAccent instance was detected. Exiting QuickAccent"); - } + _application = new App(); + _application.InitializeComponent(); + _application.Run(); } private static void InitEvents() @@ -55,7 +42,7 @@ internal static class Program Task.Run( () => { - EventWaitHandle eventHandle = new (false, EventResetMode.AutoReset, Constants.PowerAccentExitEvent()); + EventWaitHandle eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.PowerAccentExitEvent()); if (eventHandle.WaitOne()) { Terminate(); @@ -69,15 +56,16 @@ internal static class Program { try { - _ = int.TryParse(args[0], out _powerToysRunnerPid); - - Logger.LogInfo($"QuickAccent started from the PowerToys Runner. Runner pid={_powerToysRunnerPid}"); - - RunnerHelper.WaitForPowerToysRunner(_powerToysRunnerPid, () => + if (int.TryParse(args[0], out _powerToysRunnerPid)) { - Logger.LogInfo("PowerToys Runner exited. Exiting QuickAccent"); - Terminate(); - }); + Logger.LogInfo($"QuickAccent started from the PowerToys Runner. Runner pid={_powerToysRunnerPid}"); + + RunnerHelper.WaitForPowerToysRunner(_powerToysRunnerPid, () => + { + Logger.LogInfo("PowerToys Runner exited. Exiting QuickAccent"); + Terminate(); + }); + } } catch (Exception ex) { diff --git a/src/modules/poweraccent/PowerAccent.UI/Selector.xaml b/src/modules/poweraccent/PowerAccent.UI/Selector.xaml index 951322b4fa..b1624ae757 100644 --- a/src/modules/poweraccent/PowerAccent.UI/Selector.xaml +++ b/src/modules/poweraccent/PowerAccent.UI/Selector.xaml @@ -5,6 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:PowerAccent.UI" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:ui="http://schemas.modernwpf.com/2019" Title="MainWindow" Height="120" MinWidth="600" @@ -23,6 +24,7 @@ @@ -42,8 +44,8 @@ @@ -57,82 +59,72 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - + + + Fill="{DynamicResource DividerBorderBrush}" /> diff --git a/src/modules/poweraccent/PowerAccent.UI/Themes/Dark.xaml b/src/modules/poweraccent/PowerAccent.UI/Themes/Dark.xaml new file mode 100644 index 0000000000..07ed9f95ce --- /dev/null +++ b/src/modules/poweraccent/PowerAccent.UI/Themes/Dark.xaml @@ -0,0 +1,32 @@ + + + + Dark.Accent1 + PowerToysRun + Accent1 (Dark) + Dark + Accent1 + Black + + + + + + + + \ No newline at end of file diff --git a/src/modules/poweraccent/PowerAccent.UI/Themes/HighContrast1.xaml b/src/modules/poweraccent/PowerAccent.UI/Themes/HighContrast1.xaml new file mode 100644 index 0000000000..42d269d7fe --- /dev/null +++ b/src/modules/poweraccent/PowerAccent.UI/Themes/HighContrast1.xaml @@ -0,0 +1,26 @@ + + + + HighContrast.Accent2 + PowerToysRun + Accent2 (HighContrast) + HighContrast + Accent2 + White + + + + + + + + \ No newline at end of file diff --git a/src/modules/poweraccent/PowerAccent.UI/Themes/HighContrast2.xaml b/src/modules/poweraccent/PowerAccent.UI/Themes/HighContrast2.xaml new file mode 100644 index 0000000000..825f0267bf --- /dev/null +++ b/src/modules/poweraccent/PowerAccent.UI/Themes/HighContrast2.xaml @@ -0,0 +1,26 @@ + + + + HighContrast.Accent3 + PowerToysRun + Accent3 (HighContrast) + HighContrast + Accent3 + White + + + + + + + + \ No newline at end of file diff --git a/src/modules/poweraccent/PowerAccent.UI/Themes/HighContrastBlack.xaml b/src/modules/poweraccent/PowerAccent.UI/Themes/HighContrastBlack.xaml new file mode 100644 index 0000000000..eee95d5823 --- /dev/null +++ b/src/modules/poweraccent/PowerAccent.UI/Themes/HighContrastBlack.xaml @@ -0,0 +1,26 @@ + + + + HighContrast.Accent4 + PowerToysRun + Accent4 (HighContrast) + HighContrast + Accent4 + White + + + + + + + + \ No newline at end of file diff --git a/src/modules/poweraccent/PowerAccent.UI/Themes/HighContrastWhite.xaml b/src/modules/poweraccent/PowerAccent.UI/Themes/HighContrastWhite.xaml new file mode 100644 index 0000000000..5a9f6df8ab --- /dev/null +++ b/src/modules/poweraccent/PowerAccent.UI/Themes/HighContrastWhite.xaml @@ -0,0 +1,26 @@ + + + + HighContrast.Accent5 + PowerToysRun + Accent5 (HighContrast) + HighContrast + Accent5 + White + + + + + + + + \ No newline at end of file diff --git a/src/modules/poweraccent/PowerAccent.UI/Themes/Light.xaml b/src/modules/poweraccent/PowerAccent.UI/Themes/Light.xaml new file mode 100644 index 0000000000..22f8213eee --- /dev/null +++ b/src/modules/poweraccent/PowerAccent.UI/Themes/Light.xaml @@ -0,0 +1,35 @@ + + + + Light.Accent1 + PowerToysRun + Accent1 (Light) + Light + Accent1 + White + + + + + + + + \ No newline at end of file diff --git a/src/modules/poweraccent/PowerAccent.UI/a-icon.ico b/src/modules/poweraccent/PowerAccent.UI/icon.ico similarity index 100% rename from src/modules/poweraccent/PowerAccent.UI/a-icon.ico rename to src/modules/poweraccent/PowerAccent.UI/icon.ico diff --git a/src/modules/poweraccent/PowerAccent.UI/win11desktop.jpg b/src/modules/poweraccent/PowerAccent.UI/win11desktop.jpg deleted file mode 100644 index f331b98a9d..0000000000 Binary files a/src/modules/poweraccent/PowerAccent.UI/win11desktop.jpg and /dev/null differ diff --git a/src/modules/poweraccent/PowerAccent/PowerAccent.csproj b/src/modules/poweraccent/PowerAccent/PowerAccent.csproj deleted file mode 100644 index e3c2dbbd63..0000000000 --- a/src/modules/poweraccent/PowerAccent/PowerAccent.csproj +++ /dev/null @@ -1,27 +0,0 @@ - - - - WinExe - net7.0-windows10.0.19041.0 - win-x64;win-arm64 - true - disable - PowerAccent.Program - $(SolutionDir)$(Platform)\$(Configuration)\modules\PowerAccent - false - false - PowerToys.PowerAccent - - - - - - - - - - - - - - diff --git a/src/modules/poweraccent/PowerAccent/win11desktop.jpg b/src/modules/poweraccent/PowerAccent/win11desktop.jpg deleted file mode 100644 index f331b98a9d..0000000000 Binary files a/src/modules/poweraccent/PowerAccent/win11desktop.jpg and /dev/null differ