ProgressBarBaseStyle.xaml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:hc="clr-namespace:HandyControl.Controls"
  4. xmlns:shapes="clr-namespace:HandyControl.Expression.Shapes"
  5. xmlns:system="clr-namespace:System;assembly=mscorlib">
  6. <LinearGradientBrush x:Key="ProgressBarIndicatorAnimatedFill" StartPoint="0,0" EndPoint="1,0">
  7. <GradientStop Color="#00FFFFFF" Offset="0"/>
  8. <GradientStop Color="#60FFFFFF" Offset="0.4"/>
  9. <GradientStop Color="#60FFFFFF" Offset="0.6"/>
  10. <GradientStop Color="#00FFFFFF" Offset="1"/>
  11. </LinearGradientBrush>
  12. <Style x:Key="ProgressBarBaseStyle" TargetType="ProgressBar">
  13. <Setter Property="hc:VisualElement.Text">
  14. <Setter.Value>
  15. <MultiBinding Converter="{StaticResource Number2PercentageConverter}" StringFormat="{}{0:F0} %">
  16. <Binding Path="Value" RelativeSource="{RelativeSource Self}"/>
  17. <Binding Path="Maximum" RelativeSource="{RelativeSource Self}"/>
  18. </MultiBinding>
  19. </Setter.Value>
  20. </Setter>
  21. <Setter Property="Height" Value="20"/>
  22. <Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
  23. <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
  24. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
  25. <Setter Property="BorderThickness" Value="0"/>
  26. <Setter Property="Template">
  27. <Setter.Value>
  28. <ControlTemplate TargetType="ProgressBar">
  29. <ControlTemplate.Resources>
  30. <Storyboard x:Key="IsIndeterminate" RepeatBehavior="Forever">
  31. <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="Animation">
  32. <EasingDoubleKeyFrame KeyTime="0" Value="0.25"/>
  33. <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.25"/>
  34. <EasingDoubleKeyFrame KeyTime="0:0:2" Value="0.25"/>
  35. </DoubleAnimationUsingKeyFrames>
  36. <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)" Storyboard.TargetName="Animation">
  37. <EasingPointKeyFrame KeyTime="0" Value="-0.5,0.5"/>
  38. <EasingPointKeyFrame KeyTime="0:0:1" Value="0.5,0.5"/>
  39. <EasingPointKeyFrame KeyTime="0:0:2" Value="1.5,0.5"/>
  40. </PointAnimationUsingKeyFrames>
  41. </Storyboard>
  42. </ControlTemplate.Resources>
  43. <Border x:Name="TemplateRoot" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
  44. <hc:SimplePanel>
  45. <Rectangle x:Name="PART_Track"/>
  46. <TextBlock Visibility="{Binding Visibility,ElementName=PART_GlowRect}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{TemplateBinding Foreground}" Text="{Binding Path=(hc:VisualElement.Text),RelativeSource={RelativeSource TemplatedParent}}"/>
  47. <Border Style="{StaticResource BorderClip}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" x:Name="PART_Indicator" HorizontalAlignment="Left">
  48. <hc:SimplePanel>
  49. <Border x:Name="Indicator" Background="{TemplateBinding Foreground}">
  50. <Border Width="{Binding ActualWidth,ElementName=TemplateRoot}">
  51. <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{DynamicResource TextIconBrush}" Text="{Binding Path=(hc:VisualElement.Text),RelativeSource={RelativeSource TemplatedParent}}"/>
  52. </Border>
  53. </Border>
  54. <Rectangle x:Name="PART_GlowRect" Fill="{StaticResource ProgressBarIndicatorAnimatedFill}" HorizontalAlignment="Left" Margin="-100,0,0,0" Width="100"/>
  55. <Rectangle x:Name="Animation" Visibility="Collapsed" Fill="{TemplateBinding Foreground}" RenderTransformOrigin="0.5,0.5">
  56. <Rectangle.RenderTransform>
  57. <TransformGroup>
  58. <ScaleTransform/>
  59. </TransformGroup>
  60. </Rectangle.RenderTransform>
  61. </Rectangle>
  62. </hc:SimplePanel>
  63. </Border>
  64. </hc:SimplePanel>
  65. </Border>
  66. <ControlTemplate.Triggers>
  67. <Trigger Property="Orientation" Value="Vertical">
  68. <Setter Property="Height" Value="{x:Static system:Double.NaN}"/>
  69. <Setter Property="LayoutTransform" TargetName="TemplateRoot">
  70. <Setter.Value>
  71. <RotateTransform Angle="-90"/>
  72. </Setter.Value>
  73. </Setter>
  74. </Trigger>
  75. <Trigger Property="IsIndeterminate" Value="true">
  76. <Trigger.EnterActions>
  77. <BeginStoryboard Storyboard="{StaticResource IsIndeterminate}"/>
  78. </Trigger.EnterActions>
  79. <Setter Property="Visibility" TargetName="Indicator" Value="Collapsed"/>
  80. <Setter Property="Visibility" TargetName="PART_GlowRect" Value="Collapsed"/>
  81. <Setter Property="Visibility" TargetName="Animation" Value="Visible"/>
  82. </Trigger>
  83. </ControlTemplate.Triggers>
  84. </ControlTemplate>
  85. </Setter.Value>
  86. </Setter>
  87. </Style>
  88. <Style x:Key="ProgressBarStripeBaseStyle" TargetType="ProgressBar">
  89. <Setter Property="Height" Value="20"/>
  90. <Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
  91. <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
  92. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
  93. <Setter Property="BorderThickness" Value="0"/>
  94. <Setter Property="Template">
  95. <Setter.Value>
  96. <ControlTemplate TargetType="ProgressBar">
  97. <ControlTemplate.Resources>
  98. <Storyboard x:Key="OnLoaded">
  99. <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" Storyboard.TargetProperty="(Border.Background).(Brush.Transform).(TransformGroup.Children)[1].(TranslateTransform.X)" Storyboard.TargetName="Indicator">
  100. <LinearDoubleKeyFrame KeyTime="0" Value="0"/>
  101. <LinearDoubleKeyFrame KeyTime="0:0:.25" Value="21"/>
  102. </DoubleAnimationUsingKeyFrames>
  103. </Storyboard>
  104. </ControlTemplate.Resources>
  105. <hc:SimplePanel x:Name="TemplateRoot" SnapsToDevicePixels="true">
  106. <Border CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
  107. <Rectangle x:Name="PART_Track"/>
  108. <Decorator x:Name="PART_Indicator" HorizontalAlignment="Left">
  109. <Border x:Name="Indicator" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Background="{TemplateBinding Foreground}"/>
  110. </Decorator>
  111. </hc:SimplePanel>
  112. <ControlTemplate.Triggers>
  113. <Trigger Property="Orientation" Value="Vertical">
  114. <Setter Property="Height" Value="{x:Static system:Double.NaN}"/>
  115. <Setter Property="LayoutTransform" TargetName="TemplateRoot">
  116. <Setter.Value>
  117. <RotateTransform Angle="-90"/>
  118. </Setter.Value>
  119. </Setter>
  120. </Trigger>
  121. <EventTrigger RoutedEvent="FrameworkElement.Loaded" SourceName="Indicator">
  122. <BeginStoryboard Storyboard="{StaticResource OnLoaded}"/>
  123. </EventTrigger>
  124. </ControlTemplate.Triggers>
  125. </ControlTemplate>
  126. </Setter.Value>
  127. </Setter>
  128. </Style>
  129. <ControlTemplate x:Key="CircleProgressBarIndeterminateTemplate" TargetType="hc:CircleProgressBar">
  130. <ControlTemplate.Resources>
  131. <Storyboard x:Key="IsIndeterminate" RepeatBehavior="Forever">
  132. <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)" Storyboard.TargetName="TemplateRoot">
  133. <LinearDoubleKeyFrame KeyTime="0:0:1.568" Value="360"/>
  134. </DoubleAnimationUsingKeyFrames>
  135. <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)" Storyboard.TargetName="arc">
  136. <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
  137. <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:0.666" Value="135"/>
  138. <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:1.333" Value="270"/>
  139. <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:1.999" Value="405"/>
  140. <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:2.666" Value="540"/>
  141. <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:3.333" Value="675"/>
  142. <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:3.999" Value="810"/>
  143. <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:4.666" Value="945"/>
  144. <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:5.332" Value="1080"/>
  145. </DoubleAnimationUsingKeyFrames>
  146. <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" Storyboard.TargetProperty="(shapes:Arc.StartAngle)" Storyboard.TargetName="arc">
  147. <SplineDoubleKeyFrame KeyTime="0" Value="-5"/>
  148. <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:0.666" Value="-130"/>
  149. <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:1.333" Value="-5"/>
  150. </DoubleAnimationUsingKeyFrames>
  151. <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" Storyboard.TargetProperty="(shapes:Arc.EndAngle)" Storyboard.TargetName="arc">
  152. <SplineDoubleKeyFrame KeyTime="0" Value="5"/>
  153. <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:0.666" Value="130"/>
  154. <SplineDoubleKeyFrame KeySpline="0.4,0.0,0.2,1" KeyTime="0:0:1.333" Value="5"/>
  155. </DoubleAnimationUsingKeyFrames>
  156. </Storyboard>
  157. </ControlTemplate.Resources>
  158. <hc:SimplePanel x:Name="TemplateRoot" RenderTransformOrigin="0.5,0.5">
  159. <hc:SimplePanel.RenderTransform>
  160. <TransformGroup>
  161. <RotateTransform/>
  162. </TransformGroup>
  163. </hc:SimplePanel.RenderTransform>
  164. <shapes:Arc ArcThickness="{TemplateBinding ArcThickness}" Stretch="None" EndAngle="360" Width="{TemplateBinding ActualWidth}" Height="{TemplateBinding ActualHeight}" Stroke="{TemplateBinding BorderBrush}" Fill="{TemplateBinding Background}" StrokeThickness="0"/>
  165. <shapes:Arc RenderTransformOrigin="0.5,0.5" StartAngle="-5" EndAngle="5" ArcThickness="{TemplateBinding ArcThickness}" Stretch="None" Width="{TemplateBinding ActualWidth}" StrokeThickness="0" Height="{TemplateBinding ActualHeight}" x:Name="arc" Fill="{TemplateBinding Foreground}">
  166. <shapes:Arc.RenderTransform>
  167. <TransformGroup>
  168. <RotateTransform/>
  169. </TransformGroup>
  170. </shapes:Arc.RenderTransform>
  171. </shapes:Arc>
  172. </hc:SimplePanel>
  173. <ControlTemplate.Triggers>
  174. <Trigger Property="IsIndeterminate" Value="true">
  175. <Trigger.EnterActions>
  176. <BeginStoryboard Storyboard="{StaticResource IsIndeterminate}"/>
  177. </Trigger.EnterActions>
  178. </Trigger>
  179. </ControlTemplate.Triggers>
  180. </ControlTemplate>
  181. <ControlTemplate x:Key="CircleProgressBarTemplate" TargetType="hc:CircleProgressBar">
  182. <hc:SimplePanel x:Name="TemplateRoot">
  183. <shapes:Arc ArcThickness="{TemplateBinding ArcThickness}" Stretch="None" EndAngle="360" Width="{TemplateBinding ActualWidth}" Height="{TemplateBinding ActualHeight}" Stroke="{TemplateBinding BorderBrush}" Fill="{TemplateBinding Background}" StrokeThickness="0"/>
  184. <shapes:Arc ArcThickness="{TemplateBinding ArcThickness}" Stretch="None" Width="{TemplateBinding ActualWidth}" StrokeThickness="0" Height="{TemplateBinding ActualHeight}" x:Name="PART_Indicator" Fill="{TemplateBinding Foreground}"/>
  185. <TextBlock Visibility="{Binding ShowText,RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource Boolean2VisibilityConverter}}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Text}"/>
  186. </hc:SimplePanel>
  187. </ControlTemplate>
  188. <Style x:Key="ProgressBarCircleBaseStyle" TargetType="hc:CircleProgressBar">
  189. <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
  190. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
  191. <Setter Property="Height" Value="100"/>
  192. <Setter Property="Width" Value="100"/>
  193. <Setter Property="ArcThickness" Value="4"/>
  194. <Setter Property="Text" Value="{Binding Value,RelativeSource={RelativeSource Self},StringFormat={}{0:F0} %}"/>
  195. <Setter Property="Template" Value="{StaticResource CircleProgressBarTemplate}"/>
  196. <Style.Triggers>
  197. <Trigger Property="IsIndeterminate" Value="True">
  198. <Setter Property="Template" Value="{StaticResource CircleProgressBarIndeterminateTemplate}"/>
  199. </Trigger>
  200. </Style.Triggers>
  201. </Style>
  202. <Style x:Key="ProgressBarWaveBaseStyle" TargetType="hc:WaveProgressBar">
  203. <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
  204. <Setter Property="Width" Value="100"/>
  205. <Setter Property="BorderThickness" Value="1"/>
  206. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
  207. <Setter Property="Text" Value="{Binding Value,RelativeSource={RelativeSource Self},StringFormat={}{0:F0} %}"/>
  208. <Setter Property="Template">
  209. <Setter.Value>
  210. <ControlTemplate TargetType="hc:WaveProgressBar">
  211. <ControlTemplate.Resources>
  212. <Storyboard x:Key="StoryboardOnLoaded" RepeatBehavior="Forever">
  213. <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.X)" Storyboard.TargetName="PART_Wave">
  214. <EasingDoubleKeyFrame KeyTime="0:0:2" Value="-400"/>
  215. </DoubleAnimationUsingKeyFrames>
  216. </Storyboard>
  217. </ControlTemplate.Resources>
  218. <StackPanel>
  219. <Border Style="{StaticResource BorderCircular}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
  220. <Viewbox>
  221. <Border x:Name="PART_Clip" Style="{StaticResource BorderCircularClip}" CornerRadius="100" Width="200" Height="200">
  222. <Path x:Name="PART_Wave" Stroke="{TemplateBinding WaveStroke}" StrokeThickness="{TemplateBinding WaveThickness}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="600" Height="250" Fill="{TemplateBinding WaveFill}" Stretch="Fill" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" Margin="0,0,-400,-20">
  223. <Path.Data>
  224. <PathGeometry>
  225. <PathFigure StartPoint="0,1">
  226. <PolyBezierSegment Points="0.5,1 0.5,0 1,0"/>
  227. <PolyBezierSegment Points="1.5,0 1.5,1 2,1"/>
  228. <PolyBezierSegment Points="2.5,1 2.5,0 3,0"/>
  229. <PolyLineSegment Points="3,0 3,10, 0,10 0,1"/>
  230. </PathFigure>
  231. </PathGeometry>
  232. </Path.Data>
  233. </Path>
  234. </Border>
  235. </Viewbox>
  236. </Border>
  237. <TextBlock Margin="0,10,0,0" Visibility="{Binding ShowText,RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource Boolean2VisibilityConverter}}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Text}"/>
  238. </StackPanel>
  239. <ControlTemplate.Triggers>
  240. <EventTrigger RoutedEvent="FrameworkElement.Loaded" SourceName="PART_Wave">
  241. <BeginStoryboard Name="BeginStoryboardWave" Storyboard="{StaticResource StoryboardOnLoaded}"/>
  242. </EventTrigger>
  243. <EventTrigger RoutedEvent="FrameworkElement.Unloaded" SourceName="PART_Wave">
  244. <StopStoryboard BeginStoryboardName="BeginStoryboardWave"/>
  245. </EventTrigger>
  246. </ControlTemplate.Triggers>
  247. </ControlTemplate>
  248. </Setter.Value>
  249. </Setter>
  250. </Style>
  251. </ResourceDictionary>