You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

297 regels
16 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. <!-- 默认按钮 -->
  8. <Style x:Key="RubyerButtonBase" TargetType="{x:Type ButtonBase}">
  9. <Setter Property="Background" Value="{DynamicResource Primary}" />
  10. <Setter Property="Foreground" Value="{DynamicResource WhiteForeground}" />
  11. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
  12. <Setter Property="BorderThickness" Value="0" />
  13. <Setter Property="HorizontalContentAlignment" Value="Center" />
  14. <Setter Property="VerticalContentAlignment" Value="Center" />
  15. <Setter Property="Padding" Value="10 5" />
  16. <Setter Property="Cursor" Value="Hand" />
  17. <Setter Property="SnapsToDevicePixels" Value="True" />
  18. <Setter Property="bpa:ControlHelper.CornerRadius" Value="{DynamicResource AllControlCornerRadius}" />
  19. <Setter Property="bpa:ControlHelper.MaskOpacity" Value="0.6" />
  20. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource MaskDark}" />
  21. <Setter Property="bpa:ButtonHelper.ShowShadow" Value="False" />
  22. <Setter Property="bpa:ButtonHelper.Loading" Value="False" />
  23. <Setter Property="bpa:ButtonHelper.LoadingContent" Value="{x:Null}" />
  24. <Setter Property="Template">
  25. <Setter.Value>
  26. <ControlTemplate TargetType="{x:Type ButtonBase}">
  27. <Border x:Name="border"
  28. Background="{TemplateBinding Background}"
  29. BorderBrush="{TemplateBinding BorderBrush}"
  30. BorderThickness="{TemplateBinding BorderThickness}"
  31. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  32. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
  33. <Grid>
  34. <Border x:Name="effectBorder"
  35. Background="{TemplateBinding Background}"
  36. BorderBrush="{TemplateBinding BorderBrush}"
  37. BorderThickness="{TemplateBinding BorderThickness}"
  38. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  39. Effect="{DynamicResource RightBottomEffect}"
  40. Visibility="Collapsed" />
  41. <bpa:ControlMask Background="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  42. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  43. IsActive="{TemplateBinding IsPressed}"
  44. MaskOpacity="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
  45. <StackPanel Margin="{TemplateBinding Padding}"
  46. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  47. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  48. Orientation="Horizontal">
  49. <bpa:Loading x:Name="loading"
  50. Margin="0 0 5 0"
  51. Background="Transparent"
  52. Diameter="16"
  53. FocusedBrush="{TemplateBinding Foreground}"
  54. StrokeThickness="2"
  55. Visibility="Collapsed" />
  56. <ContentPresenter x:Name="contentPresenter"
  57. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  58. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  59. Focusable="False"
  60. RecognizesAccessKey="True"
  61. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  62. </StackPanel>
  63. </Grid>
  64. </Border>
  65. <ControlTemplate.Triggers>
  66. <Trigger Property="IsPressed" Value="True">
  67. <Trigger.EnterActions>
  68. <BeginStoryboard>
  69. <Storyboard>
  70. <DoubleAnimation Storyboard.TargetName="effectBorder"
  71. Storyboard.TargetProperty="Effect.ShadowDepth"
  72. To="0"
  73. Duration="0:0:0.15">
  74. <DoubleAnimation.EasingFunction>
  75. <CubicEase EasingMode="EaseOut" />
  76. </DoubleAnimation.EasingFunction>
  77. </DoubleAnimation>
  78. </Storyboard>
  79. </BeginStoryboard>
  80. </Trigger.EnterActions>
  81. <Trigger.ExitActions>
  82. <BeginStoryboard>
  83. <Storyboard>
  84. <DoubleAnimation Storyboard.TargetName="effectBorder"
  85. Storyboard.TargetProperty="Effect.ShadowDepth"
  86. Duration="0:0:0.25">
  87. <DoubleAnimation.EasingFunction>
  88. <CubicEase EasingMode="EaseIn" />
  89. </DoubleAnimation.EasingFunction>
  90. </DoubleAnimation>
  91. </Storyboard>
  92. </BeginStoryboard>
  93. </Trigger.ExitActions>
  94. </Trigger>
  95. <Trigger Property="IsEnabled" Value="False">
  96. <Setter TargetName="border" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
  97. </Trigger>
  98. <Trigger Property="bpa:ButtonHelper.ShowShadow" Value="True">
  99. <Setter TargetName="effectBorder" Property="Visibility" Value="Visible" />
  100. </Trigger>
  101. <Trigger Property="bpa:ButtonHelper.Shape" Value="Round">
  102. <Setter Property="bpa:ControlHelper.CornerRadius" Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}, Converter={StaticResource HalfOfDoubleConverter}}" />
  103. </Trigger>
  104. <Trigger Property="bpa:ButtonHelper.Shape" Value="Circle">
  105. <Setter Property="Width" Value="{Binding Path=ActualHeight, RelativeSource={RelativeSource Self}}" />
  106. <Setter Property="bpa:ControlHelper.CornerRadius" Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}, Converter={StaticResource HalfOfDoubleConverter}}" />
  107. <Setter Property="Padding" Value="5" />
  108. <Setter Property="VerticalAlignment" Value="Center" />
  109. </Trigger>
  110. <Trigger Property="bpa:ButtonHelper.Loading" Value="True">
  111. <Setter TargetName="loading" Property="Visibility" Value="Visible" />
  112. <Setter TargetName="contentPresenter" Property="Content" Value="{Binding Path=(bpa:ButtonHelper.LoadingContent), RelativeSource={RelativeSource AncestorType=Button}}" />
  113. </Trigger>
  114. <Trigger Property="Content" Value="{x:Null}">
  115. <Setter TargetName="loading" Property="Margin" Value="0" />
  116. </Trigger>
  117. <MultiDataTrigger>
  118. <MultiDataTrigger.Conditions>
  119. <Condition Binding="{Binding DependencyObjectType.SystemType, RelativeSource={RelativeSource Self}}" Value="{x:Type Button}" />
  120. <Condition Binding="{Binding IsDefault, RelativeSource={RelativeSource Self}}" Value="True" />
  121. </MultiDataTrigger.Conditions>
  122. <Setter TargetName="effectBorder" Property="Visibility" Value="Visible" />
  123. <Setter TargetName="effectBorder" Property="Effect" Value="{DynamicResource AllDirectionEffect3}" />
  124. </MultiDataTrigger>
  125. </ControlTemplate.Triggers>
  126. </ControlTemplate>
  127. </Setter.Value>
  128. </Setter>
  129. </Style>
  130. <Style x:Key="RubyerButton"
  131. BasedOn="{StaticResource RubyerButtonBase}"
  132. TargetType="{x:Type Button}" />
  133. <Style x:Key="LightButton"
  134. BasedOn="{StaticResource RubyerButton}"
  135. TargetType="{x:Type Button}">
  136. <Setter Property="Background" Value="{DynamicResource Light}" />
  137. <Setter Property="Foreground" Value="{DynamicResource BlackForeground}" />
  138. </Style>
  139. <Style x:Key="DarkButton"
  140. BasedOn="{StaticResource RubyerButton}"
  141. TargetType="{x:Type Button}">
  142. <Setter Property="Background" Value="{DynamicResource Dark}" />
  143. <Setter Property="Foreground" Value="{DynamicResource WhiteForeground}" />
  144. </Style>
  145. <Style x:Key="AccentButton"
  146. BasedOn="{StaticResource RubyerButton}"
  147. TargetType="{x:Type Button}">
  148. <Setter Property="Background" Value="{DynamicResource Accent}" />
  149. <Setter Property="Foreground" Value="{DynamicResource WhiteForeground}" />
  150. </Style>
  151. <Style x:Key="SecondaryButton"
  152. BasedOn="{StaticResource RubyerButton}"
  153. TargetType="{x:Type Button}">
  154. <Setter Property="Background" Value="{DynamicResource Secondary}" />
  155. <Setter Property="Foreground" Value="{DynamicResource SecondaryForeground}" />
  156. </Style>
  157. <Style x:Key="InfoButton"
  158. BasedOn="{StaticResource RubyerButton}"
  159. TargetType="{x:Type Button}">
  160. <Setter Property="Background" Value="{DynamicResource Info}" />
  161. <Setter Property="Foreground" Value="{DynamicResource WhiteForeground}" />
  162. </Style>
  163. <Style x:Key="WarningButton"
  164. BasedOn="{StaticResource RubyerButton}"
  165. TargetType="{x:Type Button}">
  166. <Setter Property="Background" Value="{DynamicResource Warning}" />
  167. <Setter Property="Foreground" Value="{DynamicResource WhiteForeground}" />
  168. </Style>
  169. <Style x:Key="SuccessButton"
  170. BasedOn="{StaticResource RubyerButton}"
  171. TargetType="{x:Type Button}">
  172. <Setter Property="Background" Value="{DynamicResource Success}" />
  173. <Setter Property="Foreground" Value="{DynamicResource WhiteForeground}" />
  174. </Style>
  175. <Style x:Key="ErrorButton"
  176. BasedOn="{StaticResource RubyerButton}"
  177. TargetType="{x:Type Button}">
  178. <Setter Property="Background" Value="{DynamicResource Error}" />
  179. <Setter Property="Foreground" Value="{DynamicResource WhiteForeground}" />
  180. </Style>
  181. <!-- 文字按钮 -->
  182. <Style x:Key="TextButton"
  183. BasedOn="{StaticResource RubyerButton}"
  184. TargetType="{x:Type Button}">
  185. <Setter Property="Background" Value="Transparent" />
  186. <Setter Property="Foreground" Value="{DynamicResource Primary}" />
  187. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource Mask}" />
  188. <Setter Property="bpa:ControlHelper.MaskOpacity" Value="0.5" />
  189. <Setter Property="BorderBrush" Value="{Binding Foreground, RelativeSource={RelativeSource Self}}" />
  190. </Style>
  191. <Style x:Key="TextLightButton"
  192. BasedOn="{StaticResource TextButton}"
  193. TargetType="{x:Type Button}">
  194. <Setter Property="Foreground" Value="{DynamicResource Light}" />
  195. </Style>
  196. <Style x:Key="TextDarkButton"
  197. BasedOn="{StaticResource TextButton}"
  198. TargetType="{x:Type Button}">
  199. <Setter Property="Foreground" Value="{DynamicResource Dark}" />
  200. </Style>
  201. <Style x:Key="TextAccentButton"
  202. BasedOn="{StaticResource TextButton}"
  203. TargetType="{x:Type Button}">
  204. <Setter Property="Foreground" Value="{DynamicResource Accent}" />
  205. </Style>
  206. <Style x:Key="TextSuccessButton"
  207. BasedOn="{StaticResource TextButton}"
  208. TargetType="{x:Type Button}">
  209. <Setter Property="Foreground" Value="{DynamicResource Success}" />
  210. </Style>
  211. <Style x:Key="TextInfoButton"
  212. BasedOn="{StaticResource TextButton}"
  213. TargetType="{x:Type Button}">
  214. <Setter Property="Foreground" Value="{DynamicResource Info}" />
  215. </Style>
  216. <Style x:Key="TextWarningButton"
  217. BasedOn="{StaticResource TextButton}"
  218. TargetType="{x:Type Button}">
  219. <Setter Property="Foreground" Value="{DynamicResource Warning}" />
  220. </Style>
  221. <Style x:Key="TextErrorButton"
  222. BasedOn="{StaticResource TextButton}"
  223. TargetType="{x:Type Button}">
  224. <Setter Property="Foreground" Value="{DynamicResource Error}" />
  225. </Style>
  226. <!-- Outline 按钮 -->
  227. <Style x:Key="OutlineButton"
  228. BasedOn="{StaticResource TextButton}"
  229. TargetType="{x:Type Button}">
  230. <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
  231. </Style>
  232. <Style x:Key="OutlineLightButton"
  233. BasedOn="{StaticResource OutlineButton}"
  234. TargetType="{x:Type Button}">
  235. <Setter Property="Foreground" Value="{DynamicResource Light}" />
  236. </Style>
  237. <Style x:Key="OutlineDarkButton"
  238. BasedOn="{StaticResource OutlineButton}"
  239. TargetType="{x:Type Button}">
  240. <Setter Property="Foreground" Value="{DynamicResource Dark}" />
  241. </Style>
  242. <Style x:Key="OutlineAccentButton"
  243. BasedOn="{StaticResource OutlineButton}"
  244. TargetType="{x:Type Button}">
  245. <Setter Property="Foreground" Value="{DynamicResource Accent}" />
  246. </Style>
  247. <Style x:Key="OutlineSuccessButton"
  248. BasedOn="{StaticResource OutlineButton}"
  249. TargetType="{x:Type Button}">
  250. <Setter Property="Foreground" Value="{DynamicResource Success}" />
  251. </Style>
  252. <Style x:Key="OutlineInfoButton"
  253. BasedOn="{StaticResource OutlineButton}"
  254. TargetType="{x:Type Button}">
  255. <Setter Property="Foreground" Value="{DynamicResource Info}" />
  256. </Style>
  257. <Style x:Key="OutlineWarningButton"
  258. BasedOn="{StaticResource OutlineButton}"
  259. TargetType="{x:Type Button}">
  260. <Setter Property="Foreground" Value="{DynamicResource Warning}" />
  261. </Style>
  262. <Style x:Key="OutlineErrorButton"
  263. BasedOn="{StaticResource OutlineButton}"
  264. TargetType="{x:Type Button}">
  265. <Setter Property="Foreground" Value="{DynamicResource Error}" />
  266. </Style>
  267. </ResourceDictionary>