Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

280 строки
18 KiB

  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:bpa="clr-namespace:BPA.UIControl">
  4. <ResourceDictionary.MergedDictionaries>
  5. <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/Resources/Default.xaml" />
  6. </ResourceDictionary.MergedDictionaries>
  7. <Style x:Key="RubyerToggleButton" TargetType="{x:Type ToggleButton}">
  8. <Setter Property="Background" Value="{DynamicResource Secondary}" />
  9. <Setter Property="BorderBrush" Value="{DynamicResource Border}" />
  10. <Setter Property="BorderThickness" Value="0" />
  11. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
  12. <Setter Property="Foreground" Value="{DynamicResource DefaultForeground}" />
  13. <Setter Property="HorizontalContentAlignment" Value="Center" />
  14. <Setter Property="VerticalContentAlignment" Value="Center" />
  15. <Setter Property="Padding" Value="10 5" />
  16. <Setter Property="SnapsToDevicePixels" Value="True" />
  17. <Setter Property="bpa:ControlHelper.CornerRadius" Value="{DynamicResource AllControlCornerRadius}" />
  18. <Setter Property="bpa:ControlHelper.MaskOpacity" Value="1" />
  19. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource Primary}" />
  20. <Setter Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource Mask}" />
  21. <Setter Property="bpa:ControlHelper.FocusedForegroundBrush" Value="{DynamicResource WhiteForeground}" />
  22. <Setter Property="bpa:ToggleButtonHelper.CheckedContent" Value="{x:Null}" />
  23. <Setter Property="Template">
  24. <Setter.Value>
  25. <ControlTemplate TargetType="{x:Type ToggleButton}">
  26. <Border x:Name="border"
  27. Background="{TemplateBinding Background}"
  28. BorderBrush="{TemplateBinding BorderBrush}"
  29. BorderThickness="{TemplateBinding BorderThickness}"
  30. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  31. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
  32. <Grid>
  33. <bpa:ControlMask x:Name="mask"
  34. Background="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  35. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  36. IsActive="{TemplateBinding IsChecked}"
  37. MaskOpacity="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
  38. <ContentPresenter x:Name="contentPresenter"
  39. Margin="{TemplateBinding Padding}"
  40. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  41. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  42. Focusable="False"
  43. RecognizesAccessKey="True"
  44. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  45. </Grid>
  46. </Border>
  47. <ControlTemplate.Triggers>
  48. <Trigger Property="Button.IsDefaulted" Value="true">
  49. <Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
  50. </Trigger>
  51. <Trigger Property="IsEnabled" Value="false">
  52. <Setter Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
  53. </Trigger>
  54. <Trigger Property="bpa:ButtonHelper.Shape" Value="Circle">
  55. <Setter Property="Width" Value="{Binding Path=ActualHeight, RelativeSource={RelativeSource Self}}" />
  56. <Setter Property="bpa:ControlHelper.CornerRadius" Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}, Converter={StaticResource HalfOfDoubleConverter}}" />
  57. <Setter Property="Padding" Value="5" />
  58. <Setter Property="VerticalAlignment" Value="Center" />
  59. </Trigger>
  60. <Trigger Property="bpa:ButtonHelper.Shape" Value="Round">
  61. <Setter Property="bpa:ControlHelper.CornerRadius" Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}, Converter={StaticResource HalfOfDoubleConverter}}" />
  62. </Trigger>
  63. <Trigger Property="IsChecked" Value="True">
  64. <Setter Property="Foreground" Value="{Binding Path=(bpa:ControlHelper.FocusedForegroundBrush), RelativeSource={RelativeSource Self}}" />
  65. <!--<Setter TargetName="border" Property="Background" Value="{Binding Path=(rubyer:ControlHelper.FocusedBrush), RelativeSource={RelativeSource AncestorType=ToggleButton}}" />-->
  66. </Trigger>
  67. <Trigger Property="IsChecked" Value="{x:Null}">
  68. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource Mask}" />
  69. <Setter Property="BorderBrush" Value="{DynamicResource Error}" />
  70. <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
  71. </Trigger>
  72. </ControlTemplate.Triggers>
  73. </ControlTemplate>
  74. </Setter.Value>
  75. </Setter>
  76. </Style>
  77. <!-- 亮色 -->
  78. <Style x:Key="LightToggleButton"
  79. BasedOn="{StaticResource RubyerToggleButton}"
  80. TargetType="{x:Type ToggleButton}">
  81. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource Light}" />
  82. <Setter Property="bpa:ControlHelper.FocusedForegroundBrush" Value="{DynamicResource BlackForeground}" />
  83. </Style>
  84. <!-- 暗色 -->
  85. <Style x:Key="DarkToggleButton"
  86. BasedOn="{StaticResource RubyerToggleButton}"
  87. TargetType="{x:Type ToggleButton}">
  88. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource Dark}" />
  89. <Setter Property="bpa:ControlHelper.FocusedForegroundBrush" Value="{DynamicResource WhiteForeground}" />
  90. </Style>
  91. <!-- 强调色 -->
  92. <Style x:Key="AccentToggleButton"
  93. BasedOn="{StaticResource RubyerToggleButton}"
  94. TargetType="{x:Type ToggleButton}">
  95. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource Accent}" />
  96. <Setter Property="bpa:ControlHelper.FocusedForegroundBrush" Value="{DynamicResource WhiteForeground}" />
  97. </Style>
  98. <!-- 切换开关默认 -->
  99. <Style x:Key="SwitchToggleButton" TargetType="{x:Type ToggleButton}">
  100. <Setter Property="Background" Value="{DynamicResource Border}" />
  101. <Setter Property="BorderBrush" Value="Transparent" />
  102. <Setter Property="BorderThickness" Value="0" />
  103. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
  104. <Setter Property="Foreground" Value="{DynamicResource DefaultForeground}" />
  105. <Setter Property="HorizontalContentAlignment" Value="Center" />
  106. <Setter Property="SnapsToDevicePixels" Value="True" />
  107. <Setter Property="VerticalContentAlignment" Value="Center" />
  108. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource Primary}" />
  109. <Setter Property="bpa:ToggleButtonHelper.CheckedContent" Value="{x:Null}" />
  110. <Setter Property="Template">
  111. <Setter.Value>
  112. <ControlTemplate TargetType="{x:Type ToggleButton}">
  113. <Grid>
  114. <Grid.ColumnDefinitions>
  115. <ColumnDefinition Width="Auto" />
  116. <ColumnDefinition Width="Auto" />
  117. </Grid.ColumnDefinitions>
  118. <Grid x:Name="backgroundRoot"
  119. Grid.Column="1"
  120. Width="26"
  121. Height="15"
  122. Margin="2 1">
  123. <Border x:Name="defaultBorder"
  124. Background="{TemplateBinding Background}"
  125. BorderBrush="{TemplateBinding BorderBrush}"
  126. BorderThickness="{TemplateBinding BorderThickness}"
  127. CornerRadius="{Binding ActualHeight, Converter={StaticResource HalfOfDoubleConverter}, RelativeSource={RelativeSource Mode=Self}}"
  128. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  129. <Border x:Name="checkedBorder"
  130. Background="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  131. BorderBrush="{TemplateBinding BorderBrush}"
  132. BorderThickness="{TemplateBinding BorderThickness}"
  133. CornerRadius="{Binding ActualHeight, Converter={StaticResource HalfOfDoubleConverter}, RelativeSource={RelativeSource Mode=Self}}"
  134. Opacity="0"
  135. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  136. <Canvas>
  137. <Ellipse x:Name="littleBall"
  138. Canvas.Right="12"
  139. Width="15"
  140. Height="{Binding ActualWidth, RelativeSource={RelativeSource Mode=Self}}"
  141. Effect="{DynamicResource AllDirectionEffect}"
  142. Fill="{DynamicResource WhiteForeground}" />
  143. </Canvas>
  144. </Grid>
  145. <Grid Grid.Column="0" Margin="0 0 5 0">
  146. <ContentPresenter x:Name="contentPresenter"
  147. Margin="{TemplateBinding Padding}"
  148. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  149. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  150. Focusable="False"
  151. RecognizesAccessKey="True"
  152. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  153. </Grid>
  154. </Grid>
  155. <ControlTemplate.Triggers>
  156. <Trigger SourceName="backgroundRoot" Property="IsMouseOver" Value="True">
  157. <Trigger.EnterActions>
  158. <BeginStoryboard>
  159. <Storyboard>
  160. <DoubleAnimation Storyboard.TargetName="littleBall"
  161. Storyboard.TargetProperty="Effect.BlurRadius"
  162. To="10"
  163. Duration="0:0:0.2" />
  164. </Storyboard>
  165. </BeginStoryboard>
  166. </Trigger.EnterActions>
  167. <Trigger.ExitActions>
  168. <BeginStoryboard>
  169. <Storyboard>
  170. <DoubleAnimation Storyboard.TargetName="littleBall"
  171. Storyboard.TargetProperty="Effect.BlurRadius"
  172. Duration="0:0:0.2" />
  173. </Storyboard>
  174. </BeginStoryboard>
  175. </Trigger.ExitActions>
  176. </Trigger>
  177. <Trigger Property="IsPressed" Value="True">
  178. <Trigger.EnterActions>
  179. <BeginStoryboard>
  180. <Storyboard>
  181. <DoubleAnimation Storyboard.TargetName="littleBall"
  182. Storyboard.TargetProperty="Effect.BlurRadius"
  183. To="2"
  184. Duration="0:0:0.15">
  185. <DoubleAnimation.EasingFunction>
  186. <CubicEase EasingMode="EaseOut" />
  187. </DoubleAnimation.EasingFunction>
  188. </DoubleAnimation>
  189. </Storyboard>
  190. </BeginStoryboard>
  191. </Trigger.EnterActions>
  192. <Trigger.ExitActions>
  193. <BeginStoryboard>
  194. <Storyboard>
  195. <DoubleAnimation Storyboard.TargetName="littleBall"
  196. Storyboard.TargetProperty="Effect.BlurRadius"
  197. Duration="0:0:0.15">
  198. <DoubleAnimation.EasingFunction>
  199. <CubicEase EasingMode="EaseIn" />
  200. </DoubleAnimation.EasingFunction>
  201. </DoubleAnimation>
  202. </Storyboard>
  203. </BeginStoryboard>
  204. </Trigger.ExitActions>
  205. </Trigger>
  206. <Trigger Property="IsEnabled" Value="False">
  207. <Setter Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
  208. </Trigger>
  209. <Trigger Property="IsChecked" Value="True">
  210. <Trigger.EnterActions>
  211. <BeginStoryboard>
  212. <Storyboard>
  213. <DoubleAnimation Storyboard.TargetName="checkedBorder"
  214. Storyboard.TargetProperty="Opacity"
  215. To="1"
  216. Duration="0:0:0.25" />
  217. <DoubleAnimation Storyboard.TargetName="littleBall"
  218. Storyboard.TargetProperty="(Canvas.Right)"
  219. To="-1"
  220. Duration="0:0:0.25">
  221. <DoubleAnimation.EasingFunction>
  222. <CubicEase EasingMode="EaseOut" />
  223. </DoubleAnimation.EasingFunction>
  224. </DoubleAnimation>
  225. </Storyboard>
  226. </BeginStoryboard>
  227. </Trigger.EnterActions>
  228. <Trigger.ExitActions>
  229. <BeginStoryboard>
  230. <Storyboard>
  231. <DoubleAnimation Storyboard.TargetName="checkedBorder"
  232. Storyboard.TargetProperty="Opacity"
  233. Duration="0:0:0.25" />
  234. <DoubleAnimation Storyboard.TargetName="littleBall"
  235. Storyboard.TargetProperty="(Canvas.Right)"
  236. Duration="0:0:0.25">
  237. <DoubleAnimation.EasingFunction>
  238. <CubicEase EasingMode="EaseOut" />
  239. </DoubleAnimation.EasingFunction>
  240. </DoubleAnimation>
  241. </Storyboard>
  242. </BeginStoryboard>
  243. </Trigger.ExitActions>
  244. </Trigger>
  245. </ControlTemplate.Triggers>
  246. </ControlTemplate>
  247. </Setter.Value>
  248. </Setter>
  249. </Style>
  250. <!-- 切换开关亮色 -->
  251. <Style x:Key="SwitchLightToggleButton"
  252. BasedOn="{StaticResource SwitchToggleButton}"
  253. TargetType="{x:Type ToggleButton}">
  254. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource Light}" />
  255. </Style>
  256. <!-- 切换开关暗色 -->
  257. <Style x:Key="SwitchDarkToggleButton"
  258. BasedOn="{StaticResource SwitchToggleButton}"
  259. TargetType="{x:Type ToggleButton}">
  260. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource Dark}" />
  261. </Style>
  262. <!-- 切换开关强调色 -->
  263. <Style x:Key="SwitchAccentToggleButton"
  264. BasedOn="{StaticResource SwitchToggleButton}"
  265. TargetType="{x:Type ToggleButton}">
  266. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource Accent}" />
  267. </Style>
  268. </ResourceDictionary>