Skip to content

Commit a18daba

Browse files
committed
Use generated DPs 3
1 parent 4373ca1 commit a18daba

File tree

2 files changed

+11
-249
lines changed

2 files changed

+11
-249
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Files.App.Controls.Primitives
1010
{
1111
[DependencyProperty<double>("StartAngle", nameof(OnStartAngleChanged), DefaultValue = "(double)0.0")]
1212
[DependencyProperty<double>("EndAngle", nameof(OnEndAngleChanged), DefaultValue = "(double)90.0")]
13-
[DependencyProperty<SweepDirection>("SweepDirection", nameof(OnSweepDirectionChanged), DefaultValue = "(SweepDirection)1")]
13+
[DependencyProperty<SweepDirection>("SweepDirection", nameof(OnSweepDirectionChanged), DefaultValue = "global::System.Windows.Media.SweepDirection.Clockwise")]
1414
[DependencyProperty<double>("MinAngle", nameof(OnMinAngleChanged), DefaultValue = "(double)0.0")]
1515
[DependencyProperty<double>("MaxAngle", nameof(OnMaxAngleChanged), DefaultValue = "(double)360.0")]
1616
[DependencyProperty<double>("RadiusWidth", nameof(OnRadiusWidthChanged), DefaultValue = "(double)0.0")]

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

Lines changed: 10 additions & 248 deletions
Original file line numberDiff line numberDiff line change
@@ -5,153 +5,37 @@
55

66
namespace Files.App.Controls
77
{
8+
[DependencyProperty<double>("ValueRingThickness", nameof(OnValueRingThicknessChanged), DefaultValue = "(double)0.0")]
9+
[DependencyProperty<double>("TrackRingThickness", nameof(OnTrackRingThicknessChanged), DefaultValue = "(double)0.0")]
10+
[DependencyProperty<double>("MinAngle", nameof(OnMinAngleChanged), DefaultValue = "(double)0.0")]
11+
[DependencyProperty<double>("MaxAngle", nameof(OnMaxAngleChanged), DefaultValue = "(double)360.0")]
12+
[DependencyProperty<double>("StartAngle", nameof(OnStartAngleChanged), DefaultValue = "(double)0.0")]
13+
[DependencyProperty<double>("Percent", nameof(OnPercentChanged))]
14+
[DependencyProperty<double>("PercentCaution", nameof(OnPercentCautionChanged), DefaultValue = "(double)75.01.0")]
15+
[DependencyProperty<double>("PercentCritical", nameof(OnPercentCriticalChanged), DefaultValue = "(double)90.01")]
16+
[DependencyProperty<double>("ValueAngle"))]
17+
[DependencyProperty<double>("AdjustedSize", DefaultValue = "(double)16.0")]
818
public partial class StorageRing
919
{
10-
#region ValueRingThickness (double)
11-
12-
/// <summary>
13-
/// The ValueRing Thickness property.
14-
/// </summary>
15-
public static readonly DependencyProperty ValueRingThicknessProperty =
16-
DependencyProperty.Register(
17-
nameof(ValueRingThickness),
18-
typeof(double),
19-
typeof(StorageRing),
20-
new PropertyMetadata(0.0, (d, e) => ((StorageRing)d).OnValueRingThicknessChanged((double)e.OldValue, (double)e.NewValue)));
21-
22-
/// <summary>
23-
/// Gets or sets the Track ring Thickness.
24-
/// </summary>
25-
/// <value>
26-
/// The value ring thickness.
27-
/// </value>
28-
public double ValueRingThickness
29-
{
30-
get => (double)GetValue(ValueRingThicknessProperty);
31-
set => SetValue(ValueRingThicknessProperty, value);
32-
}
33-
3420
private void OnValueRingThicknessChanged(double oldValue, double newValue)
3521
{
3622
UpdateRingThickness(this, newValue, false);
3723
UpdateRings(this);
3824
}
3925

40-
#endregion
41-
42-
#region TrackRingThickness (double)
43-
44-
/// <summary>
45-
/// The TrackRing Thickness property.
46-
/// </summary>
47-
public static readonly DependencyProperty TrackRingThicknessProperty =
48-
DependencyProperty.Register(
49-
nameof(TrackRingThickness),
50-
typeof(double),
51-
typeof(StorageRing),
52-
new PropertyMetadata(0.0, (d, e) => ((StorageRing)d).OnTrackRingThicknessChanged((double)e.OldValue, (double)e.NewValue)));
53-
54-
/// <summary>
55-
/// Gets or sets the Track ring Thickness.
56-
/// </summary>
57-
/// <value>
58-
/// The track ring thickness.
59-
/// </value>
60-
public double TrackRingThickness
61-
{
62-
get => (double)GetValue(TrackRingThicknessProperty);
63-
set => SetValue(TrackRingThicknessProperty, value);
64-
}
65-
6626
private void OnTrackRingThicknessChanged(double oldValue, double newValue)
6727
{
6828
UpdateRingThickness(this, newValue, true);
6929
UpdateRings(this);
7030
}
7131

72-
#endregion
73-
74-
#region MinAngle (double)
75-
76-
/// <summary>
77-
/// Identifies the MinAngle dependency property.
78-
/// </summary>
79-
public static readonly DependencyProperty MinAngleProperty =
80-
DependencyProperty.Register(
81-
nameof(MinAngle),
82-
typeof(double),
83-
typeof(StorageRing),
84-
new PropertyMetadata(0.0, (d, e) => ((StorageRing)d).OnMinAngleChanged((double)e.OldValue, (double)e.NewValue)));
85-
86-
/// <summary>
87-
/// Gets or sets the MinAngle
88-
/// </summary>
89-
public double MinAngle
90-
{
91-
get => (double)GetValue(MinAngleProperty);
92-
set => SetValue(MinAngleProperty, value);
93-
}
94-
95-
private void OnMinAngleChanged(double oldValue, double newValue)
96-
{
97-
UpdateValues(this, Value, _oldValue, false, -1.0);
98-
CalculateAndSetNormalizedAngles(this, newValue, MaxAngle);
99-
UpdateRings(this);
100-
}
101-
102-
#endregion
103-
104-
#region MaxAngle (double)
105-
106-
/// <summary>
107-
/// Identifies the MinAngle dependency property.
108-
/// </summary>
109-
public static readonly DependencyProperty MaxAngleProperty =
110-
DependencyProperty.Register(
111-
nameof(MaxAngle),
112-
typeof(double),
113-
typeof(StorageRing),
114-
new PropertyMetadata(360.0, (d, e) => ((StorageRing)d).OnMaxAngleChanged((double)e.OldValue, (double)e.NewValue)));
115-
116-
/// <summary>
117-
/// Gets or sets the MaxAngle
118-
/// </summary>
119-
public double MaxAngle
120-
{
121-
get => (double)GetValue(MaxAngleProperty);
122-
set => SetValue(MaxAngleProperty, value);
123-
}
124-
12532
private void OnMaxAngleChanged(double oldValue, double newValue)
12633
{
12734
UpdateValues(this, Value, _oldValue, false, -1.0);
12835
CalculateAndSetNormalizedAngles(this, MinAngle, newValue);
12936
UpdateRings(this);
13037
}
13138

132-
#endregion
133-
134-
#region StartAngle (double)
135-
136-
/// <summary>
137-
/// Identifies the StartAngle dependency property.
138-
/// </summary>
139-
public static readonly DependencyProperty StartAngleProperty =
140-
DependencyProperty.Register(
141-
nameof(StartAngle),
142-
typeof(double),
143-
typeof(StorageRing),
144-
new PropertyMetadata(0.0, (d, e) => ((StorageRing)d).OnStartAngleChanged((double)e.OldValue, (double)e.NewValue)));
145-
146-
/// <summary>
147-
/// Gets or sets the StartAngle
148-
/// </summary>
149-
public double StartAngle
150-
{
151-
get => (double)GetValue(StartAngleProperty);
152-
set => SetValue(StartAngleProperty, value);
153-
}
154-
15539
private void OnStartAngleChanged(double oldValue, double newValue)
15640
{
15741
UpdateValues(this, Value, _oldValue, false, -1.0);
@@ -160,29 +44,6 @@ private void OnStartAngleChanged(double oldValue, double newValue)
16044
UpdateRings(this);
16145
}
16246

163-
#endregion
164-
165-
#region Percent (double)
166-
167-
/// <summary>
168-
/// Identifies the Percent dependency property.
169-
/// </summary>
170-
public static readonly DependencyProperty PercentProperty =
171-
DependencyProperty.Register(
172-
nameof(Percent),
173-
typeof(double),
174-
typeof(StorageRing),
175-
new PropertyMetadata(null, (d, e) => ((StorageRing)d).OnPercentChanged((double)e.OldValue, (double)e.NewValue)));
176-
177-
/// <summary>
178-
/// Gets or sets the current value as a Percentage between 0.0 and 100.0.
179-
/// </summary>
180-
public double Percent
181-
{
182-
get => (double)GetValue(PercentProperty);
183-
set => SetValue(PercentProperty, value);
184-
}
185-
18647
private void OnPercentChanged(double oldValue, double newValue)
18748
{
18849
return; //Read-only
@@ -201,30 +62,6 @@ private void OnPercentChanged(double oldValue, double newValue)
20162
UpdateValues(this, Value, _oldValue, true, adjustedPercentage);
20263
UpdateVisualState(this);
20364
UpdateRings(this);
204-
205-
}
206-
207-
#endregion
208-
209-
#region PercentCaution (double)
210-
211-
/// <summary>
212-
/// Identifies the PercentCaution dependency property
213-
/// </summary>
214-
public static readonly DependencyProperty PercentCautionProperty =
215-
DependencyProperty.Register(
216-
nameof(PercentCaution),
217-
typeof(double),
218-
typeof(StorageRing),
219-
new PropertyMetadata(75.01, (d, e) => ((StorageRing)d).OnPercentCautionChanged((double)e.OldValue, (double)e.NewValue)));
220-
221-
/// <summary>
222-
/// Gets or sets the PercentCaution double value
223-
/// </summary>
224-
public double PercentCaution
225-
{
226-
get => (double)GetValue(PercentCautionProperty);
227-
set => SetValue(PercentCautionProperty, value);
22865
}
22966

23067
private void OnPercentCautionChanged(double oldValue, double newValue)
@@ -234,40 +71,13 @@ private void OnPercentCautionChanged(double oldValue, double newValue)
23471
UpdateRings(this);
23572
}
23673

237-
#endregion
238-
239-
#region PercentCritical (double)
240-
241-
/// <summary>
242-
/// Identifies the PercentCritical dependency property
243-
/// </summary>
244-
public static readonly DependencyProperty PercentCriticalProperty =
245-
DependencyProperty.Register(
246-
nameof(PercentCritical),
247-
typeof(double),
248-
typeof(StorageRing),
249-
new PropertyMetadata(90.01, (d, e) => ((StorageRing)d).OnPercentCriticalChanged((double)e.OldValue, (double)e.NewValue)));
250-
251-
/// <summary>
252-
/// Gets or sets the PercentCritical double value
253-
/// </summary>
254-
public double PercentCritical
255-
{
256-
get => (double)GetValue(PercentCriticalProperty);
257-
set => SetValue(PercentCriticalProperty, value);
258-
}
259-
26074
private void OnPercentCriticalChanged(double oldValue, double newValue)
26175
{
26276
UpdateValues(this, Value, _oldValue, false, -1.0);
26377
UpdateVisualState(this);
26478
UpdateRings(this);
26579
}
26680

267-
#endregion
268-
269-
#region RangeBase Methods
270-
27181
/// <inheritdoc/>
27282
protected override void OnValueChanged(double oldValue, double newValue)
27383
{
@@ -288,53 +98,5 @@ protected override void OnMaximumChanged(double oldMaximum, double newMaximum)
28898
base.OnMaximumChanged(oldMaximum, newMaximum);
28999
StorageRing_MaximumChanged(this, newMaximum);
290100
}
291-
292-
#endregion
293-
294-
#region Protected ValueAngle (double)
295-
296-
/// <summary>
297-
/// Identifies the ValueAngle dependency property.
298-
/// </summary>
299-
protected static readonly DependencyProperty ValueAngleProperty =
300-
DependencyProperty.Register(
301-
nameof(ValueAngle),
302-
typeof(double),
303-
typeof(StorageRing),
304-
new PropertyMetadata(null));
305-
306-
/// <summary>
307-
/// Gets or sets the current angle of the Ring (between MinAngle and MaxAngle).
308-
/// </summary>
309-
protected double ValueAngle
310-
{
311-
get => (double)GetValue(ValueAngleProperty);
312-
set => SetValue(ValueAngleProperty, value);
313-
}
314-
315-
#endregion
316-
317-
#region Protected AdjustedSize (double)
318-
319-
/// <summary>
320-
/// Identifies the AdjustedSize dependency property.
321-
/// </summary>
322-
protected static readonly DependencyProperty AdjustedSizeProperty =
323-
DependencyProperty.Register(
324-
nameof(AdjustedSize),
325-
typeof(double),
326-
typeof(StorageRing),
327-
new PropertyMetadata(16.0));
328-
329-
/// <summary>
330-
/// Gets or sets the AdjustedSize of the control.
331-
/// </summary>
332-
protected double AdjustedSize
333-
{
334-
get => (double)GetValue(AdjustedSizeProperty);
335-
set => SetValue(AdjustedSizeProperty, value);
336-
}
337-
338-
#endregion
339101
}
340102
}

0 commit comments

Comments
 (0)