diff --git a/src/Files.App.Controls/Files.App.Controls.csproj b/src/Files.App.Controls/Files.App.Controls.csproj index e7acc8b0cbda..081f8b2e7e80 100644 --- a/src/Files.App.Controls/Files.App.Controls.csproj +++ b/src/Files.App.Controls/Files.App.Controls.csproj @@ -1,4 +1,4 @@ - + @@ -26,23 +26,4 @@ - - - - - - - - - - - - - - - - MSBuild:Compile - - - diff --git a/src/Files.App.Controls/Storage/RingShape/RingShape.Properties.cs b/src/Files.App.Controls/Storage/RingShape/RingShape.Properties.cs index 8250d4f50e46..d20e544ba8b4 100644 --- a/src/Files.App.Controls/Storage/RingShape/RingShape.Properties.cs +++ b/src/Files.App.Controls/Storage/RingShape/RingShape.Properties.cs @@ -8,364 +8,57 @@ namespace Files.App.Controls.Primitives { + [DependencyProperty("StartAngle", nameof(OnStartAngleChanged), DefaultValue = "(double)0.0")] + [DependencyProperty("EndAngle", nameof(OnEndAngleChanged), DefaultValue = "(double)90.0")] + [DependencyProperty("SweepDirection", nameof(OnSweepDirectionChanged), DefaultValue = "global::Microsoft.UI.Xaml.Media.SweepDirection.Clockwise")] + [DependencyProperty("MinAngle", nameof(OnMinAngleChanged), DefaultValue = "(double)0.0")] + [DependencyProperty("MaxAngle", nameof(OnMaxAngleChanged), DefaultValue = "(double)360.0")] + [DependencyProperty("RadiusWidth", nameof(OnRadiusWidthChanged), DefaultValue = "(double)0.0")] + [DependencyProperty("RadiusHeight", nameof(OnRadiusHeightChanged), DefaultValue = "(double)0.0")] + [DependencyProperty("IsCircle", nameof(OnIsCircleChanged), DefaultValue = "(bool)false")] + [DependencyProperty("Center")] + [DependencyProperty("ActualRadiusWidth")] + [DependencyProperty("ActualRadiusHeight")] public partial class RingShape : Path { - #region StartAngle (double) - - /// - /// The Start Angle property. - /// - public static readonly DependencyProperty StartAngleProperty = - DependencyProperty.Register( - nameof(StartAngle), - typeof(double), - typeof(RingShape), - new PropertyMetadata(0.0, OnStartAngleChanged)); - - /// - /// Gets or sets the start angle. - /// - /// - /// The start angle. - /// - public double StartAngle + protected virtual void OnStartAngleChanged(double oldValue, double newValue) { - get => (double)GetValue(StartAngleProperty); - set => SetValue(StartAngleProperty, value); + StartAngleChanged(); } - /// - /// Function invoked as the StartAngleProperty is changed - /// - /// The DependencyObject which holds the DependencyProperty - /// DependencyPropertyChangedEventArgs - private static void OnStartAngleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + protected virtual void OnEndAngleChanged(double oldValue, double newValue) { - RingShape ringShape = (RingShape)d; - - ringShape.StartAngleChanged(d, (double)e.NewValue); + EndAngleChanged(); } - #endregion - - #region EndAngle (double) - - /// - /// The End Angle property. - /// - public static readonly DependencyProperty EndAngleProperty = - DependencyProperty.Register( - nameof(EndAngle), - typeof(double), - typeof(RingShape), - new PropertyMetadata(90.0, OnEndAngleChanged)); - - /// - /// Gets or sets the end angle. - /// - /// - /// The end angle. - /// - public double EndAngle + protected virtual void OnSweepDirectionChanged(SweepDirection oldValue, SweepDirection newValue) { - get => (double)GetValue(EndAngleProperty); - set => SetValue(EndAngleProperty, value); + SweepDirectionChanged(); } - /// - /// Function invoked as the EndAngleProperty is changed - /// - /// The DependencyObject which holds the DependencyProperty - /// DependencyPropertyChangedEventArgs - private static void OnEndAngleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + protected virtual void OnMinAngleChanged(double oldValue, double newValue) { - RingShape ringShape = (RingShape)d; - - ringShape.EndAngleChanged(d, (double)e.NewValue); + MinMaxAngleChanged(false); } - #endregion - - #region SweepDirection (SweepDirection) - - /// - /// The SweepDirection property. - /// - public static readonly DependencyProperty SweepDirectionProperty = - DependencyProperty.Register( - nameof(SweepDirection), - typeof(SweepDirection), - typeof(RingShape), - new PropertyMetadata( - SweepDirection.Clockwise, OnSweepDirectionChanged)); - - /// - /// Gets or sets the SweepDirection. - /// - /// - /// The SweepDirection. - /// - public SweepDirection SweepDirection + protected virtual void OnMaxAngleChanged(double oldValue, double newValue) { - get => (SweepDirection)GetValue(SweepDirectionProperty); - set => SetValue(SweepDirectionProperty, value); + MinMaxAngleChanged(true); } - /// - /// Function invoked as the SweepDirectionProperty is changed - /// - /// The DependencyObject which holds the DependencyProperty - /// DependencyPropertyChangedEventArgs - private static void OnSweepDirectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + protected virtual void OnRadiusWidthChanged(double oldValue, double newValue) { - RingShape ringShape = (RingShape)d; - - ringShape.SweepDirectionChanged(d, (SweepDirection)e.NewValue); + RadiusWidthChanged(); } - #endregion - - #region MinAngle (double) - - /// - /// Identifies the MinAngle dependency property. - /// - public static readonly DependencyProperty MinAngleProperty = - DependencyProperty.Register( - nameof(MinAngle), - typeof(double), - typeof(RingShape), - new PropertyMetadata(0.0, OnMinAngleChanged)); - - /// - /// Gets or sets the MinAngle - /// - public double MinAngle + protected virtual void OnRadiusHeightChanged(double oldValue, double newValue) { - get => (double)GetValue(MinAngleProperty); - set => SetValue(MinAngleProperty, value); + RadiusHeightChanged(); } - /// - /// Function invoked as the MinAngleProperty is changed - /// - /// The DependencyObject which holds the DependencyProperty - /// DependencyPropertyChangedEventArgs - private static void OnMinAngleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + protected virtual void OnIsCircleChanged(bool oldValue, bool newValue) { - RingShape ringShape = (RingShape)d; - - ringShape.MinMaxAngleChanged(d, (double)e.NewValue, false); + IsCircleChanged(); } - - #endregion - - #region MaxAngle (double) - - /// - /// Identifies the MinAngle dependency property. - /// - public static readonly DependencyProperty MaxAngleProperty = - DependencyProperty.Register( - nameof(MaxAngle), - typeof(double), - typeof(RingShape), - new PropertyMetadata(360.0, OnMaxAngleChanged)); - - /// - /// Gets or sets the MaxAngle - /// - public double MaxAngle - { - get => (double)GetValue(MaxAngleProperty); - set => SetValue(MaxAngleProperty, value); - } - - /// - /// Function invoked as the MaxAngleProperty is changed - /// - /// The DependencyObject which holds the DependencyProperty - /// DependencyPropertyChangedEventArgs - private static void OnMaxAngleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - RingShape ringShape = (RingShape)d; - - ringShape.MinMaxAngleChanged(ringShape, (double)e.NewValue, true); - } - - #endregion - - #region RadiusWidth (double) - - /// - /// Identifies the RadiusWidth dependency property. - /// - public static readonly DependencyProperty RadiusWidthProperty = - DependencyProperty.Register( - nameof(RadiusWidth), - typeof(double), - typeof(RingShape), - new PropertyMetadata(0.0, OnRadiusWidthChanged)); - - /// - /// Gets or sets the Radius along the Width of the shape - /// - public double RadiusWidth - { - get => (double)GetValue(RadiusWidthProperty); - set => SetValue(RadiusWidthProperty, value); - } - - /// - /// Function invoked as the RadiusWidthProperty is changed - /// - /// The DependencyObject which holds the DependencyProperty - /// DependencyPropertyChangedEventArgs - private static void OnRadiusWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - RingShape ringShape = (RingShape)d; - - ringShape.RadiusWidthChanged(d, (double)e.NewValue); - } - - #endregion - - #region RadiusHeight (double) - - /// - /// Identifies the RadiusHeight dependency property. - /// - public static readonly DependencyProperty RadiusHeightProperty = - DependencyProperty.Register( - nameof(RadiusHeight), - typeof(double), - typeof(RingShape), - new PropertyMetadata(0.0, OnRadiusHeightChanged)); - - /// - /// Gets or sets the Radius along the Height of the shape - /// - public double RadiusHeight - { - get => (double)GetValue(RadiusHeightProperty); - set => SetValue(RadiusHeightProperty, value); - } - - /// - /// Function invoked as the RadiusHeightProperty is changed - /// - /// The DependencyObject which holds the DependencyProperty - /// DependencyPropertyChangedEventArgs - private static void OnRadiusHeightChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - RingShape ringShape = (RingShape)d; - - ringShape.RadiusHeightChanged(d, (double)e.NewValue); - } - #endregion - - #region IsCircle (bool) - - /// - /// Identifies the property. - /// - public static readonly DependencyProperty IsCircleProperty = - DependencyProperty.Register( - nameof(IsCircle), - typeof(bool), - typeof(RingShape), - new PropertyMetadata(false, OnIsCircleChanged)); - - /// - /// Gets or sets a value indicating whether the shape should be constrained as a Circle. - /// - public bool IsCircle - { - get => (bool)GetValue(IsCircleProperty); - set => SetValue(IsCircleProperty, value); - } - - /// - /// Function invoked as the IsCircleProperty is changed - /// - /// The DependencyObject which holds the DependencyProperty - /// DependencyPropertyChangedEventArgs - private static void OnIsCircleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - RingShape ringShape = (RingShape)d; - - ringShape.IsCircleChanged(d, (bool)e.NewValue); - } - - #endregion - - #region Protected Centre (Point) - - /// - /// Identifies the Protected Center dependency property. - /// - protected static readonly DependencyProperty CenterProperty = - DependencyProperty.Register( - nameof(Center), - typeof(Point), - typeof(RingShape), - new PropertyMetadata(null)); - - /// - /// Gets or sets the Center point - /// - protected Point Center - { - get => (Point)GetValue(CenterProperty); - set => SetValue(CenterProperty, value); - } - - #endregion - - #region Protected ActualRadiusWidth (double) - - /// - /// Identifies the Protected ActualRadiusWidth dependency property. - /// - protected static readonly DependencyProperty ActualRadiusWidthProperty = - DependencyProperty.Register( - nameof(ActualRadiusWidth), - typeof(double), - typeof(RingShape), - new PropertyMetadata(null)); - - /// - /// Gets or sets the ActualRadiusWidth double value - /// - protected double ActualRadiusWidth - { - get => (double)GetValue(ActualRadiusWidthProperty); - set => SetValue(ActualRadiusWidthProperty, value); - } - - #endregion - - #region Protected ActualRadiusHeight (double) - - /// - /// Identifies the Protected ActualRadiusHeight dependency property. - /// - protected static readonly DependencyProperty ActualRadiusHeightProperty = - DependencyProperty.Register( - nameof(ActualRadiusHeight), - typeof(double), - typeof(RingShape), - new PropertyMetadata(null)); - - /// - /// Gets or sets the ActualRadiusHeight double value - /// - protected double ActualRadiusHeight - { - get => (double)GetValue(ActualRadiusHeightProperty); - set => SetValue(ActualRadiusHeightProperty, value); - } - - #endregion } } diff --git a/src/Files.App.Controls/Storage/RingShape/RingShape.cs b/src/Files.App.Controls/Storage/RingShape/RingShape.cs index 292a03536cf2..b3f32df14b14 100644 --- a/src/Files.App.Controls/Storage/RingShape/RingShape.cs +++ b/src/Files.App.Controls/Storage/RingShape/RingShape.cs @@ -10,8 +10,7 @@ namespace Files.App.Controls.Primitives { /// - /// RingShape - Primitive Path shape for drawing a - /// circular or elliptical Ring. + /// Represents primitive Path shape for drawing a circular or elliptical ring. /// public partial class RingShape : Path { @@ -32,12 +31,10 @@ public partial class RingShape : Path private double _radiusHeight; // The radius Height private SweepDirection _sweepDirection; // The SweepDirection - // Constants private const double DegreesToRadians = Math.PI / 180; - // Constructor /// @@ -46,7 +43,6 @@ public partial class RingShape : Path public RingShape() { SizeChanged += RingShape_SizeChanged; - RegisterPropertyChangedCallback(StrokeThicknessProperty, OnStrokeThicknessChanged); } @@ -54,106 +50,65 @@ public RingShape() #region PropertyChanged Events - private void StartAngleChanged(DependencyObject d, double newStartAngle) + private void StartAngleChanged() { - RingShape ringShape = (RingShape)d; - - ringShape.BeginUpdate(); - - ValidateAngle(ringShape, newStartAngle, true); - - ringShape.EndUpdate(); + BeginUpdate(); + ValidateAngle(this, StartAngle, true); + EndUpdate(); } - private void EndAngleChanged(DependencyObject d, double newEndAngle) + private void EndAngleChanged() { - RingShape ringShape = (RingShape)d; - - ringShape.BeginUpdate(); - - ValidateAngle(ringShape, newEndAngle, false); - - ringShape.EndUpdate(); + BeginUpdate(); + ValidateAngle(this, EndAngle, false); + EndUpdate(); } - private void IsCircleChanged(DependencyObject d, bool isCircle) + private void IsCircleChanged() { - RingShape ringShape = (RingShape)d; - - ringShape.BeginUpdate(); - - _isCircle = isCircle; - - ringShape.EndUpdate(); + BeginUpdate(); + _isCircle = IsCircle; + EndUpdate(); } - private void RadiusWidthChanged(DependencyObject d, double radiusWidth) + private void RadiusWidthChanged() { - RingShape ringShape = (RingShape)d; - - ringShape.BeginUpdate(); - - AdjustRadiusWidth(ringShape, radiusWidth, ringShape.StrokeThickness); - - ringShape.EndUpdate(); + BeginUpdate(); + AdjustRadiusWidth(this, RadiusWidth, StrokeThickness); + EndUpdate(); } - private void RadiusHeightChanged(DependencyObject d, double radiusHeight) + private void RadiusHeightChanged() { - RingShape ringShape = (RingShape)d; - - ringShape.BeginUpdate(); - - AdjustRadiusHeight(ringShape, radiusHeight, ringShape.StrokeThickness); - - ringShape.EndUpdate(); + BeginUpdate(); + AdjustRadiusHeight(this, RadiusHeight, StrokeThickness); + EndUpdate(); } private void RingShape_SizeChanged(object obj, SizeChangedEventArgs e) { - RingShape ringShape = (RingShape)obj; - - ringShape.BeginUpdate(); - - ringShape.EndUpdate(); + BeginUpdate(); + EndUpdate(); } private void OnStrokeThicknessChanged(DependencyObject d, DependencyProperty dp) { - RingShape ringShape = (RingShape)d; - - ringShape.BeginUpdate(); - - ringShape.EndUpdate(); + BeginUpdate(); + EndUpdate(); } - private void MinMaxAngleChanged(DependencyObject d, double newAngle, bool isMax) + private void MinMaxAngleChanged(bool isMax) { - RingShape ringShape = (RingShape)d; - - ringShape.BeginUpdate(); - - if (isMax) - { - CalculateAndSetNormalizedAngles(ringShape, ringShape.MinAngle, newAngle); - } - else - { - CalculateAndSetNormalizedAngles(ringShape, newAngle, ringShape.MaxAngle); - } - - ringShape.EndUpdate(); + BeginUpdate(); + CalculateAndSetNormalizedAngles(this, MinAngle, MaxAngle); + EndUpdate(); } - private void SweepDirectionChanged(DependencyObject d, SweepDirection newSweepDirection) + private void SweepDirectionChanged() { - RingShape ringShape = (RingShape)d; - - ringShape.BeginUpdate(); - - _sweepDirection = newSweepDirection; - - ringShape.EndUpdate(); + BeginUpdate(); + _sweepDirection = SweepDirection; + EndUpdate(); } #endregion @@ -174,21 +129,15 @@ public void BeginUpdate() public void EndUpdate() { _isUpdating = false; - UpdatePath(); } - /// - /// Updates the RingShape path - /// private void UpdatePath() { if (_isUpdating || ActualWidth <= 0 || ActualHeight <= 0 || _radiusWidth <= 0 || _radiusHeight <= 0) - { return; - } UpdateSizeAndStroke(this); @@ -234,15 +183,6 @@ public void UpdateSizeAndStroke(DependencyObject d) ValidateAngle( ringShape , ringShape.EndAngle , false ); } - /// - /// Draws an EllipseGeometry Ring - /// - /// - /// - /// - /// - /// - /// EllipseGeometry private static EllipseGeometry DrawEllipse(bool IsCircle, Point Center, double EqualRadius, double RadiusWidth, double RadiusHeight) { EllipseGeometry eg; @@ -269,19 +209,6 @@ private static EllipseGeometry DrawEllipse(bool IsCircle, Point Center, double E return eg; } - /// - /// Draws the Arc as PathGeometry - /// - /// The RingShape calling this method - /// The SweepDirection for the Arc - /// True if the Path is to be a Circle - /// The Center Point - /// The Start Angle - /// The End Angle - /// The equalised Radius (for circles) - /// The Radius Width - /// The Radius Height - /// Path Geometry private static PathGeometry DrawArc(RingShape RingShape, SweepDirection SweepDirection, bool IsCircle, Point Center, double StartAngle, double EndAngle, double EqualRadius, double RadiusWidth, double RadiusHeight) { var pathGeometry = new PathGeometry(); @@ -329,15 +256,6 @@ private static PathGeometry DrawArc(RingShape RingShape, SweepDirection SweepDir return pathGeometry; } - /// - /// Calculates the StartPoint for the Arc - /// - /// SweepDirection for the Arc - /// Center point for the Arc - /// Start Angle for the Arc - /// Radius Width for the Arc - /// Radius Height for the Arc - /// Start Point for the Arc private static Point ArcStartPoint(SweepDirection SweepDirection , Point Center, double StartAngle , double RadiusWidth, double RadiusHeight) { var finalPoint = new Point(); @@ -362,16 +280,6 @@ private static Point ArcStartPoint(SweepDirection SweepDirection , Point Center, return finalPoint; } - /// - /// Generates an ArcSegment for the RingShape Path Data - /// - /// SweepDirection for the Arc - /// Center point for the Arc - /// Start Angle for the Arc - /// End Angle for the Arc - /// Radius Width for the Arc - /// Radius Height for the Arc - /// ArcSegment for the RingShape Path Data private static ArcSegment CreateArcSegment(SweepDirection SweepDirection , Point Center , double StartAngle, double EndAngle , double RadiusWidth , double RadiusHeight) { var finalArcSegment = new ArcSegment(); @@ -423,13 +331,6 @@ private static ArcSegment CreateArcSegment(SweepDirection SweepDirection , Point #region Value Calculations - /// - /// Calculates the EqualSize taking the smaller of the given Size's - /// Width and Height - /// - /// The Size we want to use for calculating - /// The StrokeThickness value - /// The calculated EqualizedSize private static Size CalculateEqualSize(Size size, double strokeThickness) { double adjWidth = size.Width; @@ -447,15 +348,6 @@ private static Size CalculateEqualSize(Size size, double strokeThickness) } } - /// - /// Calculates the smaller of the RadiusWidth and RadiusHeight when both - /// should be the same value. - /// - /// The DependencyObject calling the function - /// The RadiusWidth value - /// The RadiusHeight value - /// The StrokeThickness value - /// The calculated EqualRadius private static double CalculateEqualRadius(DependencyObject d, double radiusWidth, double radiusHeight, double strokeThickness) { RingShape ringShape = (RingShape)d; @@ -479,12 +371,6 @@ private static double CalculateEqualRadius(DependencyObject d, double radiusWidt } } - /// - /// Calculates the center point based on half the Width and Height - /// - /// The Width value - /// The Height value - /// The calculated Center Point private static Point CalculateCenter(double Width, double Height) { Point calculatedCenter = new Point((Width / 2.0), (Height / 2.0)); @@ -492,12 +378,6 @@ private static Point CalculateCenter(double Width, double Height) return calculatedCenter; } - /// - /// Calculates and Sets the normalized Min and Max Angles - /// - /// The DependencyObject calling the function - /// MinAngle in the range from -180 to 180. - /// MaxAngle, in the range from -180 to 540. private static void CalculateAndSetNormalizedAngles(DependencyObject d, double minAngle, double maxAngle) { RingShape ringShape = (RingShape)d; @@ -505,35 +385,22 @@ private static void CalculateAndSetNormalizedAngles(DependencyObject d, double m var result = CalculateModulus(minAngle, 360); if (result >= 180) - { result = result - 360; - } ringShape._normalizedMinAngle = result; result = CalculateModulus(maxAngle, 360); if (result < 180) - { result = result + 360; - } if (result > ringShape._normalizedMinAngle + 360) - { result = result - 360; - } ringShape._normalizedMaxAngle = result; } - /// - /// Calculates the modulus of a number with respect to a divider. - /// The result is always positive or zero, regardless of the input values. - /// - /// The input number. - /// The divider (non-zero). - /// The positive modulus result. private static double CalculateModulus(double number, double divider) { // Calculate the modulus @@ -545,12 +412,6 @@ private static double CalculateModulus(double number, double divider) return result; } - /// - /// - /// - /// The DependencyObject calling the function - /// The Angle to validate - /// Bool to check if we are validating Start or End angle private void ValidateAngle(DependencyObject d, double angle, bool isStart) { RingShape ringShape = (RingShape)d; @@ -590,12 +451,6 @@ private void ValidateAngle(DependencyObject d, double angle, bool isStart) } } - /// - /// Adjust the RadiusWidth to fit within the bounds - /// - /// The DependencyObject calling the function - /// The RadiusWidth to adjust - /// The Stroke Thickness private void AdjustRadiusWidth(DependencyObject d, double radiusWidth, double strokeThickness) { RingShape ringShape = (RingShape)d; @@ -617,12 +472,6 @@ private void AdjustRadiusWidth(DependencyObject d, double radiusWidth, double st } } - /// - /// Adjust the RadiusHeight to fit within the bounds - /// - /// The DependencyObject calling the function - /// The RadiusHeight to adjust - /// The Stroke Thickness private void AdjustRadiusHeight(DependencyObject d, double radiusHeight, double strokeThickness) { RingShape ringShape = (RingShape)d; diff --git a/src/Files.App.Controls/Storage/StorageBar/StorageBar.Constants.cs b/src/Files.App.Controls/Storage/StorageBar/StorageBar.Constants.cs index 0325b0543863..6e0c51f8cf3a 100644 --- a/src/Files.App.Controls/Storage/StorageBar/StorageBar.Constants.cs +++ b/src/Files.App.Controls/Storage/StorageBar/StorageBar.Constants.cs @@ -9,14 +9,11 @@ namespace Files.App.Controls { // TemplateParts [TemplatePart(Name = ContainerPartName, Type = typeof(Grid))] - [TemplatePart(Name = ValueColumnPartName, Type = typeof(ColumnDefinition))] [TemplatePart(Name = GapColumnPartName, Type = typeof(ColumnDefinition))] [TemplatePart(Name = TrackColumnPartName, Type = typeof(ColumnDefinition))] - [TemplatePart(Name = ValueBorderPartName, Type = typeof(Border))] [TemplatePart(Name = TrackBorderPartName, Type = typeof(Border))] - // VisualStates [TemplateVisualState(Name = SafeStateName, GroupName = ControlStateGroupName)] [TemplateVisualState(Name = CautionStateName, GroupName = ControlStateGroupName)] diff --git a/src/Files.App.Controls/Storage/StorageBar/StorageBar.Properties.cs b/src/Files.App.Controls/Storage/StorageBar/StorageBar.Properties.cs index 1c426ad06fb5..18b20e03f213 100644 --- a/src/Files.App.Controls/Storage/StorageBar/StorageBar.Properties.cs +++ b/src/Files.App.Controls/Storage/StorageBar/StorageBar.Properties.cs @@ -5,182 +5,47 @@ namespace Files.App.Controls { + [DependencyProperty("ValueBarHeight", nameof(OnValueBarHeightChanged), DefaultValue = "(double)4.0")] + [DependencyProperty("TrackBarHeight", nameof(OnTrackBarHeightChanged), DefaultValue = "(double)2.0")] + [DependencyProperty("BarShape", nameof(OnBarShapeChanged), DefaultValue = "BarShapes.Round")] + [DependencyProperty("Percent", nameof(OnPercentChanged), DefaultValue = "(double)0.0")] + [DependencyProperty("PercentCaution", nameof(OnPercentCautionChanged), DefaultValue = "(double)75.1")] + [DependencyProperty("PercentCritical", nameof(OnPercentCriticalChanged), DefaultValue = "(double)89.9")] public partial class StorageBar { - #region Value Bar Height (double) - - /// - /// Identifies the ValueBarHeight dependency property. - /// - public static readonly DependencyProperty ValueBarHeightProperty = - DependencyProperty.Register( - nameof(ValueBarHeight), - typeof(double), - typeof(StorageBar), - new PropertyMetadata(4.0, (d, e) => ((StorageBar)d).OnValueBarHeightChanged((double)e.OldValue, (double)e.NewValue))); - - /// - /// Gets or sets the height of the Value Bar. - /// - public double ValueBarHeight - { - get => (double)GetValue(ValueBarHeightProperty); - set => SetValue(ValueBarHeightProperty, value); - } - private void OnValueBarHeightChanged(double oldValue, double newValue) { UpdateControl(this); } - #endregion - - #region Track Bar Height (double) - - /// - /// Identifies the TrackBarHeight dependency property. - /// - public static readonly DependencyProperty TrackBarHeightProperty = - DependencyProperty.Register( - nameof(TrackBarHeight), - typeof(double), - typeof(StorageBar), - new PropertyMetadata(2.0, (d, e) => ((StorageBar)d).OnTrackBarHeightChanged((double)e.OldValue, (double)e.NewValue))); - - /// - /// Gets or sets the height of the Track Bar. - /// - public double TrackBarHeight - { - get => (double)GetValue(TrackBarHeightProperty); - set => SetValue(TrackBarHeightProperty, value); - } - private void OnTrackBarHeightChanged(double oldValue, double newValue) { UpdateControl(this); } - #endregion - - #region BarShape (BarShapes) - - /// - /// Identifies the BarShape dependency property. - /// - public static readonly DependencyProperty BarShapeProperty = - DependencyProperty.Register( - nameof(BarShape), - typeof(BarShapes), - typeof(StorageBar), - new PropertyMetadata(BarShapes.Round, (d, e) => ((StorageBar)d).OnBarShapeChanged((BarShapes)e.OldValue, (BarShapes)e.NewValue))); - - /// - /// Gets or sets an Enum value to choose from our two BarShapes. (Round, Flat) - /// - public BarShapes BarShape - { - get => (BarShapes)GetValue(BarShapeProperty); - set => SetValue(BarShapeProperty, value); - } - private void OnBarShapeChanged(BarShapes oldValue, BarShapes newValue) { UpdateControl(this); } - #endregion - - #region Percent (double) - - /// - /// Identifies the Percent dependency property. - /// - public static readonly DependencyProperty PercentProperty = - DependencyProperty.Register( - nameof(Percent), - typeof(double), - typeof(StorageBar), - new PropertyMetadata(0.0, (d, e) => ((StorageBar)d).OnPercentChanged((double)e.OldValue, (double)e.NewValue))); - - /// - /// Gets or sets the current value as a Percentage between 0.0 and 100.0. - /// - public double Percent - { - get => (double)GetValue(PercentProperty); - set => SetValue(PercentProperty, value); - } - private void OnPercentChanged(double oldValue, double newValue) { return; //Read-only DoubleToPercentage(Value, Minimum, Maximum); - UpdateControl(this); } - #endregion - - #region PercentWarning (double) - - /// - /// Identifies the PercentCaution dependency property. - /// - public static readonly DependencyProperty PercentCautionProperty = - DependencyProperty.Register( - nameof(PercentCaution), - typeof(double), - typeof(StorageBar), - new PropertyMetadata(75.1, (d, e) => ((StorageBar)d).OnPercentCautionChanged((double)e.OldValue, (double)e.NewValue))); - - /// - /// Gets or sets the PercentCaution double value. - /// - public double PercentCaution - { - get => (double)GetValue(PercentCautionProperty); - set => SetValue(PercentCautionProperty, value); - } - private void OnPercentCautionChanged(double oldValue, double newValue) { UpdateControl(this); } - #endregion - - #region PercentCritical (double) - - /// - /// Identifies the PercentCritical dependency property. - /// - public static readonly DependencyProperty PercentCriticalProperty = - DependencyProperty.Register( - nameof(PercentCritical), - typeof(double), - typeof(StorageBar), - new PropertyMetadata(89.9, (d, e) => ((StorageBar)d).OnPercentCriticalChanged((double)e.OldValue, (double)e.NewValue))); - - /// - /// Gets or sets the PercentCritical double value. - /// - public double PercentCritical - { - get => (double)GetValue(PercentCriticalProperty); - set => SetValue(PercentCriticalProperty, value); - } - private void OnPercentCriticalChanged(double oldValue, double newValue) { UpdateControl(this); } - #endregion - - #region Derived RangeBase Events - /// protected override void OnValueChanged(double oldValue, double newValue) { @@ -202,7 +67,5 @@ protected override void OnMinimumChanged(double oldValue, double newValue) base.OnMinimumChanged(oldValue, newValue); UpdateValue(this, oldValue, newValue, false, -1.0); } - - #endregion } } diff --git a/src/Files.App.Controls/Storage/StorageBar/StorageBar.cs b/src/Files.App.Controls/Storage/StorageBar/StorageBar.cs index fc9c0ada17c8..201b8866c8be 100644 --- a/src/Files.App.Controls/Storage/StorageBar/StorageBar.cs +++ b/src/Files.App.Controls/Storage/StorageBar/StorageBar.cs @@ -10,8 +10,7 @@ namespace Files.App.Controls { /// - /// StorageBar - Takes a set of values, converts them to a percentage - /// and displays it across a Bar. + /// Represents percentage ring islands. /// public partial class StorageBar : RangeBase { diff --git a/src/Files.App.Controls/Storage/StorageRing/StorageRing.Constants.cs b/src/Files.App.Controls/Storage/StorageRing/StorageRing.Constants.cs index 91042d134237..1b5fe39b9f4b 100644 --- a/src/Files.App.Controls/Storage/StorageRing/StorageRing.Constants.cs +++ b/src/Files.App.Controls/Storage/StorageRing/StorageRing.Constants.cs @@ -12,15 +12,11 @@ namespace Files.App.Controls [TemplatePart(Name = ContainerPartName, Type = typeof(Grid))] [TemplatePart(Name = ValueRingShapePartName, Type = typeof(RingShape))] [TemplatePart(Name = TrackRingShapePartName, Type = typeof(RingShape))] - - // VisualStates [TemplateVisualState(Name = SafeStateName, GroupName = ControlStateGroupName)] [TemplateVisualState(Name = CautionStateName, GroupName = ControlStateGroupName)] [TemplateVisualState(Name = CriticalStateName, GroupName = ControlStateGroupName)] [TemplateVisualState(Name = DisabledStateName, GroupName = ControlStateGroupName)] - - public partial class StorageRing { internal const string ContainerPartName = "PART_Container"; diff --git a/src/Files.App.Controls/Storage/StorageRing/StorageRing.Properties.cs b/src/Files.App.Controls/Storage/StorageRing/StorageRing.Properties.cs index 18c4d18f4793..6eba61d9595f 100644 --- a/src/Files.App.Controls/Storage/StorageRing/StorageRing.Properties.cs +++ b/src/Files.App.Controls/Storage/StorageRing/StorageRing.Properties.cs @@ -5,93 +5,30 @@ namespace Files.App.Controls { + [DependencyProperty("ValueRingThickness", nameof(OnValueRingThicknessChanged), DefaultValue = "(double)0.0")] + [DependencyProperty("TrackRingThickness", nameof(OnTrackRingThicknessChanged), DefaultValue = "(double)0.0")] + [DependencyProperty("MinAngle", nameof(OnMinAngleChanged), DefaultValue = "(double)0.0")] + [DependencyProperty("MaxAngle", nameof(OnMaxAngleChanged), DefaultValue = "(double)360.0")] + [DependencyProperty("StartAngle", nameof(OnStartAngleChanged), DefaultValue = "(double)0.0")] + [DependencyProperty("Percent", nameof(OnPercentChanged))] + [DependencyProperty("PercentCaution", nameof(OnPercentCautionChanged), DefaultValue = "(double)75.01")] + [DependencyProperty("PercentCritical", nameof(OnPercentCriticalChanged), DefaultValue = "(double)90.01")] + [DependencyProperty("ValueAngle")] + [DependencyProperty("AdjustedSize", DefaultValue = "(double)16.0")] public partial class StorageRing { - #region ValueRingThickness (double) - - /// - /// The ValueRing Thickness property. - /// - public static readonly DependencyProperty ValueRingThicknessProperty = - DependencyProperty.Register( - nameof(ValueRingThickness), - typeof(double), - typeof(StorageRing), - new PropertyMetadata(0.0, (d, e) => ((StorageRing)d).OnValueRingThicknessChanged((double)e.OldValue, (double)e.NewValue))); - - /// - /// Gets or sets the Track ring Thickness. - /// - /// - /// The value ring thickness. - /// - public double ValueRingThickness - { - get => (double)GetValue(ValueRingThicknessProperty); - set => SetValue(ValueRingThicknessProperty, value); - } - private void OnValueRingThicknessChanged(double oldValue, double newValue) { UpdateRingThickness(this, newValue, false); UpdateRings(this); } - #endregion - - #region TrackRingThickness (double) - - /// - /// The TrackRing Thickness property. - /// - public static readonly DependencyProperty TrackRingThicknessProperty = - DependencyProperty.Register( - nameof(TrackRingThickness), - typeof(double), - typeof(StorageRing), - new PropertyMetadata(0.0, (d, e) => ((StorageRing)d).OnTrackRingThicknessChanged((double)e.OldValue, (double)e.NewValue))); - - /// - /// Gets or sets the Track ring Thickness. - /// - /// - /// The track ring thickness. - /// - public double TrackRingThickness - { - get => (double)GetValue(TrackRingThicknessProperty); - set => SetValue(TrackRingThicknessProperty, value); - } - private void OnTrackRingThicknessChanged(double oldValue, double newValue) { UpdateRingThickness(this, newValue, true); UpdateRings(this); } - #endregion - - #region MinAngle (double) - - /// - /// Identifies the MinAngle dependency property. - /// - public static readonly DependencyProperty MinAngleProperty = - DependencyProperty.Register( - nameof(MinAngle), - typeof(double), - typeof(StorageRing), - new PropertyMetadata(0.0, (d, e) => ((StorageRing)d).OnMinAngleChanged((double)e.OldValue, (double)e.NewValue))); - - /// - /// Gets or sets the MinAngle - /// - public double MinAngle - { - get => (double)GetValue(MinAngleProperty); - set => SetValue(MinAngleProperty, value); - } - private void OnMinAngleChanged(double oldValue, double newValue) { UpdateValues(this, Value, _oldValue, false, -1.0); @@ -99,29 +36,6 @@ private void OnMinAngleChanged(double oldValue, double newValue) UpdateRings(this); } - #endregion - - #region MaxAngle (double) - - /// - /// Identifies the MinAngle dependency property. - /// - public static readonly DependencyProperty MaxAngleProperty = - DependencyProperty.Register( - nameof(MaxAngle), - typeof(double), - typeof(StorageRing), - new PropertyMetadata(360.0, (d, e) => ((StorageRing)d).OnMaxAngleChanged((double)e.OldValue, (double)e.NewValue))); - - /// - /// Gets or sets the MaxAngle - /// - public double MaxAngle - { - get => (double)GetValue(MaxAngleProperty); - set => SetValue(MaxAngleProperty, value); - } - private void OnMaxAngleChanged(double oldValue, double newValue) { UpdateValues(this, Value, _oldValue, false, -1.0); @@ -129,29 +43,6 @@ private void OnMaxAngleChanged(double oldValue, double newValue) UpdateRings(this); } - #endregion - - #region StartAngle (double) - - /// - /// Identifies the StartAngle dependency property. - /// - public static readonly DependencyProperty StartAngleProperty = - DependencyProperty.Register( - nameof(StartAngle), - typeof(double), - typeof(StorageRing), - new PropertyMetadata(0.0, (d, e) => ((StorageRing)d).OnStartAngleChanged((double)e.OldValue, (double)e.NewValue))); - - /// - /// Gets or sets the StartAngle - /// - public double StartAngle - { - get => (double)GetValue(StartAngleProperty); - set => SetValue(StartAngleProperty, value); - } - private void OnStartAngleChanged(double oldValue, double newValue) { UpdateValues(this, Value, _oldValue, false, -1.0); @@ -160,29 +51,6 @@ private void OnStartAngleChanged(double oldValue, double newValue) UpdateRings(this); } - #endregion - - #region Percent (double) - - /// - /// Identifies the Percent dependency property. - /// - public static readonly DependencyProperty PercentProperty = - DependencyProperty.Register( - nameof(Percent), - typeof(double), - typeof(StorageRing), - new PropertyMetadata(null, (d, e) => ((StorageRing)d).OnPercentChanged((double)e.OldValue, (double)e.NewValue))); - - /// - /// Gets or sets the current value as a Percentage between 0.0 and 100.0. - /// - public double Percent - { - get => (double)GetValue(PercentProperty); - set => SetValue(PercentProperty, value); - } - private void OnPercentChanged(double oldValue, double newValue) { return; //Read-only @@ -201,30 +69,6 @@ private void OnPercentChanged(double oldValue, double newValue) UpdateValues(this, Value, _oldValue, true, adjustedPercentage); UpdateVisualState(this); UpdateRings(this); - - } - - #endregion - - #region PercentCaution (double) - - /// - /// Identifies the PercentCaution dependency property - /// - public static readonly DependencyProperty PercentCautionProperty = - DependencyProperty.Register( - nameof(PercentCaution), - typeof(double), - typeof(StorageRing), - new PropertyMetadata(75.01, (d, e) => ((StorageRing)d).OnPercentCautionChanged((double)e.OldValue, (double)e.NewValue))); - - /// - /// Gets or sets the PercentCaution double value - /// - public double PercentCaution - { - get => (double)GetValue(PercentCautionProperty); - set => SetValue(PercentCautionProperty, value); } private void OnPercentCautionChanged(double oldValue, double newValue) @@ -234,29 +78,6 @@ private void OnPercentCautionChanged(double oldValue, double newValue) UpdateRings(this); } - #endregion - - #region PercentCritical (double) - - /// - /// Identifies the PercentCritical dependency property - /// - public static readonly DependencyProperty PercentCriticalProperty = - DependencyProperty.Register( - nameof(PercentCritical), - typeof(double), - typeof(StorageRing), - new PropertyMetadata(90.01, (d, e) => ((StorageRing)d).OnPercentCriticalChanged((double)e.OldValue, (double)e.NewValue))); - - /// - /// Gets or sets the PercentCritical double value - /// - public double PercentCritical - { - get => (double)GetValue(PercentCriticalProperty); - set => SetValue(PercentCriticalProperty, value); - } - private void OnPercentCriticalChanged(double oldValue, double newValue) { UpdateValues(this, Value, _oldValue, false, -1.0); @@ -264,10 +85,6 @@ private void OnPercentCriticalChanged(double oldValue, double newValue) UpdateRings(this); } - #endregion - - #region RangeBase Methods - /// protected override void OnValueChanged(double oldValue, double newValue) { @@ -288,53 +105,5 @@ protected override void OnMaximumChanged(double oldMaximum, double newMaximum) base.OnMaximumChanged(oldMaximum, newMaximum); StorageRing_MaximumChanged(this, newMaximum); } - - #endregion - - #region Protected ValueAngle (double) - - /// - /// Identifies the ValueAngle dependency property. - /// - protected static readonly DependencyProperty ValueAngleProperty = - DependencyProperty.Register( - nameof(ValueAngle), - typeof(double), - typeof(StorageRing), - new PropertyMetadata(null)); - - /// - /// Gets or sets the current angle of the Ring (between MinAngle and MaxAngle). - /// - protected double ValueAngle - { - get => (double)GetValue(ValueAngleProperty); - set => SetValue(ValueAngleProperty, value); - } - - #endregion - - #region Protected AdjustedSize (double) - - /// - /// Identifies the AdjustedSize dependency property. - /// - protected static readonly DependencyProperty AdjustedSizeProperty = - DependencyProperty.Register( - nameof(AdjustedSize), - typeof(double), - typeof(StorageRing), - new PropertyMetadata(16.0)); - - /// - /// Gets or sets the AdjustedSize of the control. - /// - protected double AdjustedSize - { - get => (double)GetValue(AdjustedSizeProperty); - set => SetValue(AdjustedSizeProperty, value); - } - - #endregion } } diff --git a/src/Files.App.Controls/Storage/StorageRing/StorageRing.cs b/src/Files.App.Controls/Storage/StorageRing/StorageRing.cs index 046a2cffa8bb..04d1647934e0 100644 --- a/src/Files.App.Controls/Storage/StorageRing/StorageRing.cs +++ b/src/Files.App.Controls/Storage/StorageRing/StorageRing.cs @@ -13,8 +13,7 @@ namespace Files.App.Controls { /// - /// StorageRing - Takes a set of values, converts them to a percentage - /// and displays it on a ring. + /// Represents percentage bar islands. /// public partial class StorageRing : RangeBase { diff --git a/src/Files.App.Controls/Themes/Generic.xaml b/src/Files.App.Controls/Themes/Generic.xaml index 5bbe85957be7..e72f2b250065 100644 --- a/src/Files.App.Controls/Themes/Generic.xaml +++ b/src/Files.App.Controls/Themes/Generic.xaml @@ -5,9 +5,6 @@ xmlns:local="using:Files.App.Controls"> - - - diff --git a/tests/Files.App.UITests/Files.App.UITests.csproj b/tests/Files.App.UITests/Files.App.UITests.csproj index 98811ae46f03..9779a74497bb 100644 --- a/tests/Files.App.UITests/Files.App.UITests.csproj +++ b/tests/Files.App.UITests/Files.App.UITests.csproj @@ -36,12 +36,6 @@ - - - $(DefaultXamlRuntime) - MSBuild:Compile - - true diff --git a/tests/Files.App.UITests/Views/StorageControlsPage.xaml b/tests/Files.App.UITests/Views/StorageControlsPage.xaml index 3b725b21b2cd..d2dd20999c48 100644 --- a/tests/Files.App.UITests/Views/StorageControlsPage.xaml +++ b/tests/Files.App.UITests/Views/StorageControlsPage.xaml @@ -20,7 +20,6 @@ -