Skip to content

Commit

Permalink
Merge branch 'Development'
Browse files Browse the repository at this point in the history
  • Loading branch information
syminomega committed Jun 25, 2022
2 parents bd6db67 + 77c4add commit 563666a
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 4 deletions.
Binary file modified Images/StylesDemo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SyminUI 是 WPF 的 UI 组件库,并使用称为 **C#UI** 的 MVU 设计模式

[![dotnet package](https://github.com/syminomega/SyminUI/actions/workflows/dotnet-desktop.yml/badge.svg)](https://github.com/syminomega/SyminUI/actions/workflows/dotnet-desktop.yml)

## Preview 预览 (2022-06-23)
## Preview 预览 (2022-06-25)
Currently is in early preview stage. **Pull requests are not available at this moment.**\
目前处于早期预览阶段,**Pull Request 暂未全面开放**

Expand Down
5 changes: 3 additions & 2 deletions SyminUI/Themes/Styles/MenuStyle.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:svd="clr-namespace:SyminUI.Controls.Decorations">
<!--PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}"-->
<!--菜单栏样式-->
<Style TargetType="{x:Type Menu}">
<Setter Property="Background" Value="Transparent"/>
Expand Down Expand Up @@ -185,7 +186,7 @@
<Popup x:Name="PART_Popup" AllowsTransparency="true" Focusable="false"
IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Bottom"
PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}"
PopupAnimation="Fade"
PlacementTarget="{Binding ElementName=templateRoot}">
<svd:LightedSurface Margin="8" Padding="0" BorderThickness="1"
BorderBrush="{StaticResource Border.Main.Shaded}">
Expand Down Expand Up @@ -366,7 +367,7 @@
Focusable="false" HorizontalOffset="-2"
IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Right" VerticalOffset="-3"
PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}">
PopupAnimation="Fade">
<svd:LightedSurface Margin="8" Padding="0" BorderThickness="1"
BorderBrush="{StaticResource Border.Main.Shaded}">
<Border x:Name="SubMenuBorder" Margin="0,4">
Expand Down
2 changes: 1 addition & 1 deletion SyminUI/Themes/Styles/SliderStyle.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<Trigger Property="IsDragging" Value="true">
<Setter Property="Effect" TargetName="grip">
<Setter.Value>
<DropShadowEffect BlurRadius="12" Opacity="0.6" ShadowDepth="3"
<DropShadowEffect BlurRadius="4" Opacity="0.6" ShadowDepth="3"
Color="{StaticResource Shader.ShadowColor}"/>
</Setter.Value>
</Setter>
Expand Down
174 changes: 174 additions & 0 deletions SyminUI/Themes/Styles/ToggleButtonStyle.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:svd="clr-namespace:SyminUI.Controls.Decorations">
<!--TODO:可调整光影颜色-->
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
<Setter Property="Background" Value="{StaticResource Background.Main}"/>
<Setter Property="BorderBrush" Value="{StaticResource Background.Main}"/>
<Setter Property="Foreground" Value="{StaticResource Text.Main}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="12,4"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<svd:EmbossBorder x:Name="border" Intensity="0.6"
Background="{TemplateBinding BorderBrush}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<svd:SlotBorder x:Name="slot" Intensity="0" ShaderEnabled="False"
Background="{TemplateBinding Background}">
<ContentPresenter x:Name="contentPresenter" Focusable="False"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Margin="{TemplateBinding Padding}" RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</svd:SlotBorder>
</svd:EmbossBorder>
<ControlTemplate.Triggers>
<Trigger Property="Button.IsDefaulted" Value="true">
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="ShaderEnabled" TargetName="slot" Value="True"/>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Intensity" TargetName="slot"
Value="0.9"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="border"
Value="{StaticResource Background.Button.Disabled}"/>
<Setter Property="TextElement.Foreground" TargetName="contentPresenter"
Value="{StaticResource Text.Main.Disabled}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="True"/>
<Condition Property="IsPressed" Value="False"/>
</MultiTrigger.Conditions>
<Setter Property="Intensity" TargetName="slot" Value="0.6"/>
<Setter Property="ShaderEnabled" TargetName="slot" Value="True"/>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="SwitchButton" TargetType="{x:Type ToggleButton}">
<Style.Resources>
<Storyboard x:Key="ToggleSwitchOn">
<ThicknessAnimationUsingKeyFrames Duration="0:0:0.2"
Storyboard.TargetProperty="Margin"
Storyboard.TargetName="circleBox">
<LinearThicknessKeyFrame KeyTime="0" Value="0,0,19,0"/>
<SplineThicknessKeyFrame KeyTime="0:0:0.2" Value="0,0,1,0"
KeySpline="0.8,1 0.8,1"/>
</ThicknessAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Duration="0:0:0.2"
Storyboard.TargetProperty="Opacity"
Storyboard.TargetName="borderOff">
<LinearDoubleKeyFrame KeyTime="0" Value="1"/>
<SplineDoubleKeyFrame KeyTime="0:0:0.2" Value="0"
KeySpline="0.8,1 0.8,1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Duration="0:0:0.2"
Storyboard.TargetProperty="Opacity"
Storyboard.TargetName="borderOn">
<LinearDoubleKeyFrame KeyTime="0" Value="0"/>
<SplineDoubleKeyFrame KeyTime="0:0:0.2" Value="1"
KeySpline="0.8,1 0.8,1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="ToggleSwitchOff">
<ThicknessAnimationUsingKeyFrames Duration="0:0:0.2"
Storyboard.TargetProperty="Margin"
Storyboard.TargetName="circleBox">
<LinearThicknessKeyFrame KeyTime="0" Value="19,0,0,0"/>
<SplineThicknessKeyFrame KeyTime="0:0:0.2" Value="1,0,0,0"
KeySpline="0.8,1 0.8,1"/>
</ThicknessAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Duration="0:0:0.2"
Storyboard.TargetProperty="Opacity"
Storyboard.TargetName="borderOff">
<LinearDoubleKeyFrame KeyTime="0" Value="0"/>
<SplineDoubleKeyFrame KeyTime="0:0:0.2" Value="1"
KeySpline="0.8,1 0.8,1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Duration="0:0:0.2"
Storyboard.TargetProperty="Opacity"
Storyboard.TargetName="borderOn">
<LinearDoubleKeyFrame KeyTime="0" Value="1"/>
<SplineDoubleKeyFrame KeyTime="0:0:0.2" Value="0"
KeySpline="0.8,1 0.8,1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Style.Resources>
<Setter Property="Background" Value="{StaticResource Background.Toggle}"/>
<Setter Property="Foreground" Value="{StaticResource Gradient.Primary}"/>
<Setter Property="BorderBrush" Value="{StaticResource Border.MainBrush}"/>
<Setter Property="Margin" Value="4"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid Height="24" Width="42">
<Border x:Name="borderOn" CornerRadius="12"
Opacity="0"
Background="{TemplateBinding Foreground}"/>

