From 7ac7e48e666f50a97bd31c2d0bf9e4b427b64468 Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Mon, 27 Dec 2021 14:29:31 +0100 Subject: [PATCH] [Settings] Added disabled state to FZ preview control (#15166) * Added Disabled state * Added wallpaper image to installer file --- installer/PowerToysSetup/Product.wxs | 2 +- .../Wallpaper.png} | Bin .../Controls/FancyZonesPreviewControl.xaml | 17 ++++++++++++---- .../Controls/FancyZonesPreviewControl.xaml.cs | 19 +++++++++++++++++- .../Settings.UI/Settings.UI.csproj | 2 +- .../Settings.UI/Views/FancyZonesPage.xaml | 2 +- 6 files changed, 34 insertions(+), 8 deletions(-) rename src/settings-ui/Settings.UI/Assets/{wallpaper_placeholder.png => Modules/Wallpaper.png} (100%) diff --git a/installer/PowerToysSetup/Product.wxs b/installer/PowerToysSetup/Product.wxs index 8df7b554a8..2bdbb9619a 100644 --- a/installer/PowerToysSetup/Product.wxs +++ b/installer/PowerToysSetup/Product.wxs @@ -877,7 +877,7 @@ - + diff --git a/src/settings-ui/Settings.UI/Assets/wallpaper_placeholder.png b/src/settings-ui/Settings.UI/Assets/Modules/Wallpaper.png similarity index 100% rename from src/settings-ui/Settings.UI/Assets/wallpaper_placeholder.png rename to src/settings-ui/Settings.UI/Assets/Modules/Wallpaper.png diff --git a/src/settings-ui/Settings.UI/Controls/FancyZonesPreviewControl.xaml b/src/settings-ui/Settings.UI/Controls/FancyZonesPreviewControl.xaml index a6f7b5f9f9..3195fa46b0 100644 --- a/src/settings-ui/Settings.UI/Controls/FancyZonesPreviewControl.xaml +++ b/src/settings-ui/Settings.UI/Controls/FancyZonesPreviewControl.xaml @@ -6,10 +6,9 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters" + Loaded="FancyZonesPreviewControl_Loaded" RequestedTheme="Dark" - mc:Ignorable="d" - d:DesignHeight="300" - d:DesignWidth="400"> + mc:Ignorable="d"> @@ -32,7 +31,7 @@ - + @@ -42,6 +41,16 @@ + + + + + + + + + + diff --git a/src/settings-ui/Settings.UI/Controls/FancyZonesPreviewControl.xaml.cs b/src/settings-ui/Settings.UI/Controls/FancyZonesPreviewControl.xaml.cs index 25e200669f..b608706952 100644 --- a/src/settings-ui/Settings.UI/Controls/FancyZonesPreviewControl.xaml.cs +++ b/src/settings-ui/Settings.UI/Controls/FancyZonesPreviewControl.xaml.cs @@ -34,6 +34,11 @@ namespace Microsoft.PowerToys.Settings.UI.Controls } } + private void FancyZonesPreviewControl_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) + { + SetEnabledState(); + } + public bool IsSystemTheme { get { return (bool)GetValue(IsSystemThemeProperty); } @@ -48,7 +53,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls set { SetValue(WallpaperPathProperty, value); } } - public static readonly DependencyProperty WallpaperPathProperty = DependencyProperty.Register("WallpaperPath", typeof(string), typeof(FancyZonesPreviewControl), new PropertyMetadata("ms-appx:///Assets/wallpaper_placeholder.png")); + public static readonly DependencyProperty WallpaperPathProperty = DependencyProperty.Register("WallpaperPath", typeof(string), typeof(FancyZonesPreviewControl), new PropertyMetadata("ms-appx:///Assets/Modules/Wallpaper.png")); public Color CustomBorderColor { @@ -139,5 +144,17 @@ namespace Microsoft.PowerToys.Settings.UI.Controls Zone2Number.Foreground = numberBrush; Zone3Number.Foreground = numberBrush; } + + private void SetEnabledState() + { + VisualStateManager.GoToState(this, IsEnabled ? "Normal" : "Disabled", true); + } + + private void FancyZonesPreviewControl_Loaded(object sender, RoutedEventArgs e) + { + IsEnabledChanged -= FancyZonesPreviewControl_IsEnabledChanged; + SetEnabledState(); + IsEnabledChanged += FancyZonesPreviewControl_IsEnabledChanged; + } } } diff --git a/src/settings-ui/Settings.UI/Settings.UI.csproj b/src/settings-ui/Settings.UI/Settings.UI.csproj index d959387b7b..938dfef33d 100644 --- a/src/settings-ui/Settings.UI/Settings.UI.csproj +++ b/src/settings-ui/Settings.UI/Settings.UI.csproj @@ -280,7 +280,7 @@ - + diff --git a/src/settings-ui/Settings.UI/Views/FancyZonesPage.xaml b/src/settings-ui/Settings.UI/Views/FancyZonesPage.xaml index c0ff3c84ce..3394dafc6e 100644 --- a/src/settings-ui/Settings.UI/Views/FancyZonesPage.xaml +++ b/src/settings-ui/Settings.UI/Views/FancyZonesPage.xaml @@ -116,7 +116,7 @@ CustomNumberColor="{x:Bind Path=ViewModel.ZoneNumberColor, Mode=OneWay}" ShowZoneNumber="{x:Bind Path=ViewModel.ShowZoneNumber, Mode=OneWay}" Margin="{StaticResource ExpanderSettingMargin}" - HorizontalAlignment="Left" + HorizontalAlignment="Center" Width="170" Grid.Column="1" Height="86"/>