[FancyZones] Zone Number Settings (#14910)

This commit is contained in:
Davide Giacometti
2021-12-20 17:50:51 +01:00
committed by GitHub
parent 3805348afd
commit 288e0487a0
17 changed files with 208 additions and 73 deletions

View File

@@ -15,16 +15,20 @@
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="SolidBackgroundBrush" Color="Black" />
<SolidColorBrush x:Key="SolidZoneNumberBrush" Color="White" />
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="SolidBackgroundBrush" Color="White" />
<SolidColorBrush x:Key="SolidZoneNumberBrush" Color="Black" />
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<SolidColorBrush x:Key="SolidBackgroundBrush" Color="Black" />
<SolidColorBrush x:Key="SolidZoneNumberBrush" Color="White" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<SolidColorBrush x:Key="DefaultAccentBrush" Color="{ThemeResource SystemAccentColor}"/>
<SolidColorBrush x:Key="DefaultBorderBrush" Color="{ThemeResource SystemAccentColor}"/>
<converters:BoolToObjectConverter x:Key="BoolToVisibilityConverter" TrueValue="Visible" FalseValue="Collapsed"/>
</ResourceDictionary>
</UserControl.Resources>
@@ -43,8 +47,14 @@
</Border>
<Grid Background="{ThemeResource SystemControlAcrylicElementBrush}" Grid.Row="2" Grid.ColumnSpan="2"/>
<Border x:Name="Zone1" Margin="4,4,2,4" CornerRadius="2" Grid.RowSpan="2" BorderThickness="1"/>
<Border x:Name="Zone2" Margin="2,4,4,2" CornerRadius="2" Grid.Column="1" BorderThickness="1"/>
<Border x:Name="Zone3" Margin="2,2,4,4" CornerRadius="2" Grid.Row="1" Grid.Column="1" BorderThickness="1"/>
<Border x:Name="Zone1" Margin="4,4,2,4" CornerRadius="2" Grid.RowSpan="2" BorderThickness="1">
<TextBlock x:Name="Zone1Number" Text="1" FontWeight="SemiBold" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="{x:Bind ShowZoneNumber, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"/>
</Border>
<Border x:Name="Zone2" Margin="2,4,4,2" CornerRadius="2" Grid.Column="1" BorderThickness="1">
<TextBlock x:Name="Zone2Number" Text="2" FontWeight="SemiBold" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="{x:Bind ShowZoneNumber, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"/>
</Border>
<Border x:Name="Zone3" Margin="2,2,4,4" CornerRadius="2" Grid.Row="1" Grid.Column="1" BorderThickness="1">
<TextBlock x:Name="Zone3Number" Text="3" FontWeight="SemiBold" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="{x:Bind ShowZoneNumber, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"/>
</Border>
</Grid>
</UserControl>

View File

@@ -40,14 +40,14 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
set { SetValue(IsSystemThemeProperty, value); }
}
public static readonly DependencyProperty IsSystemThemeProperty = DependencyProperty.Register("IsSystemTheme", typeof(bool), typeof(FancyZonesPreviewControl), new PropertyMetadata(default(bool), OnPropertyChanged));
public string WallpaperPath
{
get { return (string)GetValue(WallpaperPathProperty); }
set { SetValue(WallpaperPathProperty, value); }
}
public static readonly DependencyProperty IsSystemThemeProperty = DependencyProperty.Register("IsSystemTheme", typeof(bool), typeof(FancyZonesPreviewControl), new PropertyMetadata(default(bool), OnPropertyChanged));
public static readonly DependencyProperty WallpaperPathProperty = DependencyProperty.Register("WallpaperPath", typeof(string), typeof(FancyZonesPreviewControl), new PropertyMetadata("ms-appx:///Assets/wallpaper_placeholder.png"));
public Color CustomBorderColor
@@ -74,6 +74,22 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
public static readonly DependencyProperty CustomHighlightColorProperty = DependencyProperty.Register("CustomHighlightColor", typeof(Color), typeof(FancyZonesPreviewControl), new PropertyMetadata(null, OnPropertyChanged));
public Color CustomNumberColor
{
get { return (Color)GetValue(CustomNumberColorProperty); }
set { SetValue(CustomNumberColorProperty, value); }
}
public static readonly DependencyProperty CustomNumberColorProperty = DependencyProperty.Register("CustomNumberColor", typeof(Color), typeof(FancyZonesPreviewControl), new PropertyMetadata(null, OnPropertyChanged));
public bool ShowZoneNumber
{
get { return (bool)GetValue(ShowZoneNumberProperty); }
set { SetValue(ShowZoneNumberProperty, value); }
}
public static readonly DependencyProperty ShowZoneNumberProperty = DependencyProperty.Register("ShowZoneNumber", typeof(bool), typeof(FancyZonesPreviewControl), new PropertyMetadata(default(bool), OnPropertyChanged));
public double HighlightOpacity
{
get { return (double)GetValue(HighlightOpacityProperty); }
@@ -90,6 +106,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
private SolidColorBrush highlightBrush;
private SolidColorBrush inActiveBrush;
private SolidColorBrush borderBrush;
private SolidColorBrush numberBrush;
private void Update()
{
@@ -98,12 +115,14 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
highlightBrush = new SolidColorBrush(CustomHighlightColor);
inActiveBrush = new SolidColorBrush(CustomInActiveColor);
borderBrush = new SolidColorBrush(CustomBorderColor);
numberBrush = new SolidColorBrush(CustomNumberColor);
}
else
{
highlightBrush = (SolidColorBrush)this.Resources["DefaultAccentBrush"];
inActiveBrush = (SolidColorBrush)this.Resources["SolidBackgroundBrush"];
borderBrush = (SolidColorBrush)this.Resources["DefaultBorderBrush"];
numberBrush = (SolidColorBrush)this.Resources["SolidZoneNumberBrush"];
}
highlightBrush.Opacity = HighlightOpacity / 100;
@@ -115,6 +134,10 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
Zone1.BorderBrush = borderBrush;
Zone2.BorderBrush = borderBrush;
Zone3.BorderBrush = borderBrush;
Zone1Number.Foreground = numberBrush;
Zone2Number.Foreground = numberBrush;
Zone3Number.Foreground = numberBrush;
}
}
}