<Border x:Name="borderOff" CornerRadius="12"
Opacity="1" BorderThickness="1"
BorderBrush="{TemplateBinding BorderBrush}"
Background="{TemplateBinding Background}">

</Border>
<Grid x:Name="circleBox" Width="20" Height="20" Margin="1,0,0,0"
HorizontalAlignment="Left">
<Border x:Name="circle"
Background="{StaticResource Background.Button}"
CornerRadius="8" Margin="2">
<Border.Effect>
<DropShadowEffect BlurRadius="6" Opacity="0.6" ShadowDepth="2"
Color="{StaticResource Shader.ShadowColor}"/>
</Border.Effect>
</Border>
</Grid>

</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Button.IsDefaulted" Value="true">
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Margin" TargetName="circle" Value="1"/>
<Setter Property="CornerRadius" TargetName="circle" Value="9"/>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Width" TargetName="circleBox" Value="24"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="circle"
Value="{StaticResource Background.Button.Disabled}"/>
<Setter Property="Background" TargetName="borderOn"
Value="{StaticResource Primary.Disabled}"/>
<Setter Property="Background" TargetName="borderOff"
Value="{StaticResource Background.Toggle.Disabled}"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="HorizontalAlignment" TargetName="circleBox"
Value="Right"/>
<Setter Property="Margin" TargetName="circleBox"
Value="0,0,11,0"/>
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource ToggleSwitchOn}"/>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource ToggleSwitchOff}"/>
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
4 changes: 4 additions & 0 deletions SyminUI/Themes/SyminLight.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@
<SolidColorBrush x:Key="Background.FocusedMask" Color="#7F9FA2AC"/>
<SolidColorBrush x:Key="Background.LightMask" Color="#7FFFFFFF"/>
<SolidColorBrush x:Key="Background.Section" Color="#DFE1E7"/>

<SolidColorBrush x:Key="Background.Button" Color="#F1F2F6"/>
<SolidColorBrush x:Key="Background.Button.Disabled" Color="#E8E9EC"/>

<SolidColorBrush x:Key="Background.Pure" Color="White"/>
<SolidColorBrush x:Key="Background.TextField" Color="#FBFBFB"/>
<SolidColorBrush x:Key="Background.Label" Color="#F2F2F2"/>
<SolidColorBrush x:Key="Background.Toggle" Color="#C3C6D6"/>
<SolidColorBrush x:Key="Background.Toggle.Disabled" Color="#E5E6EC"/>
<!--实色填充的系统控件:滚动条、GridSplitter等-->
<SolidColorBrush x:Key="Background.Handler" Color="#87898A"/>
<SolidColorBrush x:Key="Background.Handler.Focused" Color="#5E5E5E"/>
Expand Down
2 changes: 2 additions & 0 deletions SyminUI/Themes/SyminStyle.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
<ResourceDictionary Source="Styles/LabelStyle.xaml"/>
<ResourceDictionary Source="Styles/ToolTipStyle.xaml"/>
<ResourceDictionary Source="Styles/ButtonsStyle.xaml"/>
<ResourceDictionary Source="Styles/ToggleButtonStyle.xaml"/>
<ResourceDictionary Source="Styles/TextBoxStyle.xaml"/>
<ResourceDictionary Source="Styles/ProgressBarStyle.xaml"/>
<ResourceDictionary Source="Styles/SliderStyle.xaml"/>
<ResourceDictionary Source="Styles/CheckBoxStyle.xaml"/>
<ResourceDictionary Source="Styles/MenuStyle.xaml"/>
<ResourceDictionary Source="Styles/GroupBoxStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>

</ResourceDictionary>
4 changes: 4 additions & 0 deletions SyminViewTest/StyleTestWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@
<svd:LightedSurface Height="80" Margin="4"
Background="{StaticResource Background.Main}"
CornerRadius="16" Content="Lighed Surface" FontSize="24"/>
<StackPanel Orientation="Horizontal">
<ToggleButton Content="Toggle"/>
<ToggleButton Style="{StaticResource SwitchButton}"/>
</StackPanel>
</StackPanel>
</GroupBox>

Expand Down

0 comments on commit 563666a

Please sign in to comment.