Skip to content

Commit ebe6ad5

Browse files
committed
Use generated DPs
1 parent d56432f commit ebe6ad5

File tree

2 files changed

+58
-516
lines changed

2 files changed

+58
-516
lines changed

src/Files.App.Controls/Storage/RingShape/RingShape.Properties.cs

Lines changed: 27 additions & 334 deletions
Original file line numberDiff line numberDiff line change
@@ -8,364 +8,57 @@
88

99
namespace Files.App.Controls.Primitives
1010
{
11+
[DependencyProperty<double>("StartAngle", nameof(OnStartAngleChanged), DefaultValue = "(double)0.0")]
12+
[DependencyProperty<double>("EndAngle", nameof(OnEndAngleChanged), DefaultValue = "(double)90.0")]
13+
[DependencyProperty<SweepDirection>("SweepDirection", nameof(OnSweepDirectionChanged), DefaultValue = "SweepDirection.Clockwise")]
14+
[DependencyProperty<double>("MinAngle", nameof(OnMinAngleChanged), DefaultValue = "(double)0.0")]
15+
[DependencyProperty<double>("MaxAngle", nameof(OnMaxAngleChanged), DefaultValue = "(double)360.0")]
16+
[DependencyProperty<double>("RadiusWidth", nameof(OnRadiusWidthChanged), DefaultValue = "(double)0.0")]
17+
[DependencyProperty<double>("RadiusHeight", nameof(OnRadiusHeightChanged), DefaultValue = "(double)0.0")]
18+
[DependencyProperty<bool>("IsCircle", nameof(OnIsCircleChanged), DefaultValue = "(bool)false")]
19+
[DependencyProperty<Point>("Center")]
20+
[DependencyProperty<double>("ActualRadiusWidth")]
21+
[DependencyProperty<double>("ActualRadiusHeight")]
1122
public partial class RingShape : Path
1223
{
13-
#region StartAngle (double)
14-
15-
/// <summary>
16-
/// The Start Angle property.
17-
/// </summary>
18-
public static readonly DependencyProperty StartAngleProperty =
19-
DependencyProperty.Register(
20-
nameof(StartAngle),
21-
typeof(double),
22-
typeof(RingShape),
23-
new PropertyMetadata(0.0, OnStartAngleChanged));
24-
25-
/// <summary>
26-
/// Gets or sets the start angle.
27-
/// </summary>
28-
/// <value>
29-
/// The start angle.
30-
/// </value>
31-
public double StartAngle
24+
protected virtual void OnStartAngleChanged(double oldValue, double newValue)
3225
{
33-
get => (double)GetValue(StartAngleProperty);
34-
set => SetValue(StartAngleProperty, value);
26+
StartAngleChanged();
3527
}
3628

37-
/// <summary>
38-
/// Function invoked as the StartAngleProperty is changed
39-
/// </summary>
40-
/// <param name="d">The DependencyObject which holds the DependencyProperty</param>
41-
/// <param name="e">DependencyPropertyChangedEventArgs</param>
42-
private static void OnStartAngleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
29+
protected virtual void OnEndAngleChanged(double oldValue, double newValue)
4330
{
44-
RingShape ringShape = (RingShape)d;
45-
46-
ringShape.StartAngleChanged(d, (double)e.NewValue);
31+
EndAngleChanged();
4732
}
4833

49-
#endregion
50-
51-
#region EndAngle (double)
52-
53-
/// <summary>
54-
/// The End Angle property.
55-
/// </summary>
56-
public static readonly DependencyProperty EndAngleProperty =
57-
DependencyProperty.Register(
58-
nameof(EndAngle),
59-
typeof(double),
60-
typeof(RingShape),
61-
new PropertyMetadata(90.0, OnEndAngleChanged));
62-
63-
/// <summary>
64-
/// Gets or sets the end angle.
65-
/// </summary>
66-
/// <value>
67-
/// The end angle.
68-
/// </value>
69-
public double EndAngle
34+
protected virtual void OnSweepDirectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
7035
{
71-
get => (double)GetValue(EndAngleProperty);
72-
set => SetValue(EndAngleProperty, value);
36+
SweepDirectionChanged();
7337
}
7438

75-
/// <summary>
76-
/// Function invoked as the EndAngleProperty is changed
77-
/// </summary>
78-
/// <param name="d">The DependencyObject which holds the DependencyProperty</param>
79-
/// <param name="e">DependencyPropertyChangedEventArgs</param>
80-
private static void OnEndAngleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
39+
protected virtual void OnMinAngleChanged(double oldValue, double newValue)
8140
{
82-
RingShape ringShape = (RingShape)d;
83-
84-
ringShape.EndAngleChanged(d, (double)e.NewValue);
41+
MinMaxAngleChanged(false);
8542
}
8643

87-
#endregion
88-
89-
#region SweepDirection (SweepDirection)
90-
91-
/// <summary>
92-
/// The SweepDirection property.
93-
/// </summary>
94-
public static readonly DependencyProperty SweepDirectionProperty =
95-
DependencyProperty.Register(
96-
nameof(SweepDirection),
97-
typeof(SweepDirection),
98-
typeof(RingShape),
99-
new PropertyMetadata(
100-
SweepDirection.Clockwise, OnSweepDirectionChanged));
101-
102-
/// <summary>
103-
/// Gets or sets the SweepDirection.
104-
/// </summary>
105-
/// <value>
106-
/// The SweepDirection.
107-
/// </value>
108-
public SweepDirection SweepDirection
44+
protected virtual void OnMaxAngleChanged(double oldValue, double newValue)
10945
{
110-
get => (SweepDirection)GetValue(SweepDirectionProperty);
111-
set => SetValue(SweepDirectionProperty, value);
46+
MinMaxAngleChanged(true);
11247
}
11348

114-
/// <summary>
115-
/// Function invoked as the SweepDirectionProperty is changed
116-
/// </summary>
117-
/// <param name="d">The DependencyObject which holds the DependencyProperty</param>
118-
/// <param name="e">DependencyPropertyChangedEventArgs</param>
119-
private static void OnSweepDirectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
49+
protected virtual void OnRadiusWidthChanged(double oldValue, double newValue)
12050
{
121-
RingShape ringShape = (RingShape)d;
122-
123-
ringShape.SweepDirectionChanged(d, (SweepDirection)e.NewValue);
51+
RadiusWidthChanged();
12452
}
12553

126-
#endregion
127-
128-
#region MinAngle (double)
129-
130-
/// <summary>
131-
/// Identifies the MinAngle dependency property.
132-
/// </summary>
133-
public static readonly DependencyProperty MinAngleProperty =
134-
DependencyProperty.Register(
135-
nameof(MinAngle),
136-
typeof(double),
137-
typeof(RingShape),
138-
new PropertyMetadata(0.0, OnMinAngleChanged));
139-
140-
/// <summary>
141-
/// Gets or sets the MinAngle
142-
/// </summary>
143-
public double MinAngle
54+
protected virtual void OnRadiusHeightChanged(double oldValue, double newValue)
14455
{
145-
get => (double)GetValue(MinAngleProperty);
146-
set => SetValue(MinAngleProperty, value);
56+
RadiusHeightChanged();
14757
}
14858

149-
/// <summary>
150-
/// Function invoked as the MinAngleProperty is changed
151-
/// </summary>
152-
/// <param name="d">The DependencyObject which holds the DependencyProperty</param>
153-
/// <param name="e">DependencyPropertyChangedEventArgs</param>
154-
private static void OnMinAngleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
59+
protected virtual void OnIsCircleChanged(bool oldValue, bool newValue)
15560
{
156-
RingShape ringShape = (RingShape)d;
157-
158-
ringShape.MinMaxAngleChanged(d, (double)e.NewValue, false);
61+
IsCircleChanged();
15962
}
160-
161-
#endregion
162-
163-
#region MaxAngle (double)
164-
165-
/// <summary>
166-
/// Identifies the MinAngle dependency property.
167-
/// </summary>
168-
public static readonly DependencyProperty MaxAngleProperty =
169-
DependencyProperty.Register(
170-
nameof(MaxAngle),
171-
typeof(double),
172-
typeof(RingShape),
173-
new PropertyMetadata(360.0, OnMaxAngleChanged));
174-
175-
/// <summary>
176-
/// Gets or sets the MaxAngle
177-
/// </summary>
178-
public double MaxAngle
179-
{
180-
get => (double)GetValue(MaxAngleProperty);
181-
set => SetValue(MaxAngleProperty, value);
182-
}
183-
184-
/// <summary>
185-
/// Function invoked as the MaxAngleProperty is changed
186-
/// </summary>
187-
/// <param name="d">The DependencyObject which holds the DependencyProperty</param>
188-
/// <param name="e">DependencyPropertyChangedEventArgs</param>
189-
private static void OnMaxAngleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
190-
{
191-
RingShape ringShape = (RingShape)d;
192-
193-
ringShape.MinMaxAngleChanged(ringShape, (double)e.NewValue, true);
194-
}
195-
196-
#endregion
197-
198-
#region RadiusWidth (double)
199-
200-
/// <summary>
201-
/// Identifies the RadiusWidth dependency property.
202-
/// </summary>
203-
public static readonly DependencyProperty RadiusWidthProperty =
204-
DependencyProperty.Register(
205-
nameof(RadiusWidth),
206-
typeof(double),
207-
typeof(RingShape),
208-
new PropertyMetadata(0.0, OnRadiusWidthChanged));
209-
210-
/// <summary>
211-
/// Gets or sets the Radius along the Width of the shape
212-
/// </summary>
213-
public double RadiusWidth
214-
{
215-
get => (double)GetValue(RadiusWidthProperty);
216-
set => SetValue(RadiusWidthProperty, value);
217-
}
218-
219-
/// <summary>
220-
/// Function invoked as the RadiusWidthProperty is changed
221-
/// </summary>
222-
/// <param name="d">The DependencyObject which holds the DependencyProperty</param>
223-
/// <param name="e">DependencyPropertyChangedEventArgs</param>
224-
private static void OnRadiusWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
225-
{
226-
RingShape ringShape = (RingShape)d;
227-
228-
ringShape.RadiusWidthChanged(d, (double)e.NewValue);
229-
}
230-
231-
#endregion
232-
233-
#region RadiusHeight (double)
234-
235-
/// <summary>
236-
/// Identifies the RadiusHeight dependency property.
237-
/// </summary>
238-
public static readonly DependencyProperty RadiusHeightProperty =
239-
DependencyProperty.Register(
240-
nameof(RadiusHeight),
241-
typeof(double),
242-
typeof(RingShape),
243-
new PropertyMetadata(0.0, OnRadiusHeightChanged));
244-
245-
/// <summary>
246-
/// Gets or sets the Radius along the Height of the shape
247-
/// </summary>
248-
public double RadiusHeight
249-
{
250-
get => (double)GetValue(RadiusHeightProperty);
251-
set => SetValue(RadiusHeightProperty, value);
252-
}
253-
254-
/// <summary>
255-
/// Function invoked as the RadiusHeightProperty is changed
256-
/// </summary>
257-
/// <param name="d">The DependencyObject which holds the DependencyProperty</param>
258-
/// <param name="e">DependencyPropertyChangedEventArgs</param>
259-
private static void OnRadiusHeightChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
260-
{
261-
RingShape ringShape = (RingShape)d;
262-
263-
ringShape.RadiusHeightChanged(d, (double)e.NewValue);
264-
}
265-
#endregion
266-
267-
#region IsCircle (bool)
268-
269-
/// <summary>
270-
/// Identifies the <see cref="IsCircle"/> property.
271-
/// </summary>
272-
public static readonly DependencyProperty IsCircleProperty =
273-
DependencyProperty.Register(
274-
nameof(IsCircle),
275-
typeof(bool),
276-
typeof(RingShape),
277-
new PropertyMetadata(false, OnIsCircleChanged));
278-
279-
/// <summary>
280-
/// Gets or sets a value indicating whether the shape should be constrained as a Circle.
281-
/// </summary>
282-
public bool IsCircle
283-
{
284-
get => (bool)GetValue(IsCircleProperty);
285-
set => SetValue(IsCircleProperty, value);
286-
}
287-
288-
/// <summary>
289-
/// Function invoked as the IsCircleProperty is changed
290-
/// </summary>
291-
/// <param name="d">The DependencyObject which holds the DependencyProperty</param>
292-
/// <param name="e">DependencyPropertyChangedEventArgs</param>
293-
private static void OnIsCircleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
294-
{
295-
RingShape ringShape = (RingShape)d;
296-
297-
ringShape.IsCircleChanged(d, (bool)e.NewValue);
298-
}
299-
300-
#endregion
301-
302-
#region Protected Centre (Point)
303-
304-
/// <summary>
305-
/// Identifies the Protected Center dependency property.
306-
/// </summary>
307-
protected static readonly DependencyProperty CenterProperty =
308-
DependencyProperty.Register(
309-
nameof(Center),
310-
typeof(Point),
311-
typeof(RingShape),
312-
new PropertyMetadata(null));
313-
314-
/// <summary>
315-
/// Gets or sets the Center point
316-
/// </summary>
317-
protected Point Center
318-
{
319-
get => (Point)GetValue(CenterProperty);
320-
set => SetValue(CenterProperty, value);
321-
}
322-
323-
#endregion
324-
325-
#region Protected ActualRadiusWidth (double)
326-
327-
/// <summary>
328-
/// Identifies the Protected ActualRadiusWidth dependency property.
329-
/// </summary>
330-
protected static readonly DependencyProperty ActualRadiusWidthProperty =
331-
DependencyProperty.Register(
332-
nameof(ActualRadiusWidth),
333-
typeof(double),
334-
typeof(RingShape),
335-
new PropertyMetadata(null));
336-
337-
/// <summary>
338-
/// Gets or sets the ActualRadiusWidth double value
339-
/// </summary>
340-
protected double ActualRadiusWidth
341-
{
342-
get => (double)GetValue(ActualRadiusWidthProperty);
343-
set => SetValue(ActualRadiusWidthProperty, value);
344-
}
345-
346-
#endregion
347-
348-
#region Protected ActualRadiusHeight (double)
349-
350-
/// <summary>
351-
/// Identifies the Protected ActualRadiusHeight dependency property.
352-
/// </summary>
353-
protected static readonly DependencyProperty ActualRadiusHeightProperty =
354-
DependencyProperty.Register(
355-
nameof(ActualRadiusHeight),
356-
typeof(double),
357-
typeof(RingShape),
358-
new PropertyMetadata(null));
359-
360-
/// <summary>
361-
/// Gets or sets the ActualRadiusHeight double value
362-
/// </summary>
363-
protected double ActualRadiusHeight
364-
{
365-
get => (double)GetValue(ActualRadiusHeightProperty);
366-
set => SetValue(ActualRadiusHeightProperty, value);
367-
}
368-
369-
#endregion
37063
}
37164
}

0 commit comments

Comments
 (0)