選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

281 行
21 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="RubyerProgressBar" TargetType="{x:Type ProgressBar}">
  8. <Setter Property="Background" Value="{DynamicResource BorderLight}" />
  9. <Setter Property="BorderBrush" Value="Transparent" />
  10. <Setter Property="BorderThickness" Value="0" />
  11. <Setter Property="Foreground" Value="{DynamicResource DefaultForeground}" />
  12. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource Primary}" />
  13. <Setter Property="bpa:ProgressBarHelper.Thickness" Value="5" />
  14. <Setter Property="Template">
  15. <Setter.Value>
  16. <ControlTemplate TargetType="{x:Type ProgressBar}">
  17. <Grid x:Name="TemplateRoot">
  18. <Grid.RowDefinitions>
  19. <RowDefinition Height="Auto" />
  20. <RowDefinition Height="Auto" />
  21. </Grid.RowDefinitions>
  22. <TextBlock Grid.Row="0"
  23. HorizontalAlignment="Center"
  24. VerticalAlignment="Center"
  25. FontSize="{TemplateBinding FontSize}"
  26. Visibility="{Binding Path=(bpa:ProgressBarHelper.ShowPercent), RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource BooleanToVisibleConverter}}">
  27. <TextBlock.Text>
  28. <MultiBinding Converter="{StaticResource GetPercentConverter}">
  29. <Binding Path="Value" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  30. <Binding Path="Minimum" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  31. <Binding Path="Maximum" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  32. </MultiBinding>
  33. </TextBlock.Text>
  34. </TextBlock>
  35. <Grid Grid.Row="1" Height="{Binding Path=(bpa:ProgressBarHelper.Thickness), RelativeSource={RelativeSource Mode=TemplatedParent}}">
  36. <Rectangle x:Name="PART_Track" />
  37. <Border Background="{TemplateBinding Background}"
  38. BorderBrush="{TemplateBinding BorderBrush}"
  39. BorderThickness="{TemplateBinding BorderThickness}" />
  40. <Grid x:Name="PART_Indicator"
  41. HorizontalAlignment="Left"
  42. ClipToBounds="true">
  43. <Rectangle x:Name="Indicator" Fill="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
  44. <Rectangle x:Name="Animation"
  45. Fill="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  46. RenderTransformOrigin="0.5,0.5">
  47. <Rectangle.RenderTransform>
  48. <TransformGroup>
  49. <ScaleTransform />
  50. <SkewTransform />
  51. <RotateTransform />
  52. <TranslateTransform />
  53. </TransformGroup>
  54. </Rectangle.RenderTransform>
  55. </Rectangle>
  56. </Grid>
  57. </Grid>
  58. <VisualStateManager.VisualStateGroups>
  59. <VisualStateGroup x:Name="CommonStates">
  60. <VisualState x:Name="Determinate" />
  61. <VisualState x:Name="Indeterminate">
  62. <Storyboard RepeatBehavior="Forever">
  63. <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Animation" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
  64. <EasingDoubleKeyFrame KeyTime="0" Value="0.3" />
  65. <EasingDoubleKeyFrame KeyTime="0:0:0.75" Value="0.4" />
  66. <EasingDoubleKeyFrame KeyTime="0:0:1.5" Value="0.3" />
  67. </DoubleAnimationUsingKeyFrames>
  68. <PointAnimationUsingKeyFrames Storyboard.TargetName="Animation" Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)">
  69. <EasingPointKeyFrame KeyTime="0" Value="-0.5,0.5" />
  70. <EasingPointKeyFrame KeyTime="0:0:0.75" Value="0.5,0.5" />
  71. <EasingPointKeyFrame KeyTime="0:0:1.5" Value="1.5,0.5" />
  72. </PointAnimationUsingKeyFrames>
  73. </Storyboard>
  74. </VisualState>
  75. </VisualStateGroup>
  76. </VisualStateManager.VisualStateGroups>
  77. </Grid>
  78. <ControlTemplate.Triggers>
  79. <Trigger Property="Orientation" Value="Vertical">
  80. <Setter TargetName="TemplateRoot" Property="LayoutTransform">
  81. <Setter.Value>
  82. <RotateTransform Angle="-90" />
  83. </Setter.Value>
  84. </Setter>
  85. </Trigger>
  86. <Trigger Property="IsIndeterminate" Value="True">
  87. <Setter TargetName="Indicator" Property="Visibility" Value="Collapsed" />
  88. </Trigger>
  89. </ControlTemplate.Triggers>
  90. </ControlTemplate>
  91. </Setter.Value>
  92. </Setter>
  93. </Style>
  94. <!-- 圆形进度条 -->
  95. <Style x:Key="CircleProgressBar" TargetType="{x:Type ProgressBar}">
  96. <Setter Property="Background" Value="{DynamicResource BorderLight}" />
  97. <Setter Property="BorderBrush" Value="Transparent" />
  98. <Setter Property="BorderThickness" Value="0" />
  99. <Setter Property="Foreground" Value="{DynamicResource DefaultForeground}" />
  100. <Setter Property="Height" Value="40" />
  101. <Setter Property="Width" Value="40" />
  102. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource Primary}" />
  103. <Setter Property="bpa:ProgressBarHelper.IndeterminateValue" Value="30" />
  104. <Setter Property="bpa:ProgressBarHelper.Thickness" Value="5" />
  105. <Setter Property="Template">
  106. <Setter.Value>
  107. <ControlTemplate TargetType="{x:Type ProgressBar}">
  108. <Grid x:Name="TemplateRoot">
  109. <Canvas>
  110. <!-- 背景圈 -->
  111. <Path x:Name="Background"
  112. RenderTransformOrigin="0, 0"
  113. Stroke="{TemplateBinding Background}"
  114. StrokeThickness="{Binding Path=(bpa:ProgressBarHelper.Thickness), RelativeSource={RelativeSource Mode=TemplatedParent}}">
  115. <Path.Data>
  116. <PathGeometry>
  117. <PathFigure>
  118. <PathFigure.StartPoint>
  119. <MultiBinding Converter="{StaticResource DoublesToPointConverter}">
  120. <Binding Converter="{StaticResource HalfOfDoubleConverter}"
  121. Path="ActualWidth"
  122. RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  123. <Binding Source="0" />
  124. </MultiBinding>
  125. </PathFigure.StartPoint>
  126. <ArcSegment IsLargeArc="True" SweepDirection="Clockwise">
  127. <ArcSegment.Size>
  128. <MultiBinding Converter="{StaticResource DoublesToSizeConverter}">
  129. <Binding Converter="{StaticResource HalfOfDoubleConverter}"
  130. Path="ActualWidth"
  131. RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  132. <Binding Converter="{StaticResource HalfOfDoubleConverter}"
  133. Path="ActualWidth"
  134. RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  135. </MultiBinding>
  136. </ArcSegment.Size>
  137. <ArcSegment.Point>
  138. <MultiBinding Converter="{StaticResource GetArcPointConverter}">
  139. <Binding Path="Maximum" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  140. <Binding Path="Minimum" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  141. <Binding Path="Maximum" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  142. <Binding Path="ActualWidth" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  143. </MultiBinding>
  144. </ArcSegment.Point>
  145. </ArcSegment>
  146. </PathFigure>
  147. </PathGeometry>
  148. </Path.Data>
  149. </Path>
  150. <!-- 进度圈 -->
  151. <Path x:Name="Indicator"
  152. RenderTransformOrigin="0, 0"
  153. Stroke="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  154. StrokeThickness="{Binding Path=(bpa:ProgressBarHelper.Thickness), RelativeSource={RelativeSource Mode=TemplatedParent}}">
  155. <Path.Data>
  156. <PathGeometry>
  157. <PathFigure>
  158. <PathFigure.StartPoint>
  159. <MultiBinding Converter="{StaticResource DoublesToPointConverter}">
  160. <Binding Converter="{StaticResource HalfOfDoubleConverter}"
  161. Path="ActualWidth"
  162. RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  163. <Binding Source="0" />
  164. </MultiBinding>
  165. </PathFigure.StartPoint>
  166. <ArcSegment SweepDirection="Clockwise">
  167. <ArcSegment.IsLargeArc>
  168. <MultiBinding Converter="{StaticResource IsLargeArcConverter}">
  169. <Binding Path="Value" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  170. <Binding Path="Minimum" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  171. <Binding Path="Maximum" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  172. </MultiBinding>
  173. </ArcSegment.IsLargeArc>
  174. <ArcSegment.Size>
  175. <MultiBinding Converter="{StaticResource DoublesToSizeConverter}">
  176. <Binding Converter="{StaticResource HalfOfDoubleConverter}"
  177. Path="ActualWidth"
  178. RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  179. <Binding Converter="{StaticResource HalfOfDoubleConverter}"
  180. Path="ActualWidth"
  181. RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  182. </MultiBinding>
  183. </ArcSegment.Size>
  184. <ArcSegment.Point>
  185. <MultiBinding Converter="{StaticResource GetArcPointConverter}">
  186. <Binding Path="Value" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  187. <Binding Path="Minimum" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  188. <Binding Path="Maximum" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  189. <Binding Path="ActualWidth" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  190. </MultiBinding>
  191. </ArcSegment.Point>
  192. </ArcSegment>
  193. </PathFigure>
  194. </PathGeometry>
  195. </Path.Data>
  196. </Path>
  197. <!-- 不确定进度 -->
  198. <Path x:Name="IndeterminateBar"
  199. Stroke="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  200. StrokeThickness="{Binding Path=(bpa:ProgressBarHelper.Thickness), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  201. Visibility="Collapsed">
  202. <Path.Data>
  203. <PathGeometry>
  204. <PathFigure>
  205. <PathFigure.StartPoint>
  206. <MultiBinding Converter="{StaticResource DoublesToPointConverter}">
  207. <Binding Converter="{StaticResource HalfOfDoubleConverter}"
  208. Path="ActualWidth"
  209. RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  210. <Binding Source="0" />
  211. </MultiBinding>
  212. </PathFigure.StartPoint>
  213. <ArcSegment SweepDirection="Clockwise">
  214. <ArcSegment.Size>
  215. <MultiBinding Converter="{StaticResource DoublesToSizeConverter}">
  216. <Binding Converter="{StaticResource HalfOfDoubleConverter}"
  217. Path="ActualWidth"
  218. RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  219. <Binding Converter="{StaticResource HalfOfDoubleConverter}"
  220. Path="ActualWidth"
  221. RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  222. </MultiBinding>
  223. </ArcSegment.Size>
  224. <ArcSegment.Point>
  225. <MultiBinding Converter="{StaticResource GetArcPointConverter}">
  226. <Binding Path="(bpa:ProgressBarHelper.IndeterminateValue)" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  227. <Binding Path="Minimum" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  228. <Binding Path="Maximum" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  229. <Binding Path="ActualWidth" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
  230. </MultiBinding>
  231. </ArcSegment.Point>
  232. </ArcSegment>
  233. </PathFigure>
  234. </PathGeometry>
  235. </Path.Data>
  236. <Path.RenderTransform>
  237. <RotateTransform x:Name="Transform" CenterX="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualWidth, Converter={StaticResource HalfOfDoubleConverter}}" CenterY="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualWidth, Converter={StaticResource HalfOfDoubleConverter}}" />
  238. </Path.RenderTransform>
  239. </Path>
  240. </Canvas>
  241. <TextBlock HorizontalAlignment="Center"
  242. VerticalAlignment="Center"
  243. FontSize="{TemplateBinding FontSize}"
  244. Visibility="{Binding Path=(bpa:ProgressBarHelper.ShowPercent), RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource BooleanToVisibleConverter}}">
  245. <TextBlock.Text>
  246. <MultiBinding Converter="{StaticResource GetPercentConverter}">
  247. <Binding Path="Value" RelativeSource="{RelativeSource AncestorType=ProgressBar}" />
  248. <Binding Path="Minimum" RelativeSource="{RelativeSource AncestorType=ProgressBar}" />
  249. <Binding Path="Maximum" RelativeSource="{RelativeSource AncestorType=ProgressBar}" />
  250. </MultiBinding>
  251. </TextBlock.Text>
  252. </TextBlock>
  253. <VisualStateManager.VisualStateGroups>
  254. <VisualStateGroup x:Name="CommonStates">
  255. <VisualState x:Name="Determinate" />
  256. <VisualState x:Name="Indeterminate">
  257. <Storyboard RepeatBehavior="Forever"
  258. TargetProperty="Angle"
  259. TargetName="Transform">
  260. <DoubleAnimation To="359" Duration="0:0:0.8" />
  261. </Storyboard>
  262. </VisualState>
  263. </VisualStateGroup>
  264. </VisualStateManager.VisualStateGroups>
  265. </Grid>
  266. <ControlTemplate.Triggers>
  267. <Trigger Property="IsIndeterminate" Value="true">
  268. <Setter TargetName="IndeterminateBar" Property="Visibility" Value="Visible" />
  269. <Setter TargetName="Indicator" Property="Visibility" Value="Collapsed" />
  270. </Trigger>
  271. </ControlTemplate.Triggers>
  272. </ControlTemplate>
  273. </Setter.Value>
  274. </Setter>
  275. </Style>
  276. </ResourceDictionary>