From 4f335b94710252147646ca74d02842ea93ea030f Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Tue, 19 Oct 2021 13:44:13 +0200 Subject: [PATCH] [Settings][Chore] Add CheckBoxWithDescriptionControl (#13866) * Added new control * Update Microsoft.PowerToys.Settings.UI.csproj * Added styling * Add enableableTextBlock * Update EnableableTextBlock.xaml * Updated styles * Updates styles * Updated margins * Name change and typo fix * Update App.xaml * Control name change * Update expect.txt * More name changes * Even more name changes Co-authored-by: Laute --- .../Microsoft.PowerToys.Settings.UI/App.xaml | 5 ++ .../CheckBoxWithDescriptionControl.cs | 72 ++++++++++++++++++ .../IsEnabledTextBlock/IsEnabledTextBlock.cs | 51 +++++++++++++ .../IsEnabledTextBlock.xaml | 34 +++++++++ .../Controls/TextBlockControl.xaml | 15 ---- .../Controls/TextBlockControl.xaml.cs | 76 ------------------- .../Microsoft.PowerToys.Settings.UI.csproj | 15 ++-- .../Strings/en-us/Resources.resw | 11 ++- .../Themes/Generic.xaml | 1 + .../Themes/SettingsExpanderStyles.xaml | 1 - .../Views/FancyZonesPage.xaml | 26 ++----- .../Views/PowerLauncherPage.xaml | 15 ++-- 12 files changed, 194 insertions(+), 128 deletions(-) create mode 100644 src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/CheckBoxWithDescriptionControl.cs create mode 100644 src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/IsEnabledTextBlock/IsEnabledTextBlock.cs create mode 100644 src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/IsEnabledTextBlock/IsEnabledTextBlock.xaml delete mode 100644 src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/TextBlockControl.xaml delete mode 100644 src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/TextBlockControl.xaml.cs diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/App.xaml b/src/settings-ui/Microsoft.PowerToys.Settings.UI/App.xaml index 6900c4b1e9..d2283fa45c 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/App.xaml +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/App.xaml @@ -2,12 +2,14 @@ x:Class="Microsoft.PowerToys.Settings.UI.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls" xmlns:xaml="using:Microsoft.Toolkit.Win32.UI.XamlHost"> + @@ -23,6 +25,9 @@ + + + diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/TextBlockControl.xaml b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/TextBlockControl.xaml deleted file mode 100644 index 7733a34b35..0000000000 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/TextBlockControl.xaml +++ /dev/null @@ -1,15 +0,0 @@ - - - - diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/TextBlockControl.xaml.cs b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/TextBlockControl.xaml.cs deleted file mode 100644 index 66f89bbde2..0000000000 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/TextBlockControl.xaml.cs +++ /dev/null @@ -1,76 +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.ComponentModel; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Media; - -namespace Microsoft.PowerToys.Settings.UI.Controls -{ - public sealed partial class TextBlockControl : UserControl - { - public static readonly DependencyProperty TextProperty = DependencyProperty.Register( - "Text", - typeof(string), - typeof(TextBlockControl), - null); - - [Localizable(true)] - public string Text - { - get => (string)GetValue(TextProperty); - set => SetValue(TextProperty, value); - } - - public static readonly DependencyProperty EnabledForegroundProperty = DependencyProperty.Register( - "EnabledForeground", - typeof(Brush), - typeof(TextBlockControl), - null); - - public Brush EnabledForeground - { - get => (Brush)GetValue(EnabledForegroundProperty); - set => SetValue(EnabledForegroundProperty, value); - } - - public static readonly DependencyProperty DisabledForegroundProperty = DependencyProperty.Register( - "DisabledForeground", - typeof(Brush), - typeof(TextBlockControl), - null); - - public Brush DisabledForeground - { - get => (Brush)GetValue(DisabledForegroundProperty); - set => SetValue(DisabledForegroundProperty, value); - } - - public TextBlockControl() - { - this.InitializeComponent(); - DataContext = this; - - IsEnabledChanged += TextBlockControl_IsEnabledChanged; - } - - private void TextBlockControl_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) - { - if ((bool)e.NewValue) - { - textBlock.Foreground = EnabledForeground; - } - else - { - textBlock.Foreground = DisabledForeground; - } - } - - private void TextBlock_Loaded(object sender, RoutedEventArgs e) - { - textBlock.Foreground = IsEnabled ? EnabledForeground : DisabledForeground; - } - } -} diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj index b798b3f676..32924752b5 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj @@ -95,6 +95,8 @@ + + ShortcutControl.xaml @@ -116,9 +118,6 @@ OOBEPageControl.xaml - - TextBlockControl.xaml - @@ -303,9 +302,13 @@ - + + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -338,10 +341,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - MSBuild:Compile Designer diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw index 05481e4593..6a22e1ab88 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw @@ -401,8 +401,11 @@ Ignore shortcuts in fullscreen mode - - Use centralized keyboard hook (try it if there are issues with the shortcut) + + Use centralized keyboard hook + + + Try this if there are issues with the shortcut Clear the previous query on launch @@ -913,7 +916,7 @@ Made with 💗 by Microsoft and the PowerToys community. Windows refers to the OS - + Allow zones to span across monitors @@ -1627,7 +1630,7 @@ From there, simply click on a Markdown file, PDF file or SVG icon in the File Ex Only shortcuts that start with **Windows key**, **Ctrl**, **Alt** or **Shift** are valid. - + All monitors must have the same DPI scaling and will be treated as one large combined rectangle which contains all monitors diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Themes/Generic.xaml b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Themes/Generic.xaml index c1f16179e8..8629816d97 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Themes/Generic.xaml +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Themes/Generic.xaml @@ -5,5 +5,6 @@ + diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Themes/SettingsExpanderStyles.xaml b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Themes/SettingsExpanderStyles.xaml index 9c6b088c91..f56e2adfa9 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Themes/SettingsExpanderStyles.xaml +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Themes/SettingsExpanderStyles.xaml @@ -34,7 +34,6 @@ -