Skip to content

Commit 37c9689

Browse files
committed
Add AudioWave
1 parent 3a9d00d commit 37c9689

File tree

10 files changed

+16579
-12391
lines changed

10 files changed

+16579
-12391
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,14 @@ Install-Package DevWinUI
134134
## 🔥 DevWinUI.Controls 🔥
135135
### ⚡ What’s Inside? ⚡
136136

137+
- ✨ AudioWave
137138
- ✨ SpectrumVisualizer
139+
- ✨ AnimatedTextBlock
140+
- ✨ Countdown
141+
- ✨ CircleIcon
142+
- ✨ BlendedImage
143+
- ✨ SpeedGraph
144+
- ✨ ConfettiCannon
138145
- ✨ LinearGradientBlurPanel
139146
- ✨ OrbitLoadingIndicator
140147
- ✨ StoreCarousel
@@ -252,14 +259,6 @@ Install-Package DevWinUI
252259
- ✨ Brushes
253260
- ✨ Subtle Button Style
254261
- ✨ Rounded TabViewItem Style
255-
256-
#### 🔥 Win2D 🔥
257-
- ✨ AnimatedTextBlock
258-
- ✨ Countdown
259-
- ✨ CircleIcon
260-
- ✨ BlendedImage
261-
- ✨ SpeedGraph
262-
- ✨ ConfettiCannon
263262
- ✨ BlurEffectManager
264263
- ✨ Hatch
265264
- ✨ TiledImageBrush
@@ -313,6 +312,9 @@ Install-Package DevWinUI.ContextMenu
313312

314313
## 🕰️ History 🕰️
315314

