Skip to content

Commit e6e4ede

Browse files
committed
Refactor 6
1 parent 58d1413 commit e6e4ede

File tree

4 files changed

+103
-236
lines changed

4 files changed

+103
-236
lines changed

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

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -177,37 +177,26 @@ ArcSegment CreateArcSegment(double radiusWidth, double radiusHeight)
177177
new(
178178
Center.X - Math.Sin(EndAngle * DegreesToRadians) * radiusWidth,
179179
Center.Y - Math.Cos(EndAngle * DegreesToRadians) * radiusHeight);
180-
181-
if (EndAngle < StartAngle)
182-
{
183-
finalArcSegment.IsLargeArc = (EndAngle - StartAngle) <= -180.0;
184-
finalArcSegment.SweepDirection = SweepDirection.Clockwise;
185-
}
186-
else
187-
{
188-
finalArcSegment.IsLargeArc = (EndAngle - StartAngle) >= 180.0;
189-
finalArcSegment.SweepDirection = SweepDirection.Counterclockwise;
190-
}
191180
}
192181
else
193182
{
194183
finalArcSegment.Point =
195184
new(
196185
Center.X + Math.Sin(EndAngle * DegreesToRadians) * radiusWidth,
197186
Center.Y - Math.Cos(EndAngle * DegreesToRadians) * radiusHeight);
187+
}
198188

199-
//ArcSegment.IsLargeArc = (EndAngle - StartAngle) >= 180.0;
200-
201-
if (EndAngle < StartAngle)
202-
{
203-
finalArcSegment.IsLargeArc = (EndAngle - StartAngle) <= -180.0;
204-
finalArcSegment.SweepDirection = SweepDirection.Counterclockwise;
205-
}
206-
else
207-
{
208-
finalArcSegment.IsLargeArc = (EndAngle - StartAngle) >= 180.0;
209-
finalArcSegment.SweepDirection = SweepDirection.Clockwise;
210-
}
189+
if (EndAngle < StartAngle)
190+
{
191+
finalArcSegment.IsLargeArc = (EndAngle - StartAngle) <= -180.0;
192+
finalArcSegment.SweepDirection = SweepDirection is SweepDirection.Clockwise
193+
? SweepDirection.Counterclockwise
194+
: SweepDirection.Clockwise;
195+
}
196+
else
197+
{
198+
finalArcSegment.IsLargeArc = (EndAngle - StartAngle) >= 180.0;
199+
finalArcSegment.SweepDirection = SweepDirection;
211200
}
212201

213202
finalArcSegment.Size = new(radiusWidth, radiusHeight);

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

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,57 +15,90 @@ public partial class StorageBar
1515
{
1616
private void OnValueBarHeightChanged(double oldValue, double newValue)
1717
{
18-
UpdateControl(this);
18+
UpdateControl();
1919
}
2020

2121
private void OnTrackBarHeightChanged(double oldValue, double newValue)
2222
{
23-
UpdateControl(this);
23+
UpdateControl();
2424
}
2525

2626
private void OnBarShapeChanged(BarShapes oldValue, BarShapes newValue)
2727
{
28-
UpdateControl(this);
28+
UpdateControl();
2929
}
3030

3131
private void OnPercentChanged(double oldValue, double newValue)
3232
{
3333
return; //Read-only
3434

3535
DoubleToPercentage(Value, Minimum, Maximum);
36-
UpdateControl(this);
36+
UpdateControl();
3737
}
3838

3939
private void OnPercentCautionChanged(double oldValue, double newValue)
4040
{
41-
UpdateControl(this);
41+
UpdateControl();
4242
}
4343

4444
private void OnPercentCriticalChanged(double oldValue, double newValue)
4545
{
46-
UpdateControl(this);
46+
UpdateControl();
4747
}
4848

4949
/// <inheritdoc/>
5050
protected override void OnValueChanged(double oldValue, double newValue)
5151
{
5252
_oldValue = oldValue;
5353
base.OnValueChanged(oldValue, newValue);
54-
UpdateValue(this, Value, _oldValue, false, -1.0);
54+
UpdateValue(Value, _oldValue, false, -1.0);
5555
}
5656

5757
/// <inheritdoc/>
5858
protected override void OnMaximumChanged(double oldValue, double newValue)
5959
{
6060
base.OnMaximumChanged(oldValue, newValue);
61-
UpdateValue(this, oldValue, newValue, false, -1.0);
61+
UpdateValue(oldValue, newValue, false, -1.0);
6262
}
6363

6464
/// <inheritdoc/>
6565
protected override void OnMinimumChanged(double oldValue, double newValue)
6666
{
6767
base.OnMinimumChanged(oldValue, newValue);
68-
UpdateValue(this, oldValue, newValue, false, -1.0);
68+
UpdateValue(oldValue, newValue, false, -1.0);
69+
}
70+
71+
private void StorageBar_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
72+
{
73+
UpdateControl();
74+
}
75+
76+
private void StorageBar_Unloaded(object sender, RoutedEventArgs e)
77+
{
78+
SizeChanged -= StorageBar_SizeChanged;
79+
Unloaded -= StorageBar_Unloaded;
80+
IsEnabledChanged -= StorageBar_IsEnabledChanged;
81+
}
82+
83+
private void StorageBar_SizeChanged(object sender, SizeChangedEventArgs e)
84+
{
85+
Size minSize;
86+
87+
if (DesiredSize.Width < MinWidth || DesiredSize.Height < MinHeight ||
88+
e.NewSize.Width < MinWidth || e.NewSize.Height < MinHeight)
89+
{
90+
Width = MinWidth;
91+
Height = MinHeight;
92+
93+
minSize = new(MinWidth, MinHeight);
94+
}
95+
else
96+
{
97+
minSize = e.NewSize;
98+
}
99+
100+
UpdateContainer(minSize);
101+
UpdateControl();
69102
}
70103
}
71104
}

0 commit comments

Comments
 (0)