WaveProgress.axaml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <UserControl x:Class="SukiUI.Controls.WaveProgress"
  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. xmlns:waveProgress="clr-namespace:SukiUI.Converters.WaveProgress"
  8. d:DesignHeight="450"
  9. d:DesignWidth="800"
  10. mc:Ignorable="d">
  11. <UserControl.Styles>
  12. <Style Selector="suki|WaveProgress">
  13. <Setter Property="Template">
  14. <ControlTemplate>
  15. <Border Width="200"
  16. Height="200"
  17. Margin="20"
  18. Background="Transparent"
  19. BorderBrush="{DynamicResource SukiControlBorderBrush}"
  20. BorderThickness="1.2"
  21. BoxShadow="{DynamicResource SukiLowShadow}"
  22. ClipToBounds="False"
  23. CornerRadius="100">
  24. <Border.Resources>
  25. <waveProgress:WaveProgressValueConverter x:Key="WValueConverter" />
  26. <waveProgress:WaveProgressValueTextConverter x:Key="WValueTextConverter" />
  27. <waveProgress:WaveProgressValueColorConverter x:Key="WValueColorConverter" />
  28. <waveProgress:WaveProgressGradientOffsetConverter x:Key="WGradientConverter" />
  29. </Border.Resources>
  30. <Border Width="200"
  31. Height="200"
  32. HorizontalAlignment="Center"
  33. VerticalAlignment="Center"
  34. ClipToBounds="True"
  35. CornerRadius="100">
  36. <Panel>
  37. <Canvas Width="200" Height="200">
  38. <Path Canvas.Top="{TemplateBinding Value,
  39. Converter={StaticResource WValueConverter}}"
  40. Classes="WaveAnimatedFast"
  41. Data="M 0,50 H 700 V 350 H 0 M 0,50 C 25,55 75,45 100,50 S 175,55 200,50 S 275,45 300,50 S 375,55 400,50 S 475,45 500,50 S 575,55 600,50 S 675,45 700,50"
  42. Fill="{TemplateBinding Value,
  43. Converter={StaticResource WGradientConverter}}"
  44. Opacity="0.45"
  45. StrokeThickness="0">
  46. <Path.Transitions>
  47. <Transitions>
  48. <DoubleTransition Property="Canvas.Top" Duration="0:0:1.5">
  49. <DoubleTransition.Easing>
  50. <CircularEaseOut />
  51. </DoubleTransition.Easing>
  52. </DoubleTransition>
  53. </Transitions>
  54. </Path.Transitions>
  55. </Path>
  56. <Path Canvas.Top="{TemplateBinding Value,
  57. Converter={StaticResource WValueConverter}}"
  58. Classes="WaveAnimated"
  59. Data="M 0,50 H 700 V 350 H 0 M 0,50 C 25,55 75,45 100,50 S 175,55 200,50 S 275,45 300,50 S 375,55 400,50 S 475,45 500,50 S 575,55 600,50 S 675,45 700,50"
  60. Fill="{TemplateBinding Value,
  61. Converter={StaticResource WGradientConverter}}"
  62. Opacity="0.8"
  63. StrokeThickness="0">
  64. <Path.Transitions>
  65. <Transitions>
  66. <DoubleTransition Property="Canvas.Top" Duration="0:0:2.5">
  67. <DoubleTransition.Easing>
  68. <CircularEaseOut />
  69. </DoubleTransition.Easing>
  70. </DoubleTransition>
  71. </Transitions>
  72. </Path.Transitions>
  73. </Path>
  74. </Canvas>
  75. <TextBlock Name="PART_Text"
  76. Margin="100,200,0,0"
  77. HorizontalAlignment="Center"
  78. VerticalAlignment="Center"
  79. Classes="h2"
  80. Foreground="{TemplateBinding Value,
  81. Converter={StaticResource WValueColorConverter}}"
  82. Text="{TemplateBinding Value,
  83. Converter={StaticResource WValueTextConverter}}">
  84. <TextBlock.Transitions>
  85. <Transitions>
  86. <DoubleTransition Property="Opacity" Duration="0:0:0.3" />
  87. </Transitions>
  88. </TextBlock.Transitions>
  89. </TextBlock>
  90. </Panel>
  91. </Border>
  92. </Border>
  93. </ControlTemplate>
  94. </Setter>
  95. </Style>
  96. <Style Selector="suki|WaveProgress[IsTextVisible=True] /template/ TextBlock#PART_Text">
  97. <Setter Property="Opacity" Value="1" />
  98. </Style>
  99. <Style Selector="suki|WaveProgress[IsTextVisible=False] /template/ TextBlock#PART_Text">
  100. <Setter Property="Opacity" Value="0" />
  101. </Style>
  102. <Style Selector="Path.WaveAnimated">
  103. <Style.Animations>
  104. <Animation IterationCount="INFINITE" Duration="0:0:6">
  105. <KeyFrame Cue="0%">
  106. <Setter Property="Canvas.Left" Value="-100" />
  107. </KeyFrame>
  108. <KeyFrame Cue="100%">
  109. <Setter Property="Canvas.Left" Value="-500" />
  110. </KeyFrame>
  111. </Animation>
  112. </Style.Animations>
  113. </Style>
  114. <Style Selector="Path.WaveAnimatedFast">
  115. <Style.Animations>
  116. <Animation IterationCount="INFINITE" Duration="0:0:3">
  117. <KeyFrame Cue="0%">
  118. <Setter Property="Canvas.Left" Value="-100" />
  119. </KeyFrame>
  120. <KeyFrame Cue="100%">
  121. <Setter Property="Canvas.Left" Value="-500" />
  122. </KeyFrame>
  123. </Animation>
  124. </Style.Animations>
  125. </Style>
  126. </UserControl.Styles>
  127. </UserControl>