Просмотр исходного кода

[新增]CheckBox样式,ProgressBar样式等

Jiangsheng 2 недель назад
Родитель
Сommit
626a19ca4f

+ 10 - 0
SKMC.UI.DesignApp/Views/BasicControlsView.xaml

@@ -121,6 +121,16 @@
                              Height="40"
                              Margin="5"
                              Width="180"/>
+                    <CheckBox Style="{StaticResource Checkbox.Base}"
+                              Content="Checkbox.Base"/>
+                    <CheckBox Style="{StaticResource Checkbox.DefaultMargin}"
+                              Content="Checkbox.Default"/>
+                    <Label Content="ProgressBar.Base" Foreground="{StaticResource Brush.Text}"/>
+                    <ProgressBar Style="{StaticResource ProgressBar.Base}"
+                                 Value="50"/>
+                    <Expander Style="{StaticResource Expander.Base}" 
+                              Header="Expander.Base" 
+                              Foreground="{StaticResource Brush.Text}"/>
                 </StackPanel>
                 <StackPanel>
                     <DataGrid Style="{StaticResource DataGrid.Primary}"

+ 4 - 0
SKMC.UI/FrameWork.xaml

@@ -23,6 +23,10 @@
         <ResourceDictionary Source="pack://application:,,,/SKMC.UI;component/Styles/ListView.xaml" />
         <ResourceDictionary Source="pack://application:,,,/SKMC.UI;component/Styles/ComboBox.xaml" />
         <ResourceDictionary Source="pack://application:,,,/SKMC.UI;component/Styles/PasswordBox.xaml" />
+        <ResourceDictionary Source="pack://application:,,,/SKMC.UI;component/Styles/CheckBox.xaml" />
+        <ResourceDictionary Source="pack://application:,,,/SKMC.UI;component/Styles/ProgressBar.xaml" />
+        <ResourceDictionary Source="pack://application:,,,/SKMC.UI;component/Styles/Control.xaml" />
+        <ResourceDictionary Source="pack://application:,,,/SKMC.UI;component/Styles/Expander.xaml" />
         <!--  Styles  -->
     </ResourceDictionary.MergedDictionaries>
 </ResourceDictionary>

+ 16 - 0
SKMC.UI/SKMC.UI.csproj

@@ -93,10 +93,26 @@
     <Resource Include="Assets\Icon_2.png" />
   </ItemGroup>
   <ItemGroup>
+    <Page Include="Styles\CheckBox.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Styles\Control.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Styles\Expander.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Styles\PasswordBox.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Styles\ProgressBar.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="UserControls\NumpadControl.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>

+ 147 - 0
SKMC.UI/Styles/CheckBox.xaml

