Skip to content

Commit 75c8448

Browse files
authored
Code Quality: Replaced DP generator with WCT (#16922)
1 parent e8d44eb commit 75c8448

File tree

14 files changed

+213
-301
lines changed

14 files changed

+213
-301
lines changed

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<PackageVersion Include="ByteSize" Version="2.1.2" />
88
<PackageVersion Include="ColorCode.WinUI" Version="2.0.15" />
99
<PackageVersion Include="CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock" Version="0.1.250206-build.2040" />
10+
<PackageVersion Include="CommunityToolkit.Labs.WinUI.DependencyPropertyGenerator" Version="0.1.250206-build.2040" />
1011
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.0" />
1112
<PackageVersion Include="CommunityToolkit.WinUI.Behaviors" Version="8.2.250129-preview2" />
1213
<PackageVersion Include="CommunityToolkit.WinUI.Controls.ColorPicker" Version="8.2.250129-preview2" />

src/Files.App.Controls/Files.App.Controls.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
<ItemGroup>
1616
<PackageReference Include="CommunityToolkit.WinUI.Extensions" />
17+
<PackageReference Include="CommunityToolkit.Labs.WinUI.DependencyPropertyGenerator" />
1718
<PackageReference Include="Microsoft.WindowsAppSDK" />
1819
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" />
1920
<PackageReference Include="Microsoft.Windows.CsWinRT" />

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

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,85 @@
11
// Copyright (c) Files Community
22
// Licensed under the MIT License.
33

4+
using CommunityToolkit.WinUI;
45
using Microsoft.UI.Xaml;
56
using Microsoft.UI.Xaml.Media;
67
using Microsoft.UI.Xaml.Shapes;
78
using Windows.Foundation;
89

910
namespace Files.App.Controls.Primitives
1011
{
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 = "global::Microsoft.UI.Xaml.Media.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")]
2212
public partial class RingShape : Path
2313
{
24-
protected virtual void OnStartAngleChanged(double oldValue, double newValue)
14+
[GeneratedDependencyProperty(DefaultValue = 0.0d)]
15+
public partial double StartAngle { get; set; }
16+
17+
[GeneratedDependencyProperty(DefaultValue = 90.0d)]
18+
public partial double EndAngle { get; set; }
19+
20+
[GeneratedDependencyProperty(DefaultValue = SweepDirection.Clockwise)]
21+
public partial SweepDirection SweepDirection { get; set; }
22+
23+
[GeneratedDependencyProperty(DefaultValue = 0.0d)]
24+
public partial double MinAngle { get; set; }
25+
26+
[GeneratedDependencyProperty(DefaultValue = 360.0d)]
27+
public partial double MaxAngle { get; set; }
28+
29+
[GeneratedDependencyProperty(DefaultValue = 0.0d)]
30+
public partial double RadiusWidth { get; set; }
31+
32+
[GeneratedDependencyProperty(DefaultValue = 0.0d)]
33+
public partial double RadiusHeight { get; set; }
34+
35+
[GeneratedDependencyProperty]
36+
public partial bool IsCircle { get; set; }
37+
38+
[GeneratedDependencyProperty]
39+
public partial Point Center { get; set; }
40+
41+
[GeneratedDependencyProperty]
42+
public partial double ActualRadiusWidth { get; set; }
43+
44+
[GeneratedDependencyProperty]
45+
public partial double ActualRadiusHeight { get; set; }
46+
47+
partial void OnStartAngleChanged(double newValue)
2548
{
2649
StartAngleChanged();
2750
}
2851

29-
protected virtual void OnEndAngleChanged(double oldValue, double newValue)
52+
partial void OnEndAngleChanged(double newValue)
3053
{
3154
EndAngleChanged();
3255
}
3356

34-
protected virtual void OnSweepDirectionChanged(SweepDirection oldValue, SweepDirection newValue)
57+
partial void OnSweepDirectionChanged(SweepDirection newValue)
3558
{
3659
SweepDirectionChanged();
3760
}
3861

39-
protected virtual void OnMinAngleChanged(double oldValue, double newValue)
62+
partial void OnMinAngleChanged(double newValue)
4063
{
4164
MinMaxAngleChanged(false);
4265
}
4366

44-
protected virtual void OnMaxAngleChanged(double oldValue, double newValue)
67+
partial void OnMaxAngleChanged(double newValue)
4568
{
4669
MinMaxAngleChanged(true);
4770
}
4871

49-
protected virtual void OnRadiusWidthChanged(double oldValue, double newValue)
72+
partial void OnRadiusWidthChanged(double newValue)
5073
{
5174
RadiusWidthChanged();
5275
}
5376

54-
protected virtual void OnRadiusHeightChanged(double oldValue, double newValue)
77+
partial void OnRadiusHeightChanged(double newValue)
5578
{
5679
RadiusHeightChanged();
5780
}
5881

59-
protected virtual void OnIsCircleChanged(bool oldValue, bool newValue)
82+
partial void OnIsCircleChanged(bool newValue)
6083
{
6184
IsCircleChanged();
6285
}

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

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,60 @@
11
// Copyright (c) Files Community
22
// Licensed under the MIT License.
33

4+
using CommunityToolkit.WinUI;
45
using Microsoft.UI.Xaml;
56

67
namespace Files.App.Controls
78
{
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")]
149
public partial class StorageBar
1510
{
16-
private void OnValueBarHeightChanged(double oldValue, double newValue)
11+
[GeneratedDependencyProperty(DefaultValue = 4.0d)]
12+
public partial double ValueBarHeight { get; set; }
13+
14+
[GeneratedDependencyProperty(DefaultValue = 2.0d)]
15+
public partial double TrackBarHeight { get; set; }
16+
17+
[GeneratedDependencyProperty(DefaultValue = BarShapes.Round)]
18+
public partial BarShapes BarShape { get; set; }
19+
20+
[GeneratedDependencyProperty(DefaultValue = 0.0d)]
21+
public partial double Percent { get; set; }
22+
23+
[GeneratedDependencyProperty(DefaultValue = 75.1d)]
24+
public partial double PercentCaution { get; set; }
25+
26+
[GeneratedDependencyProperty(DefaultValue = 89.9d)]
27+
public partial double PercentCritical { get; set; }
28+
29+
partial void OnValueBarHeightChanged(double newValue)
1730
{
1831
UpdateControl(this);
1932
}
2033

21-
private void OnTrackBarHeightChanged(double oldValue, double newValue)
34+
partial void OnTrackBarHeightChanged(double newValue)
2235
{
2336
UpdateControl(this);
2437
}
2538

26-
private void OnBarShapeChanged(BarShapes oldValue, BarShapes newValue)
39+
partial void OnBarShapeChanged(BarShapes newValue)
2740
{
2841
UpdateControl(this);
2942
}
3043

31-
private void OnPercentChanged(double oldValue, double newValue)
44+
partial void OnPercentChanged(double newValue)
3245
{
3346
return; //Read-only
3447

3548
DoubleToPercentage(Value, Minimum, Maximum);
3649
UpdateControl(this);
3750
}
3851

39-
private void OnPercentCautionChanged(double oldValue, double newValue)
52+
partial void OnPercentCautionChanged(double newValue)
4053
{
4154
UpdateControl(this);
4255
}
4356

44-
private void OnPercentCriticalChanged(double oldValue, double newValue)
57+
partial void OnPercentCriticalChanged(double newValue)
4558
{
4659
UpdateControl(this);
4760
}

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

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,78 @@
11
// Copyright (c) Files Community
22
// Licensed under the MIT License.
33

4+
using CommunityToolkit.WinUI;
45
using Microsoft.UI.Xaml;
56

67
namespace Files.App.Controls
78
{
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")]
15-
[DependencyProperty<double>("PercentCritical", nameof(OnPercentCriticalChanged), DefaultValue = "(double)90.01")]
16-
[DependencyProperty<double>("ValueAngle")]
17-
[DependencyProperty<double>("AdjustedSize", DefaultValue = "(double)16.0")]
189
public partial class StorageRing
1910
{
20-
private void OnValueRingThicknessChanged(double oldValue, double newValue)
11+
[GeneratedDependencyProperty(DefaultValue = 0.0d)]
12+
public partial double ValueRingThickness { get; set; }
13+
14+
[GeneratedDependencyProperty(DefaultValue = 0.0d)]
15+
public partial double TrackRingThickness { get; set; }
16+
17+
[GeneratedDependencyProperty(DefaultValue = 0.0d)]
18+
public partial double MinAngle { get; set; }
19+
20+
[GeneratedDependencyProperty(DefaultValue = 360.0d)]
21+
public partial double MaxAngle { get; set; }
22+
23+
[GeneratedDependencyProperty(DefaultValue = 0.0d)]
24+
public partial double StartAngle { get; set; }
25+
26+
[GeneratedDependencyProperty]
27+
public partial double Percent { get; set; }
28+
29+
[GeneratedDependencyProperty(DefaultValue = 75.01d)]
30+
public partial double PercentCaution { get; set; }
31+
32+
[GeneratedDependencyProperty(DefaultValue = 90.01d)]
33+
public partial double PercentCritical { get; set; }
34+
35+
[GeneratedDependencyProperty]
36+
public partial double ValueAngle { get; set; }
37+
38+
[GeneratedDependencyProperty(DefaultValue = 16.0d)]
39+
public partial double AdjustedSize { get; set; }
40+
41+
partial void OnValueRingThicknessChanged(double newValue)
2142
{
2243
UpdateRingThickness(this, newValue, false);
2344
UpdateRings(this);
2445
}
2546

26-
private void OnTrackRingThicknessChanged(double oldValue, double newValue)
47+
partial void OnTrackRingThicknessChanged(double newValue)
2748
{
2849
UpdateRingThickness(this, newValue, true);
2950
UpdateRings(this);
3051
}
3152

32-
private void OnMinAngleChanged(double oldValue, double newValue)
53+
partial void OnMinAngleChanged(double newValue)
3354
{
3455
UpdateValues(this, Value, _oldValue, false, -1.0);
3556
CalculateAndSetNormalizedAngles(this, newValue, MaxAngle);
3657
UpdateRings(this);
3758
}
3859

39-
private void OnMaxAngleChanged(double oldValue, double newValue)
60+
partial void OnMaxAngleChanged(double newValue)
4061
{
4162
UpdateValues(this, Value, _oldValue, false, -1.0);
4263
CalculateAndSetNormalizedAngles(this, MinAngle, newValue);
4364
UpdateRings(this);
4465
}
4566

46-
private void OnStartAngleChanged(double oldValue, double newValue)
67+
partial void OnStartAngleChanged(double newValue)
4768
{
4869
UpdateValues(this, Value, _oldValue, false, -1.0);
4970
CalculateAndSetNormalizedAngles(this, MinAngle, newValue);
5071
ValidateStartAngle(this, newValue);
5172
UpdateRings(this);
5273
}
5374

54-
private void OnPercentChanged(double oldValue, double newValue)
75+
partial void OnPercentChanged(double newValue)
5576
{
5677
return; //Read-only
5778

@@ -71,14 +92,14 @@ private void OnPercentChanged(double oldValue, double newValue)
7192
UpdateRings(this);
7293
}
7394

74-
private void OnPercentCautionChanged(double oldValue, double newValue)
95+
partial void OnPercentCautionChanged(double newValue)
7596
{
7697
UpdateValues(this, Value, _oldValue, false, -1.0);
7798
UpdateVisualState(this);
7899
UpdateRings(this);
79100
}
80101

81-
private void OnPercentCriticalChanged(double oldValue, double newValue)
102+
partial void OnPercentCriticalChanged(double newValue)
82103
{
83104
UpdateValues(this, Value, _oldValue, false, -1.0);
84105
UpdateVisualState(this);

0 commit comments

Comments
 (0)