ProgressBarStyles.xaml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  2. xmlns:suki="https://github.com/kikipoulet/SukiUI"
  3. xmlns:system="clr-namespace:System;assembly=netstandard">
  4. <Design.PreviewWith>
  5. <Panel Background="Red">
  6. <ProgressBar Width="100"
  7. Height="6"
  8. Value="50" />
  9. </Panel>
  10. </Design.PreviewWith>
  11. <Style Selector="ProgressBar">
  12. <Setter Property="CornerRadius" Value="{DynamicResource SmallCornerRadius}" />
  13. <Setter Property="Background" Value="{DynamicResource SukiBorderBrush}" />
  14. <Setter Property="Foreground" Value="{DynamicResource SukiPrimaryColor}" />
  15. <Setter Property="Template">
  16. <ControlTemplate>
  17. <DockPanel Name="PART_Dock">
  18. <DockPanel.Resources>
  19. </DockPanel.Resources>
  20. <TextBlock Name="PART_Text"
  21. Width="0"
  22. Height="0"
  23. Margin="0,0,0,1"
  24. HorizontalAlignment="Right"
  25. VerticalAlignment="Center"
  26. DockPanel.Dock="Right"
  27. FontWeight="{DynamicResource DefaultDemiBold}"
  28. Foreground="{DynamicResource SukiText}"
  29. Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, StringFormat={}{0:0}%}"
  30. TextAlignment="Right" />
  31. <suki:GlassCard Name="PART_RootBorder"
  32. MinWidth="{TemplateBinding MinWidth}"
  33. Padding="0" Classes="Control"
  34. BorderBrush="{TemplateBinding BorderBrush}"
  35. BorderThickness="{TemplateBinding BorderThickness}"
  36. ClipToBounds="True"
  37. CornerRadius="{TemplateBinding CornerRadius}">
  38. <Panel>
  39. <Border Name="PART_Indicator"
  40. Width="8"
  41. Height="8"
  42. Background="{TemplateBinding Foreground}"
  43. CornerRadius="{TemplateBinding CornerRadius}"
  44. IsVisible="{Binding !IsIndeterminate, RelativeSource={RelativeSource TemplatedParent}}">
  45. <Border.Transitions>
  46. <Transitions>
  47. <DoubleTransition Easing="CircularEaseOut"
  48. Property="Width"
  49. Duration="0:0:0.6" />
  50. <DoubleTransition Easing="CircularEaseOut"
  51. Property="Height"
  52. Duration="0:0:0.6" />
  53. <BrushTransition Property="Background" Duration="0:0:0.5" />
  54. </Transitions>
  55. </Border.Transitions>
  56. </Border>
  57. <Border Name="PART_IndeterminateIndicator"
  58. Height="8"
  59. Background="{TemplateBinding Foreground}"
  60. CornerRadius="{TemplateBinding CornerRadius}"
  61. IsVisible="{Binding IsIndeterminate, RelativeSource={RelativeSource TemplatedParent}}" />
  62. </Panel>
  63. </suki:GlassCard>
  64. </DockPanel>
  65. </ControlTemplate>
  66. </Setter>
  67. <Style Selector="^[FlowDirection=RightToLeft] /template/ TextBlock#PART_Text">
  68. <Setter Property="TextAlignment" Value="Left"/>
  69. </Style>
  70. </Style>
  71. <Style Selector="ProgressBar:horizontal /template/ Border#PART_Indicator">
  72. <Setter Property="HorizontalAlignment" Value="Left" />
  73. <Setter Property="VerticalAlignment" Value="Stretch" />
  74. </Style>
  75. <Style Selector="ProgressBar:vertical /template/ DockPanel#PART_Dock">
  76. <Setter Property="Width" Value="35" />
  77. </Style>
  78. <Style Selector="ProgressBar:vertical /template/ Border#PART_Indicator">
  79. <Setter Property="HorizontalAlignment" Value="Stretch" />
  80. <Setter Property="VerticalAlignment" Value="Bottom" />
  81. </Style>
  82. <Style Selector="ProgressBar:horizontal">
  83. <Setter Property="MinWidth" Value="200" />
  84. </Style>
  85. <Style Selector="ProgressBar:vertical">
  86. <Setter Property="MinHeight" Value="200" />
  87. </Style>
  88. <Style Selector="ProgressBar:horizontal /template/ TextBlock#PART_Text">
  89. <Setter Property="DockPanel.Dock" Value="Right" />
  90. <Setter Property="Height" Value="15" />
  91. </Style>
  92. <Style Selector="ProgressBar:vertical /template/ TextBlock#PART_Text">
  93. <Setter Property="DockPanel.Dock" Value="Bottom" />
  94. <Setter Property="Margin" Value="10,10,0,0" />
  95. <Setter Property="TextAlignment" Value="Center" />
  96. <Setter Property="Width" Value="35" />
  97. </Style>
  98. <Style Selector="ProgressBar:horizontal[ShowProgressText=True] /template/ TextBlock#PART_Text">
  99. <Style.Animations>
  100. <Animation FillMode="Forward" Duration="0:0:0.35">
  101. <KeyFrame Cue="0%">
  102. <Setter Property="Width" Value="0" />
  103. </KeyFrame>
  104. <KeyFrame Cue="100%">
  105. <Setter Property="Width" Value="40" />
  106. </KeyFrame>
  107. </Animation>
  108. </Style.Animations>
  109. </Style>
  110. <Style Selector="ProgressBar:horizontal[ShowProgressText=False] /template/ TextBlock#PART_Text">
  111. <Style.Animations>
  112. <Animation FillMode="Forward" Duration="0:0:0.35">
  113. <KeyFrame Cue="0%">
  114. <Setter Property="Width" Value="40" />
  115. </KeyFrame>
  116. <KeyFrame Cue="100%">
  117. <Setter Property="Width" Value="0" />
  118. </KeyFrame>
  119. </Animation>
  120. </Style.Animations>
  121. </Style>
  122. <Style Selector="ProgressBar:vertical[ShowProgressText=True] /template/ TextBlock#PART_Text">
  123. <Style.Animations>
  124. <Animation FillMode="Forward" Duration="0:0:0.35">
  125. <KeyFrame Cue="0%">
  126. <Setter Property="Height" Value="0" />
  127. </KeyFrame>
  128. <KeyFrame Cue="100%">
  129. <Setter Property="Height" Value="35" />
  130. </KeyFrame>
  131. </Animation>
  132. </Style.Animations>
  133. </Style>
  134. <Style Selector="ProgressBar:vertical[ShowProgressText=False] /template/ TextBlock#PART_Text">
  135. <Style.Animations>
  136. <Animation FillMode="Forward" Duration="0:0:0.35">
  137. <KeyFrame Cue="0%">
  138. <Setter Property="Height" Value="35" />
  139. </KeyFrame>
  140. <KeyFrame Cue="100%">
  141. <Setter Property="Height" Value="0" />
  142. </KeyFrame>
  143. </Animation>
  144. </Style.Animations>
  145. </Style>
  146. <Style Selector="ProgressBar:horizontal /template/ suki|GlassCard#PART_RootBorder">
  147. <Setter Property="MinHeight" Value="8" />
  148. <Setter Property="Height" Value="8" />
  149. <Setter Property="MaxHeight" Value="8" />
  150. </Style>
  151. <Style Selector="ProgressBar:vertical /template/ suki|GlassCard#PART_RootBorder">
  152. <Setter Property="MinWidth" Value="8" />
  153. <Setter Property="Width" Value="8" />
  154. <Setter Property="MaxWidth" Value="8" />
  155. </Style>
  156. <Style Selector="ProgressBar:vertical /template/ LayoutTransformControl#PART_LayoutTransformControl">
  157. <Setter Property="LayoutTransform">
  158. <Setter.Value>
  159. <RotateTransform Angle="90" />
  160. </Setter.Value>
  161. </Setter>
  162. </Style>
  163. <Style Selector="ProgressBar:horizontal:indeterminate /template/ Border#PART_IndeterminateIndicator">
  164. <Style.Animations>
  165. <Animation Easing="LinearEasing"
  166. IterationCount="Infinite"
  167. Duration="0:0:2">
  168. <KeyFrame Cue="0%">
  169. <Setter Property="TranslateTransform.X"
  170. Value="{Binding IndeterminateStartingOffset, RelativeSource={RelativeSource TemplatedParent}}" />
  171. </KeyFrame>
  172. <KeyFrame Cue="100%">
  173. <Setter Property="TranslateTransform.X"
  174. Value="{Binding IndeterminateEndingOffset, RelativeSource={RelativeSource TemplatedParent}}" />
  175. </KeyFrame>
  176. </Animation>
  177. </Style.Animations>
  178. <Setter Property="Width"
  179. Value="{Binding TemplateProperties.ContainerWidth, RelativeSource={RelativeSource TemplatedParent}}" />
  180. </Style>
  181. <Style Selector="ProgressBar:vertical:indeterminate /template/ Border#PART_IndeterminateIndicator">
  182. <Style.Animations>
  183. <Animation Easing="LinearEasing"
  184. IterationCount="Infinite"
  185. Duration="0:0:2">
  186. <KeyFrame Cue="0%">
  187. <Setter Property="TranslateTransform.Y"
  188. Value="{Binding IndeterminateStartingOffset, RelativeSource={RelativeSource TemplatedParent}}" />
  189. </KeyFrame>
  190. <KeyFrame Cue="100%">
  191. <Setter Property="TranslateTransform.Y"
  192. Value="{Binding IndeterminateEndingOffset, RelativeSource={RelativeSource TemplatedParent}}" />
  193. </KeyFrame>
  194. </Animation>
  195. </Style.Animations>
  196. <Setter Property="Height"
  197. Value="{Binding TemplateProperties.ContainerWidth, RelativeSource={RelativeSource TemplatedParent}}" />
  198. </Style>
  199. <Style Selector="ProgressBar.Accent">
  200. <Setter Property="Foreground" Value="{DynamicResource SukiAccentColor}" />
  201. </Style>
  202. <Style Selector="ProgressBar.Light">
  203. <Setter Property="Foreground" Value="{DynamicResource SukiPrimaryColor75}" />
  204. </Style>
  205. </Styles>