From f66fcbd786c3148f875dc3d54a978c75ad26127f Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Sat, 11 Oct 2025 17:06:11 +0200 Subject: [PATCH] Moving hotkey related settings in the expander --- .../cmdpal/Microsoft.CmdPal.UI/App.xaml | 4 +- .../CheckBoxWithDescriptionControl.cs | 76 +++++++++++++++++++ .../Controls/IsEnabledTextBlock.xaml | 43 +++++++++++ .../Controls/IsEnabledTextBlock.xaml.cs | 51 +++++++++++++ .../Microsoft.CmdPal.UI.csproj | 14 ++++ .../Settings/GeneralPage.xaml | 12 ++- .../Strings/en-us/Resources.resw | 14 ++-- .../Microsoft.CmdPal.UI/Themes/Generic.xaml | 1 - 8 files changed, 199 insertions(+), 16 deletions(-) create mode 100644 src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/CheckBoxWithDescriptionControl.cs create mode 100644 src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/IsEnabledTextBlock.xaml create mode 100644 src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/IsEnabledTextBlock.xaml.cs delete mode 100644 src/modules/cmdpal/Microsoft.CmdPal.UI/Themes/Generic.xaml diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml index 745dc31d95..f9a9e37ea1 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml @@ -3,6 +3,7 @@ x:Class="Microsoft.CmdPal.UI.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:controls="using:Microsoft.CmdPal.UI.Controls" xmlns:local="using:Microsoft.CmdPal.UI"> @@ -15,11 +16,12 @@ + 240 - + + + \ No newline at end of file diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/IsEnabledTextBlock.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/IsEnabledTextBlock.xaml.cs new file mode 100644 index 0000000000..ffe65bc9f9 --- /dev/null +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/IsEnabledTextBlock.xaml.cs @@ -0,0 +1,51 @@ +// 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 Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; + +namespace Microsoft.CmdPal.UI.Controls; + +[TemplateVisualState(Name = "Normal", GroupName = "CommonStates")] +[TemplateVisualState(Name = "Disabled", GroupName = "CommonStates")] +public partial class IsEnabledTextBlock : Control +{ + public IsEnabledTextBlock() + { + this.Style = (Style)App.Current.Resources["DefaultIsEnabledTextBlockStyle"]; + } + + protected override void OnApplyTemplate() + { + IsEnabledChanged -= IsEnabledTextBlock_IsEnabledChanged; + SetEnabledState(); + IsEnabledChanged += IsEnabledTextBlock_IsEnabledChanged; + base.OnApplyTemplate(); + } + + public static readonly DependencyProperty TextProperty = DependencyProperty.Register( + "Text", + typeof(string), + typeof(IsEnabledTextBlock), + null); + + [Localizable(true)] + public string Text + { + get => (string)GetValue(TextProperty); + set => SetValue(TextProperty, value); + } + + private void IsEnabledTextBlock_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) + { + SetEnabledState(); + } + + private void SetEnabledState() + { + VisualStateManager.GoToState(this, IsEnabled ? "Normal" : "Disabled", true); + } +} diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj index b41f20a5a1..f577f13898 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj @@ -66,7 +66,9 @@ + + @@ -180,6 +182,18 @@ PreserveNewest + + + + MSBuild:Compile + + + + + + MSBuild:Compile + + MSBuild:Compile diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/GeneralPage.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/GeneralPage.xaml index 21cee5407c..2899e15c1d 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/GeneralPage.xaml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/GeneralPage.xaml @@ -37,22 +37,20 @@ - - - - + + + + + - - - diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw b/src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw index 39b9bf2cf2..ec7ce8b68c 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw @@ -257,7 +257,7 @@ Right-click to remove the key combination, thereby deactivating the shortcut.Disabled Displayed when an extension is disabled - + Enable Displayed on a toggle controlling the extension's enabled / disabled state @@ -314,13 +314,13 @@ Right-click to remove the key combination, thereby deactivating the shortcut. A short keyword used to navigate to this command. - + Alias activation - + Choose when the alias runs. Direct runs as soon as you type the alias. Indirect runs after a trailing space. - - + + Built-in @@ -441,7 +441,7 @@ Right-click to remove the key combination, thereby deactivating the shortcut. Indirect - + Enter alias @@ -463,7 +463,7 @@ Right-click to remove the key combination, thereby deactivating the shortcut.Trigger reload of the extension externally with the x-cmdpal://reload command - For Developers + For developers an untitled diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Themes/Generic.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Themes/Generic.xaml deleted file mode 100644 index 6903d112e3..0000000000 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Themes/Generic.xaml +++ /dev/null @@ -1 +0,0 @@ -