From f0a4ec801d174863d9c182ee280eda6aa4a4556a Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Wed, 11 Feb 2026 19:35:47 +0100 Subject: [PATCH] Moving IsEnabledCheckbox and KeyVisual to Common.UI.Controls --- PowerToys.slnx | 4 +++ .../Common.UI.Controls.csproj | 29 +++++++++++++++++++ .../CheckBoxWithDescriptionControl.cs | 6 ++-- .../IsEnabledTextBlock.xaml | 6 ++-- .../IsEnabledTextBlock.xaml.cs | 6 ++-- .../Controls/KeyVisual/KeyCharPresenter.xaml | 2 +- .../KeyVisual/KeyCharPresenter.xaml.cs | 10 +------ .../Controls/KeyVisual/KeyVisual.xaml | 6 ++-- .../Controls/KeyVisual/KeyVisual.xaml.cs | 6 ++-- .../Common.UI.Controls/Themes/Generic.xaml | 9 ++++++ .../BoolToKeyVisualStateConverter.cs | 2 +- .../Settings.UI/PowerToys.Settings.csproj | 5 +--- .../Settings.UI/SettingsXAML/App.xaml | 10 ++++--- .../Controls/PowerAccentShortcutControl.xaml | 5 ++-- .../ShortcutControl/ShortcutControl.xaml | 11 +++---- .../ShortcutDialogContentControl.xaml | 5 ++-- .../ShortcutWithTextLabelControl.xaml | 3 +- .../SettingsXAML/Themes/Generic.xaml | 1 - .../SettingsXAML/Views/AdvancedPastePage.xaml | 11 +++---- .../SettingsXAML/Views/CmdPalPage.xaml | 5 ++-- .../SettingsXAML/Views/DashboardPage.xaml | 5 ++-- .../SettingsXAML/Views/FancyZonesPage.xaml | 9 +++--- .../SettingsXAML/Views/GeneralPage.xaml | 9 +++--- .../Views/KeyboardManagerPage.xaml | 13 +++++---- .../SettingsXAML/Views/LightSwitchPage.xaml | 13 +++++---- .../SettingsXAML/Views/PeekPage.xaml | 5 ++-- .../SettingsXAML/Views/PowerLauncherPage.xaml | 23 ++++++++------- .../SettingsXAML/Views/PowerPreviewPage.xaml | 5 ++-- 28 files changed, 135 insertions(+), 89 deletions(-) create mode 100644 src/common/Common.UI.Controls/Common.UI.Controls.csproj rename src/{settings-ui/Settings.UI/SettingsXAML/Controls => common/Common.UI.Controls/Controls/CheckBoxWithDescriptionControl}/CheckBoxWithDescriptionControl.cs (90%) rename src/{settings-ui/Settings.UI/SettingsXAML/Controls => common/Common.UI.Controls/Controls/IsEnabledTextBlock}/IsEnabledTextBlock.xaml (92%) rename src/{settings-ui/Settings.UI/SettingsXAML/Controls => common/Common.UI.Controls/Controls/IsEnabledTextBlock}/IsEnabledTextBlock.xaml.cs (88%) rename src/{settings-ui/Settings.UI/SettingsXAML => common/Common.UI.Controls}/Controls/KeyVisual/KeyCharPresenter.xaml (99%) rename src/{settings-ui/Settings.UI/SettingsXAML => common/Common.UI.Controls}/Controls/KeyVisual/KeyCharPresenter.xaml.cs (70%) rename src/{settings-ui/Settings.UI/SettingsXAML => common/Common.UI.Controls}/Controls/KeyVisual/KeyVisual.xaml (99%) rename src/{settings-ui/Settings.UI/SettingsXAML => common/Common.UI.Controls}/Controls/KeyVisual/KeyVisual.xaml.cs (97%) create mode 100644 src/common/Common.UI.Controls/Themes/Generic.xaml diff --git a/PowerToys.slnx b/PowerToys.slnx index a6bfd3a935..9200fa7868 100644 --- a/PowerToys.slnx +++ b/PowerToys.slnx @@ -17,6 +17,10 @@ + + + + diff --git a/src/common/Common.UI.Controls/Common.UI.Controls.csproj b/src/common/Common.UI.Controls/Common.UI.Controls.csproj new file mode 100644 index 0000000000..c670af6aac --- /dev/null +++ b/src/common/Common.UI.Controls/Common.UI.Controls.csproj @@ -0,0 +1,29 @@ + + + + + + Library + net9.0-windows10.0.26100.0 + Microsoft.PowerToys.Common.UI.Controls + PowerToys.Common.UI.Controls + true + true + true + PowerToys.Common.UI.Controls.pri + enable + x64;ARM64 + + + + + + + + + + + + + + diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Controls/CheckBoxWithDescriptionControl.cs b/src/common/Common.UI.Controls/Controls/CheckBoxWithDescriptionControl/CheckBoxWithDescriptionControl.cs similarity index 90% rename from src/settings-ui/Settings.UI/SettingsXAML/Controls/CheckBoxWithDescriptionControl.cs rename to src/common/Common.UI.Controls/Controls/CheckBoxWithDescriptionControl/CheckBoxWithDescriptionControl.cs index d8b5b6e31a..3073166c3b 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Controls/CheckBoxWithDescriptionControl.cs +++ b/src/common/Common.UI.Controls/Controls/CheckBoxWithDescriptionControl/CheckBoxWithDescriptionControl.cs @@ -1,4 +1,4 @@ -// 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. @@ -8,7 +8,7 @@ using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Automation; using Microsoft.UI.Xaml.Controls; -namespace Microsoft.PowerToys.Settings.UI.Controls +namespace Microsoft.PowerToys.Common.UI.Controls { public partial class CheckBoxWithDescriptionControl : CheckBox { @@ -42,7 +42,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls // Add text box only if the description is not empty. Required for additional plugin options. if (!string.IsNullOrWhiteSpace(Description)) { - panel.Children.Add(new IsEnabledTextBlock() { Style = (Style)App.Current.Resources["SecondaryIsEnabledTextBlockStyle"], Text = Description }); + panel.Children.Add(new IsEnabledTextBlock() { Style = (Style)Application.Current.Resources["SecondaryIsEnabledTextBlockStyle"], Text = Description }); } _checkBoxSubTextControl.Content = panel; diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Controls/IsEnabledTextBlock.xaml b/src/common/Common.UI.Controls/Controls/IsEnabledTextBlock/IsEnabledTextBlock.xaml similarity index 92% rename from src/settings-ui/Settings.UI/SettingsXAML/Controls/IsEnabledTextBlock.xaml rename to src/common/Common.UI.Controls/Controls/IsEnabledTextBlock/IsEnabledTextBlock.xaml index 1c2366ffbe..419e5b81e9 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Controls/IsEnabledTextBlock.xaml +++ b/src/common/Common.UI.Controls/Controls/IsEnabledTextBlock/IsEnabledTextBlock.xaml @@ -1,7 +1,7 @@ - + xmlns:controls="using:Microsoft.PowerToys.Common.UI.Controls"> diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Controls/IsEnabledTextBlock.xaml.cs b/src/common/Common.UI.Controls/Controls/IsEnabledTextBlock/IsEnabledTextBlock.xaml.cs similarity index 88% rename from src/settings-ui/Settings.UI/SettingsXAML/Controls/IsEnabledTextBlock.xaml.cs rename to src/common/Common.UI.Controls/Controls/IsEnabledTextBlock/IsEnabledTextBlock.xaml.cs index 82c6b3a986..3f9556250e 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Controls/IsEnabledTextBlock.xaml.cs +++ b/src/common/Common.UI.Controls/Controls/IsEnabledTextBlock/IsEnabledTextBlock.xaml.cs @@ -1,4 +1,4 @@ -// 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. @@ -7,7 +7,7 @@ using System.ComponentModel; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; -namespace Microsoft.PowerToys.Settings.UI.Controls +namespace Microsoft.PowerToys.Common.UI.Controls { [TemplateVisualState(Name = "Normal", GroupName = "CommonStates")] [TemplateVisualState(Name = "Disabled", GroupName = "CommonStates")] @@ -15,7 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls { public IsEnabledTextBlock() { - this.Style = (Style)App.Current.Resources["DefaultIsEnabledTextBlockStyle"]; + this.Style = (Style)Application.Current.Resources["DefaultIsEnabledTextBlockStyle"]; } protected override void OnApplyTemplate() diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Controls/KeyVisual/KeyCharPresenter.xaml b/src/common/Common.UI.Controls/Controls/KeyVisual/KeyCharPresenter.xaml similarity index 99% rename from src/settings-ui/Settings.UI/SettingsXAML/Controls/KeyVisual/KeyCharPresenter.xaml rename to src/common/Common.UI.Controls/Controls/KeyVisual/KeyCharPresenter.xaml index a28874b4ee..a162a67110 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Controls/KeyVisual/KeyCharPresenter.xaml +++ b/src/common/Common.UI.Controls/Controls/KeyVisual/KeyCharPresenter.xaml @@ -2,7 +2,7 @@ - \ No newline at end of file + diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Controls/KeyVisual/KeyVisual.xaml.cs b/src/common/Common.UI.Controls/Controls/KeyVisual/KeyVisual.xaml.cs similarity index 97% rename from src/settings-ui/Settings.UI/SettingsXAML/Controls/KeyVisual/KeyVisual.xaml.cs rename to src/common/Common.UI.Controls/Controls/KeyVisual/KeyVisual.xaml.cs index 87dc9a4c21..1439a6e1d9 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Controls/KeyVisual/KeyVisual.xaml.cs +++ b/src/common/Common.UI.Controls/Controls/KeyVisual/KeyVisual.xaml.cs @@ -1,4 +1,4 @@ -// 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. @@ -6,7 +6,7 @@ using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Windows.System; -namespace Microsoft.PowerToys.Settings.UI.Controls +namespace Microsoft.PowerToys.Common.UI.Controls { [TemplatePart(Name = KeyPresenter, Type = typeof(KeyCharPresenter))] [TemplateVisualState(Name = NormalState, GroupName = "CommonStates")] @@ -20,7 +20,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls private const string DisabledState = "Disabled"; private const string InvalidState = "Invalid"; private const string WarningState = "Warning"; - private KeyCharPresenter _keyPresenter; + private KeyCharPresenter _keyPresenter = null!; public object Content { diff --git a/src/common/Common.UI.Controls/Themes/Generic.xaml b/src/common/Common.UI.Controls/Themes/Generic.xaml new file mode 100644 index 0000000000..7ee0576030 --- /dev/null +++ b/src/common/Common.UI.Controls/Themes/Generic.xaml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/src/settings-ui/Settings.UI/Converters/BoolToKeyVisualStateConverter.cs b/src/settings-ui/Settings.UI/Converters/BoolToKeyVisualStateConverter.cs index 04a62b02c7..fdbf91e441 100644 --- a/src/settings-ui/Settings.UI/Converters/BoolToKeyVisualStateConverter.cs +++ b/src/settings-ui/Settings.UI/Converters/BoolToKeyVisualStateConverter.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.PowerToys.Settings.UI.Controls; +using Microsoft.PowerToys.Common.UI.Controls; using Microsoft.UI.Xaml.Data; namespace Microsoft.PowerToys.Settings.UI.Converters diff --git a/src/settings-ui/Settings.UI/PowerToys.Settings.csproj b/src/settings-ui/Settings.UI/PowerToys.Settings.csproj index c2b7d81ee4..dbed1d67fa 100644 --- a/src/settings-ui/Settings.UI/PowerToys.Settings.csproj +++ b/src/settings-ui/Settings.UI/PowerToys.Settings.csproj @@ -33,7 +33,6 @@ - @@ -116,6 +115,7 @@ + @@ -183,9 +183,6 @@ MSBuild:Compile - - MSBuild:Compile - MSBuild:Compile diff --git a/src/settings-ui/Settings.UI/SettingsXAML/App.xaml b/src/settings-ui/Settings.UI/SettingsXAML/App.xaml index 54b1e1a02f..05544c2f83 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/App.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/App.xaml @@ -1,17 +1,19 @@ - - - + + + @@ -74,7 +76,7 @@ - - - - - - + - @@ -109,7 +110,7 @@ - + - + - - diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/PeekPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/PeekPage.xaml index 49da343744..962701bf7d 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/PeekPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/PeekPage.xaml @@ -1,8 +1,9 @@ - - diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerLauncherPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerLauncherPage.xaml index 5bcdf7195c..6cad546c85 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerLauncherPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerLauncherPage.xaml @@ -1,8 +1,9 @@ - - - - - - - + @@ -459,7 +460,7 @@ Value="{x:Bind ViewModel.SearchClickedItemWeight, Mode=TwoWay}" /> - + @@ -548,7 +549,7 @@ x:Uid="PowerLauncher_TitleFontSize" HeaderIcon="{ui:FontIcon Glyph=}"> - - - diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerPreviewPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerPreviewPage.xaml index a6b44dfdf7..aeeac74fd0 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerPreviewPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerPreviewPage.xaml @@ -1,8 +1,9 @@ - -