mirror of
https://github.com/Stone-Red-Code/InvLock.git
synced 2026-09-04 00:56:10 +02:00
Fix ToggleSwitch style
This commit is contained in:
@@ -9,6 +9,136 @@
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ui:ThemesDictionary Theme="Dark" />
|
||||
<ui:ControlsDictionary />
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=System.Runtime">
|
||||
|
||||
<system:Double x:Key="ToggleButtonWidth">40</system:Double>
|
||||
<system:Double x:Key="ToggleButtonHeight">20</system:Double>
|
||||
<Thickness x:Key="ToggleSwitchBorderThemeThickness">1</Thickness>
|
||||
<Thickness x:Key="ToggleSwitchContentLeftMargin">0,0,8,0</Thickness>
|
||||
|
||||
<Style x:Key="ToggleSwitchContentLeftStyle" TargetType="{x:Type ui:ToggleSwitch}">
|
||||
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ToggleSwitchFillOn}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource ToggleSwitchContentForeground}" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="{StaticResource ToggleSwitchBorderThemeThickness}" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ui:ToggleSwitch}">
|
||||
<Grid Margin="{TemplateBinding Padding}" Background="Transparent">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ContentPresenter
|
||||
x:Name="ContentPresenter"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource ToggleSwitchContentLeftMargin}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
RecognizesAccessKey="True"
|
||||
TextElement.Foreground="{TemplateBinding Foreground}" />
|
||||
|
||||
<Grid
|
||||
Grid.Column="1"
|
||||
Width="{StaticResource ToggleButtonWidth}"
|
||||
Height="{StaticResource ToggleButtonHeight}">
|
||||
<Rectangle
|
||||
x:Name="ToggleRectangle"
|
||||
Width="{StaticResource ToggleButtonWidth}"
|
||||
Height="{StaticResource ToggleButtonHeight}"
|
||||
Fill="{DynamicResource ToggleSwitchFillOff}"
|
||||
RadiusX="10" RadiusY="10"
|
||||
Stroke="{DynamicResource ToggleSwitchStrokeOff}"
|
||||
StrokeThickness="1" />
|
||||
<Rectangle
|
||||
x:Name="ActiveToggleRectangle"
|
||||
Width="{StaticResource ToggleButtonWidth}"
|
||||
Height="{StaticResource ToggleButtonHeight}"
|
||||
Fill="{TemplateBinding Background}"
|
||||
Opacity="0.0"
|
||||
RadiusX="10" RadiusY="10" />
|
||||
<Rectangle
|
||||
x:Name="ToggleEllipse"
|
||||
Width="12" Height="12"
|
||||
Fill="{DynamicResource ToggleSwitchKnobFillOff}"
|
||||
RadiusX="7" RadiusY="7">
|
||||
<Rectangle.RenderTransform>
|
||||
<TranslateTransform X="-9" />
|
||||
</Rectangle.RenderTransform>
|
||||
</Rectangle>
|
||||
<Rectangle
|
||||
x:Name="ActiveToggleEllipse"
|
||||
Width="12" Height="12"
|
||||
Fill="{DynamicResource ToggleSwitchKnobFillOn}"
|
||||
Opacity="0.0"
|
||||
RadiusX="7" RadiusY="7">
|
||||
<Rectangle.RenderTransform>
|
||||
<TranslateTransform X="-9" />
|
||||
</Rectangle.RenderTransform>
|
||||
</Rectangle>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Trigger.EnterActions>
|
||||
<BeginStoryboard Name="SlideRight">
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetName="ToggleRectangle" Storyboard.TargetProperty="Opacity" To="0.0" Duration="0:0:0.16" />
|
||||
<DoubleAnimation Storyboard.TargetName="ActiveToggleRectangle" Storyboard.TargetProperty="Opacity" To="1.0" Duration="0:0:0.16" />
|
||||
<DoubleAnimation Storyboard.TargetName="ToggleEllipse" Storyboard.TargetProperty="Opacity" To="0.0" Duration="0:0:0.16" />
|
||||
<DoubleAnimation Storyboard.TargetName="ActiveToggleEllipse" Storyboard.TargetProperty="Opacity" To="1.0" Duration="0:0:0.16" />
|
||||
<DoubleAnimation Storyboard.TargetName="ActiveToggleEllipse" Storyboard.TargetProperty="(Rectangle.RenderTransform).(TranslateTransform.X)" To="9" Duration="0:0:0.167" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</Trigger.EnterActions>
|
||||
<Trigger.ExitActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetName="ToggleRectangle" Storyboard.TargetProperty="Opacity" To="1.0" Duration="0:0:0.16" />
|
||||
<DoubleAnimation Storyboard.TargetName="ActiveToggleRectangle" Storyboard.TargetProperty="Opacity" To="0.0" Duration="0:0:0.16" />
|
||||
<DoubleAnimation Storyboard.TargetName="ToggleEllipse" Storyboard.TargetProperty="Opacity" To="1.0" Duration="0:0:0.16" />
|
||||
<DoubleAnimation Storyboard.TargetName="ActiveToggleEllipse" Storyboard.TargetProperty="Opacity" To="0.0" Duration="0:0:0.16" />
|
||||
<DoubleAnimation Storyboard.TargetName="ActiveToggleEllipse" Storyboard.TargetProperty="(Rectangle.RenderTransform).(TranslateTransform.X)" To="-9" Duration="0:0:0.167" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</Trigger.ExitActions>
|
||||
</Trigger>
|
||||
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="Content" Value="{x:Null}" />
|
||||
<Condition Property="IsChecked" Value="True" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter TargetName="ContentPresenter" Property="Content" Value="{Binding OnContent, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</MultiTrigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="Content" Value="{x:Null}" />
|
||||
<Condition Property="IsChecked" Value="False" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter TargetName="ContentPresenter" Property="Content" Value="{Binding OffContent, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</MultiTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
||||
@@ -91,28 +91,28 @@
|
||||
<ui:TextBlock Grid.Row="1" Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}" FontSize="12" Text="Start InvLock when you sign in to Windows" />
|
||||
</Grid>
|
||||
</ui:CardControl.Header>
|
||||
<ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding IsAutoStartEnabled}" OffContent="Off" OnContent="On" />
|
||||
<ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding IsAutoStartEnabled}" Style="{StaticResource ToggleSwitchContentLeftStyle}" OffContent="Off" OnContent="On" />
|
||||
</ui:CardControl>
|
||||
|
||||
<ui:CardControl Margin="0,0,0,12" Icon="{ui:SymbolIcon Symbol=Window24}" Height="75">
|
||||
<ui:CardControl.Header>
|
||||
<ui:TextBlock Grid.Row="0" FontTypography="Body" Text="Show desktop while locked" />
|
||||
</ui:CardControl.Header>
|
||||
<ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding Settings.HideWindows}" OffContent="Off" OnContent="On" />
|
||||
<ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding Settings.HideWindows}" Style="{StaticResource ToggleSwitchContentLeftStyle}" OffContent="Off" OnContent="On" />
|
||||
</ui:CardControl>
|
||||
|
||||
<ui:CardControl Margin="0,0,0,12" Icon="{ui:SymbolIcon Symbol=Blur24}" Height="75">
|
||||
<ui:CardControl.Header>
|
||||
<ui:TextBlock Grid.Row="0" FontTypography="Body" Text="Blur screen while locked" />
|
||||
</ui:CardControl.Header>
|
||||
<ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding Settings.BlurScreen}" OffContent="Off" OnContent="On" />
|
||||
<ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding Settings.BlurScreen}" Style="{StaticResource ToggleSwitchContentLeftStyle}" OffContent="Off" OnContent="On" />
|
||||
</ui:CardControl>
|
||||
|
||||
<ui:CardControl Margin="0,0,0,12" Icon="{ui:SymbolIcon Symbol=WindowShield24}" Height="75">
|
||||
<ui:CardControl.Header>
|
||||
<ui:TextBlock Grid.Row="0" FontTypography="Body" Text="Use windows lock screen to unlock" />
|
||||
</ui:CardControl.Header>
|
||||
<ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding Settings.UseWindowsLockScreen}" OffContent="Off" OnContent="On" />
|
||||
<ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding Settings.UseWindowsLockScreen}" Style="{StaticResource ToggleSwitchContentLeftStyle}" OffContent="Off" OnContent="On" />
|
||||
</ui:CardControl>
|
||||
|
||||
<ui:CardControl Margin="0,0,0,12" Icon="{ui:SymbolIcon Symbol=LockClosed24}" Height="75">
|
||||
|
||||
Reference in New Issue
Block a user