315+
### AudioWave
316+
![AudioWave](https://raw.githubusercontent.com/ghost1372/DevWinUI-Resources/refs/heads/main/DevWinUI-Docs/AudioWave.gif)
317+
316318
### SpectrumVisualizer
317319
![SpectrumVisualizer](https://raw.githubusercontent.com/ghost1372/DevWinUI-Resources/refs/heads/main/DevWinUI-Docs/SpectrumVisualizer.gif)
318320

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
namespace DevWinUI;
2+
3+
public partial class AudioWave
4+
{
5+
public TimeSpan Duration
6+
{
7+
get { return (TimeSpan)GetValue(DurationProperty); }
8+
set { SetValue(DurationProperty, value); }
9+
}
10+
11+
public static readonly DependencyProperty DurationProperty =
12+
DependencyProperty.Register(nameof(Duration), typeof(TimeSpan), typeof(AudioWave), new PropertyMetadata(TimeSpan.FromSeconds(4), OnDurationChanged));
13+
14+
private static void OnDurationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
15+
{
16+
var ctl = (AudioWave)d;
17+
if (ctl != null)
18+
{
19+
if (e.NewValue is TimeSpan time)
20+
{
21+
ctl.duration = time.TotalMilliseconds;
22+
ctl.elapsedMs = 0;
23+
ctl.songPos_ = 0;
24+
ctl.canvas?.Invalidate();
25+
}
26+
}
27+
}
28+
29+
public double BarWidth
30+
{
31+
get { return (double)GetValue(BarWidthProperty); }
32+
set { SetValue(BarWidthProperty, value); }
33+
}
34+
35+
public static readonly DependencyProperty BarWidthProperty =
36+
DependencyProperty.Register(nameof(BarWidth), typeof(double), typeof(AudioWave), new PropertyMetadata(6.0d, OnBarWidthChanged));
37+
private static void OnBarWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
38+
{
39+
var ctl = (AudioWave)d;
40+
if (ctl != null)
41+
{
42+
if (e.NewValue is double width)
43+
{
44+
ctl.barWidth = (float)width;
45+
ctl.canvas?.Invalidate();
46+
}
47+
}
48+
}
49+
public double BarSpacing
50+
{
51+
get { return (double)GetValue(BarSpacingProperty); }
52+
set { SetValue(BarSpacingProperty, value); }
53+
}
54+
55+
public static readonly DependencyProperty BarSpacingProperty =
56+
DependencyProperty.Register(nameof(BarSpacing), typeof(double), typeof(AudioWave), new PropertyMetadata(3.0d, OnBarSpacingChanged));
57+
private static void OnBarSpacingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
58+
{
59+
var ctl = (AudioWave)d;
60+
if (ctl != null)
61+
{
62+
if (e.NewValue is double space)
63+
{
64+
ctl.barSpacing = (float)space;
65+
ctl.canvas?.Invalidate();
66+
}
67+
}
68+
}
69+
70+
public List<CanvasGradientStop> BarBackgroundGradientStops
71+
{
72+
get { return (List<CanvasGradientStop>)GetValue(BarBackgroundGradientStopsProperty); }
73+
set { SetValue(BarBackgroundGradientStopsProperty, value); }
74+
}
75+
76+
public static readonly DependencyProperty BarBackgroundGradientStopsProperty =
77+
DependencyProperty.Register(nameof(BarBackgroundGradientStops), typeof(List<CanvasGradientStop>), typeof(AudioWave), new PropertyMetadata(null, OnBarBackgroundGradientStopsChanged));
78+
private static void OnBarBackgroundGradientStopsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
79+
{
80+
var ctl = (AudioWave)d;
81+
if (ctl != null)
82+
{
83+
if (e.NewValue is List<CanvasGradientStop> stops)
84+
{
85+
ctl.barBackgroundGradientStops = stops;
86+
ctl.canvas?.Invalidate();
87+
}
88+
}
89+
}
90+
public Color BarBackground
91+
{
92+
get { return (Color)GetValue(BarBackgroundProperty); }
93+
set { SetValue(BarBackgroundProperty, value); }
94+
}
95+
96+
public static readonly DependencyProperty BarBackgroundProperty =
97+
DependencyProperty.Register(nameof(BarBackground), typeof(Color), typeof(AudioWave), new PropertyMetadata(Colors.Gray, OnBarBackgroundChanged));
98+
private static void OnBarBackgroundChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
99+
{
100+
var ctl = (AudioWave)d;
101+
if (ctl != null)
102+
{
103+
if (e.NewValue is Color color)
104+
{
105+
ctl.barBackground = color;
106+
ctl.canvas?.Invalidate();
107+
}
108+
}
109+
}
110+
public List<CanvasGradientStop> BarForegroundGradientStops
111+
{
112+
get { return (List<CanvasGradientStop>)GetValue(BarForegroundGradientStopsProperty); }
113+
set { SetValue(BarForegroundGradientStopsProperty, value); }
114+
}
115+
116+
public static readonly DependencyProperty BarForegroundGradientStopsProperty =
117+
DependencyProperty.Register(nameof(BarForegroundGradientStops), typeof(List<CanvasGradientStop>), typeof(AudioWave), new PropertyMetadata(null, OnBarForegroundGradientStopsChanged));
118+
private static void OnBarForegroundGradientStopsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
119+
{
120+
var ctl = (AudioWave)d;
121+
if (ctl != null)
122+
{
123+
if (e.NewValue is List<CanvasGradientStop> stops)
124+
{
125+
ctl.barForegroundGradientStops = stops;
126+
ctl.canvas?.Invalidate();
127+
}
128+
}
129+
}
130+
public Color BarForeground
131+
{
132+
get { return (Color)GetValue(BarForegroundProperty); }
133+
set { SetValue(BarForegroundProperty, value); }
134+
}
135+
136+
public static readonly DependencyProperty BarForegroundProperty =
137+
DependencyProperty.Register(nameof(BarForeground), typeof(Color), typeof(AudioWave), new PropertyMetadata(Colors.DeepPink, OnBarForegroundChanged));
138+
139+
private static void OnBarForegroundChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
140+
{
141+
var ctl = (AudioWave)d;
142+
if (ctl != null)
143+
{
144+
if (e.NewValue is Color color)
145+
{
146+
ctl.barForeground = color;
147+
ctl.canvas?.Invalidate();
148+
}
149+
}
150+
}
151+
152+
public double BarRadiusX
153+
{
154+
get { return (double)GetValue(BarRadiusXProperty); }
155+
set { SetValue(BarRadiusXProperty, value); }
156+
}
157+
158+
public static readonly DependencyProperty BarRadiusXProperty =
159+
DependencyProperty.Register(nameof(BarRadiusX), typeof(double), typeof(AudioWave), new PropertyMetadata(3.0d, OnBarRadiusXChanged));
160+
161+
private static void OnBarRadiusXChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
162+
{
163+
var ctl = (AudioWave)d;
164+
if (ctl != null)
165+
{
166+
if (e.NewValue is double radius)
167+
{
168+
ctl.barRadiusX = (float)radius;
169+
ctl.canvas?.Invalidate();
170+
}
171+
}
172+
}
173+
174+
public double BarRadiusY
175+
{
176+
get { return (double)GetValue(BarRadiusYProperty); }
177+
set { SetValue(BarRadiusYProperty, value); }
178+
}
179+
180+
public static readonly DependencyProperty BarRadiusYProperty =
181+
DependencyProperty.Register(nameof(BarRadiusY), typeof(double), typeof(AudioWave), new PropertyMetadata(3.0d, OnBarRadiusYChanged));
182+
183+
private static void OnBarRadiusYChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
184+
{
185+
var ctl = (AudioWave)d;
186+
if (ctl != null)
187+
{
188+
if (e.NewValue is double radius)
189+
{
190+
ctl.barRadiusY = (float)radius;
191+
ctl.canvas?.Invalidate();
192+
}
193+
}
194+
}
195+
196+
public int Progress
197+
{
198+
get { return (int)GetValue(ProgressProperty); }
199+
set { SetValue(ProgressProperty, value); }
200+
}
201+
202+
public static readonly DependencyProperty ProgressProperty =
203+
DependencyProperty.Register(nameof(Progress), typeof(int), typeof(AudioWave), new PropertyMetadata(0, OnProgressChanged));
204+
205+
private static void OnProgressChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
206+
{
207+
var ctl = (AudioWave)d;
208+
if (ctl != null)
209+
{
210+
ctl.OnProgressChanged();
211+
}
212+
}
213+
214+
public bool CanSelectedByMouse
215+
{
216+
get { return (bool)GetValue(CanSelectedByMouseProperty); }
217+
set { SetValue(CanSelectedByMouseProperty, value); }
218+
}
219+
220+
public static readonly DependencyProperty CanSelectedByMouseProperty =
221+
DependencyProperty.Register(nameof(CanSelectedByMouse), typeof(bool), typeof(AudioWave), new PropertyMetadata(false));
222+
}

0 commit comments

Comments
 (0)