Skip to content

Commit 4373ca1

Browse files
committed
Use generated DPs 2
1 parent ebe6ad5 commit 4373ca1

File tree

5 files changed

+11
-155
lines changed

5 files changed

+11
-155
lines changed

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

Lines changed: 2 additions & 2 deletions
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.Clockwise")]
13+
[DependencyProperty<SweepDirection>("SweepDirection", nameof(OnSweepDirectionChanged), DefaultValue = "(SweepDirection)1")]
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")]
@@ -31,7 +31,7 @@ protected virtual void OnEndAngleChanged(double oldValue, double newValue)
3131
EndAngleChanged();
3232
}
3333

34-
protected virtual void OnSweepDirectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
34+
protected virtual void OnSweepDirectionChanged(SweepDirection oldValue, SweepDirection newValue)
3535
{
3636
SweepDirectionChanged();
3737
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private void EndAngleChanged()
6767
private void IsCircleChanged()
6868
{
6969
BeginUpdate();
70-
_isCircle = isCircle;
70+
_isCircle = IsCircle;
7171
EndUpdate();
7272
}
7373

@@ -81,7 +81,7 @@ private void RadiusWidthChanged()
8181
private void RadiusHeightChanged()
8282
{
8383
BeginUpdate();
84-
AdjustRadiusHeight(this, radiusHeight, StrokeThickness);
84+
AdjustRadiusHeight(this, RadiusHeight, StrokeThickness);
8585
EndUpdate();
8686
}
8787

@@ -107,7 +107,7 @@ private void MinMaxAngleChanged(bool isMax)
107107
private void SweepDirectionChanged()
108108
{
109109
BeginUpdate();
110-
_sweepDirection = newSweepDirection;
110+
_sweepDirection = SweepDirection;
111111
EndUpdate();
112112
}
113113

src/Files.App.Controls/Storage/StorageBar/StorageBar.Constants.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@ namespace Files.App.Controls
99
{
1010
// TemplateParts
1111
[TemplatePart(Name = ContainerPartName, Type = typeof(Grid))]
12-
1312
[TemplatePart(Name = ValueColumnPartName, Type = typeof(ColumnDefinition))]
1413
[TemplatePart(Name = GapColumnPartName, Type = typeof(ColumnDefinition))]
1514
[TemplatePart(Name = TrackColumnPartName, Type = typeof(ColumnDefinition))]
16-
1715
[TemplatePart(Name = ValueBorderPartName, Type = typeof(Border))]
1816
[TemplatePart(Name = TrackBorderPartName, Type = typeof(Border))]
19-
2017
// VisualStates
2118
[TemplateVisualState(Name = SafeStateName, GroupName = ControlStateGroupName)]
2219
[TemplateVisualState(Name = CautionStateName, GroupName = ControlStateGroupName)]

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

Lines changed: 6 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -5,182 +5,47 @@
55

66
namespace Files.App.Controls
77
{
8+
[DependencyProperty<double>("ValueBarHeight", nameof(OnValueBarHeightChanged), DefaultValue = "(double)4.0")]
9+
[DependencyProperty<double>("TrackBarHeight", nameof(OnTrackBarHeightChanged), DefaultValue = "(double)2.0")]
10+
[DependencyProperty<BarShapes>("BarShape", nameof(OnBarShapeChanged), DefaultValue = "BarShapes.Round")]
11+
[DependencyProperty<double>("Percent", nameof(OnPercentChanged), DefaultValue = "(double)0.0")]
12+
[DependencyProperty<double>("PercentCaution", nameof(OnPercentCautionChanged), DefaultValue = "(double)75.1")]
13+
[DependencyProperty<double>("PercentCritical", nameof(OnPercentCriticalChanged), DefaultValue = "(double)89.9")]
814
public partial class StorageBar
915
{
10-
#region Value Bar Height (double)
11-
12-
/// <summary>
13-
/// Identifies the ValueBarHeight dependency property.
14-
/// </summary>
15-
public static readonly DependencyProperty ValueBarHeightProperty =
16-
DependencyProperty.Register(
17-
nameof(ValueBarHeight),
18-
typeof(double),
19-
typeof(StorageBar),
20-
new PropertyMetadata(4.0, (d, e) => ((StorageBar)d).OnValueBarHeightChanged((double)e.OldValue, (double)e.NewValue)));
21-
22-
/// <summary>
23-
/// Gets or sets the height of the Value Bar.
24-
/// </summary>
25-
public double ValueBarHeight
26-
{
27-
get => (double)GetValue(ValueBarHeightProperty);
28-
set => SetValue(ValueBarHeightProperty, value);
29-
}
30-
3116
private void OnValueBarHeightChanged(double oldValue, double newValue)
3217
{
3318
UpdateControl(this);
3419
}
3520

36-
#endregion
37-
38-
#region Track Bar Height (double)
39-
40-
/// <summary>
41-
/// Identifies the TrackBarHeight dependency property.
42-
/// </summary>
43-
public static readonly DependencyProperty TrackBarHeightProperty =
44-
DependencyProperty.Register(
45-
nameof(TrackBarHeight),
46-
typeof(double),
47-
typeof(StorageBar),
48-
new PropertyMetadata(2.0, (d, e) => ((StorageBar)d).OnTrackBarHeightChanged((double)e.OldValue, (double)e.NewValue)));
49-
50-
/// <summary>
51-
/// Gets or sets the height of the Track Bar.
52-
/// </summary>
53-
public double TrackBarHeight
54-
{
55-
get => (double)GetValue(TrackBarHeightProperty);
56-
set => SetValue(TrackBarHeightProperty, value);
57-
}
58-
5921
private void OnTrackBarHeightChanged(double oldValue, double newValue)
6022
{
6123
UpdateControl(this);
6224
}
6325

64-
#endregion
65-
66-
#region BarShape (BarShapes)
67-
68-
/// <summary>
69-
/// Identifies the BarShape dependency property.
70-
/// </summary>
71-
public static readonly DependencyProperty BarShapeProperty =
72-
DependencyProperty.Register(
73-
nameof(BarShape),
74-
typeof(BarShapes),
75-
typeof(StorageBar),
76-
new PropertyMetadata(BarShapes.Round, (d, e) => ((StorageBar)d).OnBarShapeChanged((BarShapes)e.OldValue, (BarShapes)e.NewValue)));
77-
78-
/// <summary>
79-
/// Gets or sets an Enum value to choose from our two BarShapes. (Round, Flat)
80-
/// </summary>
81-
public BarShapes BarShape
82-
{
83-
get => (BarShapes)GetValue(BarShapeProperty);
84-
set => SetValue(BarShapeProperty, value);
85-
}
86-
8726
private void OnBarShapeChanged(BarShapes oldValue, BarShapes newValue)
8827
{
8928
UpdateControl(this);
9029
}
9130

92-
#endregion
93-
94-
#region Percent (double)
95-
96-
/// <summary>
97-
/// Identifies the Percent dependency property.
98-
/// </summary>
99-
public static readonly DependencyProperty PercentProperty =
100-
DependencyProperty.Register(
101-
nameof(Percent),
102-
typeof(double),
103-
typeof(StorageBar),
104-
new PropertyMetadata(0.0, (d, e) => ((StorageBar)d).OnPercentChanged((double)e.OldValue, (double)e.NewValue)));
105-
106-
/// <summary>
107-
/// Gets or sets the current value as a Percentage between 0.0 and 100.0.
108-
/// </summary>
109-
public double Percent
110-
{
111-
get => (double)GetValue(PercentProperty);
112-
set => SetValue(PercentProperty, value);
113-
}
114-
11531
private void OnPercentChanged(double oldValue, double newValue)
11632
{
11733
return; //Read-only
11834

11935
DoubleToPercentage(Value, Minimum, Maximum);
120-
12136
UpdateControl(this);
12237
}
12338

124-
#endregion
125-
126-
#region PercentWarning (double)
127-
128-
/// <summary>
129-
/// Identifies the PercentCaution dependency property.
130-
/// </summary>
131-
public static readonly DependencyProperty PercentCautionProperty =
132-
DependencyProperty.Register(
133-
nameof(PercentCaution),
134-
typeof(double),
135-
typeof(StorageBar),
136-
new PropertyMetadata(75.1, (d, e) => ((StorageBar)d).OnPercentCautionChanged((double)e.OldValue, (double)e.NewValue)));
137-
138-
/// <summary>
139-
/// Gets or sets the PercentCaution double value.
140-
/// </summary>
141-
public double PercentCaution
142-
{
143-
get => (double)GetValue(PercentCautionProperty);
144-
set => SetValue(PercentCautionProperty, value);
145-
}
146-
14739
private void OnPercentCautionChanged(double oldValue, double newValue)
14840
{
14941
UpdateControl(this);
15042
}
15143

152-
#endregion
153-
154-
#region PercentCritical (double)
155-
156-
/// <summary>
157-
/// Identifies the PercentCritical dependency property.
158-
/// </summary>
159-
public static readonly DependencyProperty PercentCriticalProperty =
160-
DependencyProperty.Register(
161-
nameof(PercentCritical),
162-
typeof(double),
163-
typeof(StorageBar),
164-
new PropertyMetadata(89.9, (d, e) => ((StorageBar)d).OnPercentCriticalChanged((double)e.OldValue, (double)e.NewValue)));
165-
166-
/// <summary>
167-
/// Gets or sets the PercentCritical double value.
168-
/// </summary>
169-
public double PercentCritical
170-
{
171-
get => (double)GetValue(PercentCriticalProperty);
172-
set => SetValue(PercentCriticalProperty, value);
173-
}
174-
17544
private void OnPercentCriticalChanged(double oldValue, double newValue)
17645
{
17746
UpdateControl(this);
17847
}
17948

180-
#endregion
181-
182-
#region Derived RangeBase Events
183-
18449
/// <inheritdoc/>
18550
protected override void OnValueChanged(double oldValue, double newValue)
18651
{
@@ -202,7 +67,5 @@ protected override void OnMinimumChanged(double oldValue, double newValue)
20267
base.OnMinimumChanged(oldValue, newValue);
20368
UpdateValue(this, oldValue, newValue, false, -1.0);
20469
}
205-
206-
#endregion
20770
}
20871
}

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,11 @@ namespace Files.App.Controls
1212
[TemplatePart(Name = ContainerPartName, Type = typeof(Grid))]
1313
[TemplatePart(Name = ValueRingShapePartName, Type = typeof(RingShape))]
1414
[TemplatePart(Name = TrackRingShapePartName, Type = typeof(RingShape))]
15-
16-
1715
// VisualStates
1816
[TemplateVisualState(Name = SafeStateName, GroupName = ControlStateGroupName)]
1917
[TemplateVisualState(Name = CautionStateName, GroupName = ControlStateGroupName)]
2018
[TemplateVisualState(Name = CriticalStateName, GroupName = ControlStateGroupName)]
2119
[TemplateVisualState(Name = DisabledStateName, GroupName = ControlStateGroupName)]
22-
23-
2420
public partial class StorageRing
2521
{
2622
internal const string ContainerPartName = "PART_Container";

0 commit comments

Comments
 (0)