@@ -0,0 +1,147 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+    <Style
+		TargetType="{x:Type CheckBox}"
+		x:Key="Checkbox.Base">
+        <Setter
+			Property="BorderBrush"
+			Value="{DynamicResource Brush.SelectedBorder}" />
+        <Setter
+			Property="FontSize"
+			Value="{DynamicResource FontSize.Title}" />
+        <Setter
+			Property="Foreground"
+			Value="{DynamicResource Brush.Text}" />
+        <Setter
+			Property="Height"
+			Value="32" />
+        <Setter
+			Property="UIElement.SnapsToDevicePixels"
+			Value="True" />
+        <Setter
+			Property="Template">
+            <Setter.Value>
+                <ControlTemplate
+					TargetType="{x:Type CheckBox}">
+                    <BulletDecorator
+						Background="#00FFFFFF">
+                        <BulletDecorator.Bullet>
+                            <Border
+								Name="Border"
+								Width="25"
+								Height="25"
+								HorizontalAlignment="Center"
+								VerticalAlignment="Center"
+								Background="#00FFFFFF"
+								BorderBrush="{TemplateBinding BorderBrush}"
+								BorderThickness="2"
+								CornerRadius="3">
+                                <Polyline
+									Name="Polyline"
+									Width="19"
+									Height="14"
+									HorizontalAlignment="Center"
+									VerticalAlignment="Center"
+									Points="0,8 6,13 19,0"
+									Stroke="{TemplateBinding BorderBrush}"
+									StrokeThickness="2"
+									Visibility="Collapsed" />
+                            </Border>
+                        </BulletDecorator.Bullet>
+                        <Label
+							Height="32"
+							Margin="16,0,0,0"
+							VerticalAlignment="Center"
+							Content="{TemplateBinding Content}"
+							FontSize="{TemplateBinding FontSize}"
+							Foreground="{TemplateBinding Foreground}"/>
+                    </BulletDecorator>
+                    <ControlTemplate.Triggers>
+                        <Trigger
+							Property="ToggleButton.IsChecked"
+							Value="True">
+                            <Setter
+								TargetName="Border"
+								Property="Background"
+								Value="{DynamicResource Brush.SelectionSelected}" />
+                            <Setter
+								TargetName="Border"
+								Property="BorderBrush"
+								Value="{x:Null}" />
+                            <Setter
+								TargetName="Border"
+								Property="BorderThickness"
+								Value="0" />
+                            <Setter
+								TargetName="Polyline"
+								Property="Visibility"
+								Value="Visible" />
+                        </Trigger>
+                        <Trigger
+							Property="ToggleButton.IsChecked"
+							Value="{x:Null}">
+                            <Setter
+								TargetName="Border"
+								Property="Background"
+								Value="{DynamicResource Brush.IconInactive}" />
+                            <Setter
+								TargetName="Polyline"
+								Property="Visibility"
+								Value="Hidden" />
+                        </Trigger>
+                        <MultiTrigger>
+                            <MultiTrigger.Conditions>
+                                <Condition
+									Property="IsEnabled"
+									Value="False" />
+                                <Condition
+									Property="ToggleButton.IsChecked"
+									Value="False" />
+                            </MultiTrigger.Conditions>
+                            <MultiTrigger.Setters>
+                                <Setter
+									Property="BorderBrush"
+									Value="{DynamicResource Brush.Overlay3Percent}" />
+                            </MultiTrigger.Setters>
+                        </MultiTrigger>
+                        <MultiTrigger>
+                            <MultiTrigger.Conditions>
+                                <Condition
+									Property="IsEnabled"
+									Value="False" />
+                                <Condition
+									Property="ToggleButton.IsChecked"
+									Value="True" />
+                            </MultiTrigger.Conditions>
+                            <MultiTrigger.Setters>
+                                <Setter
+									TargetName="Border"
+									Property="Background"
+									Value="{DynamicResource Brush.Overlay3Percent}" />
+                                <Setter
+									TargetName="Polyline"
+									Property="Stroke"
+									Value="{DynamicResource Brush.SecondaryFont}" />
+                            </MultiTrigger.Setters>
+                        </MultiTrigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+        <Setter
+			Property="FrameworkElement.ToolTip"
+			Value="{Binding Content, RelativeSource={RelativeSource Self}}" />
+    </Style>
+    <Style
+		BasedOn="{StaticResource Checkbox.Base}"
+		TargetType="{x:Type CheckBox}"
+		x:Key="Checkbox.DefaultMargin">
+        <Setter
+			Property="Margin"
+			Value="5" />
+    </Style>
+    <Style
+		BasedOn="{StaticResource Checkbox.Base}"
+		TargetType="{x:Type CheckBox}"
+		x:Key="{x:Type CheckBox}" />
+</ResourceDictionary>

+ 61 - 0
SKMC.UI/Styles/Control.xaml

@@ -0,0 +1,61 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+    <Style
+		TargetType="{x:Type Control}"
+		x:Key="Control.TextBase">
+        <Setter
+			Property="FontFamily"
+			Value="{DynamicResource FontFamily.Global}" />
+        <Setter
+			Property="FontSize"
+			Value="{DynamicResource FontSize.Body}" />
+        <Setter
+			Property="Foreground"
+			Value="{DynamicResource Brush.Text}" />
+        <Setter
+			Property="Height"
+			Value="25" />
+        <Setter
+			Property="Template">
+            <Setter.Value>
+                <ControlTemplate
+					TargetType="{x:Type Control}">
+                    <ScrollViewer
+						Name="PART_ContentHost"
+						Margin="2"
+						Padding="{TemplateBinding Padding}"
+						HorizontalAlignment="Stretch"
+						VerticalAlignment="Stretch"
+						IsTabStop="False"
+						TextElement.Foreground="{TemplateBinding Foreground}"
+						Style="{x:Null}" />
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+        <Setter
+			Property="VerticalContentAlignment"
+			Value="Center" />
+    </Style>
+    <Style
+		TargetType="{x:Type Border}"
+		x:Key="Border.HorizontalSpacer">
+        <Setter
+			Property="Background"
+			Value="#00FFFFFF" />
+        <Setter
+			Property="BorderBrush"
+			Value="{DynamicResource Brush.Overlay12Percent}" />
+        <Setter
+			Property="BorderThickness"
+			Value="1" />
+        <Setter
+			Property="Border.CornerRadius"
+			Value="0" />
+        <Setter
+			Property="Margin"
+			Value="16" />
+        <Setter
+			Property="Width"
+			Value="1" />
+    </Style>
+</ResourceDictionary>

