CircleProgressBar.axaml 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <UserControl x:Class="SukiUI.Controls.CircleProgressBar"
  2. xmlns="https://github.com/avaloniaui"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. xmlns:suki="clr-namespace:SukiUI.Controls"
  7. d:DesignHeight="450"
  8. d:DesignWidth="800"
  9. mc:Ignorable="d">
  10. <UserControl.Styles>
  11. <Style Selector="suki|CircleProgressBar">
  12. <Setter Property="Template">
  13. <ControlTemplate>
  14. <Panel>
  15. <Arc Width="{TemplateBinding Width}"
  16. Height="{TemplateBinding Height}"
  17. StartAngle="0"
  18. Stretch="None"
  19. Stroke="{DynamicResource SukiLightBorderBrush}"
  20. StrokeThickness="{TemplateBinding StrokeWidth}"
  21. SweepAngle="360" />
  22. <Arc Name="PART_ArcFill"
  23. Width="{TemplateBinding Width}"
  24. Height="{TemplateBinding Height}"
  25. Stretch="None"
  26. Stroke="{DynamicResource SukiPrimaryColor}"
  27. StrokeJoin="Round"
  28. StrokeLineCap="Round"
  29. StrokeThickness="{TemplateBinding StrokeWidth}"
  30. SweepAngle="{TemplateBinding Value}">
  31. <Arc.Transitions>
  32. <Transitions>
  33. <BrushTransition Property="Stroke" Duration="0:0:0.5" />
  34. <DoubleTransition Easing="CircularEaseOut"
  35. Property="SweepAngle"
  36. Duration="0:0:0.8" />
  37. <DoubleTransition Easing="CircularEaseOut"
  38. Property="StartAngle"
  39. Duration="0:0:0.8" />
  40. </Transitions>
  41. </Arc.Transitions>
  42. </Arc>
  43. <ContentControl Margin="{TemplateBinding StrokeWidth}"
  44. HorizontalContentAlignment="Center"
  45. VerticalContentAlignment="Center"
  46. Content="{TemplateBinding Content}" />
  47. </Panel>
  48. </ControlTemplate>
  49. </Setter>
  50. <Style Selector="^.Accent /template/ Arc#PART_ArcFill">
  51. <Setter Property="Stroke" Value="{DynamicResource SukiAccentColor}" />
  52. </Style>
  53. <Style Selector="^[IsIndeterminate=True] /template/ Arc#PART_ArcFill">
  54. <Setter Property="SweepAngle" Value="90" />
  55. <Style.Animations>
  56. <Animation IterationCount="Infinite" Duration="0:0:1.2">
  57. <KeyFrame Cue="0%">
  58. <Setter Property="StartAngle" Value="270" />
  59. </KeyFrame>
  60. <KeyFrame Cue="100%">
  61. <Setter Property="StartAngle" Value="630" />
  62. </KeyFrame>
  63. </Animation>
  64. </Style.Animations>
  65. </Style>
  66. <Style Selector="^[IsIndeterminate=False] /template/ Arc#PART_ArcFill">
  67. <Setter Property="StartAngle" Value="270" />
  68. </Style>
  69. </Style>
  70. </UserControl.Styles>
  71. </UserControl>