+ 257 - 0
SKMC.UI/Styles/Expander.xaml

@@ -0,0 +1,257 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+    <ControlTemplate
+		TargetType="{x:Type ToggleButton}"
+		x:Key="ExpanderToggleButton">
+        <Grid>
+            <Border
+				Name="CollapsedArrow"
+				Width="48"
+				Height="48"
+				Background="#00FFFFFF">
+                <Path
+					HorizontalAlignment="Center"
+					VerticalAlignment="Center"
+					Fill="{DynamicResource Brush.Text}"
+					Data="{DynamicResource Icon.CaretDown}" />
+            </Border>
+            <Border
+				Name="ExpandedArrow"
+				Width="48"
+				Height="48"
+				Background="#00FFFFFF"
+				Visibility="Collapsed">
+                <Path
+					Margin="0"
+					HorizontalAlignment="Center"
+					VerticalAlignment="Center"
+					Fill="{DynamicResource Brush.Text}"
+					Data="{DynamicResource Icon.CaretUp}" />
+            </Border>
+        </Grid>
+        <ControlTemplate.Triggers>
+            <Trigger
+				Property="ToggleButton.IsChecked"
+				Value="True">
+                <Setter
+					TargetName="CollapsedArrow"
+					Property="Visibility"
+					Value="Hidden" />
+                <Setter
+					TargetName="ExpandedArrow"
+					Property="Visibility"
+					Value="Visible" />
+            </Trigger>
+        </ControlTemplate.Triggers>
+    </ControlTemplate>
+    <ControlTemplate
+		TargetType="{x:Type ToggleButton}"
+		x:Key="ExpanderToggleButtonRecipeInfo">
+        <Grid
+			Margin="0,-25,0,0">
+            <Border
+				Name="CollapsedArrow"
+				Width="150"
+				Height="100"
+				Background="#00FFFFFF">
+                <Path
+					HorizontalAlignment="Center"
+					VerticalAlignment="Center"
+					Fill="{DynamicResource Brush.Text}"
+					Data="{DynamicResource Icon.CaretDown}" />
+            </Border>
+            <Border
+				Name="ExpandedArrow"
+				Width="150"
+				Height="100"
+				Background="#00FFFFFF"
+				Visibility="Collapsed">
+                <Path
+					HorizontalAlignment="Center"
+					VerticalAlignment="Center"
+					Fill="{DynamicResource Brush.Text}"
+					Data="{DynamicResource Icon.CaretUp}" />
+            </Border>
+        </Grid>
+        <ControlTemplate.Triggers>
+            <Trigger
+				Property="ToggleButton.IsChecked"
+				Value="True">
+                <Setter
+					TargetName="CollapsedArrow"
+					Property="Visibility"
+					Value="Hidden" />
+                <Setter
+					TargetName="ExpandedArrow"
+					Property="Visibility"
+					Value="Visible" />
+            </Trigger>
+        </ControlTemplate.Triggers>
+    </ControlTemplate>
+    <Style
+		TargetType="{x:Type Expander}"
+		x:Key="Expander.Base">
+        <Setter
+			Property="Template">
+            <Setter.Value>
+                <ControlTemplate
+					TargetType="{x:Type Expander}">
+                    <Grid>
+                        <Grid.RowDefinitions>
+                            <RowDefinition
+								Height="Auto" />
+                            <RowDefinition
+								Name="ContentRow"
+								Height="0" />
+                        </Grid.RowDefinitions>
+                        <Border
+							Name="Border"
+							Grid.Row="0"
+							BorderThickness="0"
+							Background="{DynamicResource Brush.Background}"
+							CornerRadius="3">
+                            <Grid>
+                                <Grid.RowDefinitions>
+                                    <RowDefinition
+										Height="Auto" />
+                                    <RowDefinition
+										Height="*" />
+                                </Grid.RowDefinitions>
+                                <Grid.ColumnDefinitions>
+                                    <ColumnDefinition
+										Width="*" />
+                                    <ColumnDefinition
+										Width="Auto" />
+                                </Grid.ColumnDefinitions>
+                                <ContentPresenter
+									Grid.RowSpan="2"
+									Grid.Column="0"
+									Margin="4"
+									ContentSource="Header"
+									RecognizesAccessKey="True" />
+                                <ToggleButton
+									Grid.Row="0"
+									Grid.Column="1"
+									Width="48"
+									Height="48"
+									Margin="0,16,16,0"
+									OverridesDefaultStyle="True"
+									Template="{StaticResource ExpanderToggleButton}"
+									IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" />
+                            </Grid>
+                        </Border>
+                        <Border
+							Name="Content"
+							Grid.Row="1"
+							BorderThickness="0"
+							Background="{DynamicResource Brush.Background}"
+							CornerRadius="3 0 0 3">
+                            <ContentPresenter
+								Margin="4" />
+                        </Border>
+                    </Grid>
+                    <ControlTemplate.Triggers>
+                        <Trigger
+							Property="Expander.IsExpanded"
+							Value="True">
+                            <Setter
+								TargetName="Border"
+								Property="Border.CornerRadius"
+								Value="3 0 0 3" />
+                            <Setter
+								TargetName="ContentRow"
+								Property="Height"
+								Value="Auto" />
+                        </Trigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+    <Style
+		BasedOn="{StaticResource Expander.Base}"
+		TargetType="{x:Type Expander}"
+		x:Key="{x:Type Expander}" />
+    <Style
+		TargetType="{x:Type Expander}"
+		x:Key="Style.ExpanderRecipeInfo">
+        <Setter
+			Property="Template">
+            <Setter.Value>
+                <ControlTemplate
+					TargetType="{x:Type Expander}">
+                    <Grid>
+                        <Grid.RowDefinitions>
+                            <RowDefinition
+								Height="Auto" />
+                            <RowDefinition
+								Name="ContentRow"
+								Height="0" />
+                        </Grid.RowDefinitions>
+                        <Border
+							Name="Border"
+							Grid.Row="0"
+							BorderThickness="1"
+							Background="{DynamicResource Brush.Overlay3Percent}"
+							CornerRadius="3">
+                            <Grid
+								Margin="0,10,0,10">
+                                <Grid.RowDefinitions>
+                                    <RowDefinition
+										Height="Auto" />
+                                    <RowDefinition
+										Height="*" />
+                                </Grid.RowDefinitions>
+                                <Grid.ColumnDefinitions>
+                                    <ColumnDefinition
+										Width="*" />
+                                    <ColumnDefinition
+										Width="100" />
+                                </Grid.ColumnDefinitions>
+                                <ContentPresenter
+									Grid.RowSpan="1"
+									Margin="0"
+									ContentSource="Header"
+									RecognizesAccessKey="True" />
+                                <ToggleButton
+									Grid.Row="0"
+									Grid.Column="1"
+									Width="200"
+									Height="40"
+									Margin="0,-10,0,0"
+									HorizontalAlignment="Center"
+									BorderBrush="#00FFFFFF"
+									OverridesDefaultStyle="True"
+									Template="{DynamicResource ExpanderToggleButtonRecipeInfo}"
+									IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" />
+                            </Grid>
+                        </Border>
+                        <Border
+							Name="Content"
+							Grid.Row="1"
+							Background="#00FFFFFF"
+							BorderThickness="0"
+							CornerRadius="3 0 0 3">
+                            <ContentPresenter
+								Margin="4" />
+                        </Border>
+                    </Grid>
+                    <ControlTemplate.Triggers>
+                        <Trigger
+							Property="Expander.IsExpanded"
+							Value="True">
+                            <Setter
+								TargetName="Border"
+								Property="Border.CornerRadius"
+								Value="0 3 3 0" />
+                            <Setter
+								TargetName="ContentRow"
+								Property="Height"
+								Value="Auto" />
+                        </Trigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+</ResourceDictionary>

+ 37 - 0
SKMC.UI/Styles/ProgressBar.xaml

@@ -0,0 +1,37 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+    <Style
+		TargetType="{x:Type ProgressBar}"
+		x:Key="ProgressBar.Base">
+        <Setter
+			Property="MinHeight"
+			Value="8" />
+        <Setter
+			Property="Template">
+            <Setter.Value>
+                <ControlTemplate
+					TargetType="{x:Type ProgressBar}">
+                    <Grid>
+                        <Border
+							Name="PART_Track"
+							Height="{TemplateBinding Height}"
+							MinHeight="{TemplateBinding MinHeight}"
+							Background="{DynamicResource Brush.Overlay7Percent}"
+							CornerRadius="3" />
+                        <Border
+							Name="PART_Indicator"
+							Height="{TemplateBinding Height}"
+							MinHeight="{TemplateBinding MinHeight}"
+							HorizontalAlignment="Left"
+							Background="{DynamicResource Brush.Signature}"
+							CornerRadius="3" />
+                    </Grid>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+    <Style
+		BasedOn="{StaticResource ProgressBar.Base}"
+		TargetType="{x:Type ProgressBar}"
+		x:Key="{x:Type ProgressBar}" />
+</ResourceDictionary>