|
| 1 | +// Copyright (c) Files Community |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +// based on https://github.com/files-community/Files/blob/528be10e78a1c4dc7d242e5a84b3330a604c5f5f/src/Files.App.Controls/Storage/RingShape/RingShape.Properties.cs |
| 5 | + |
| 6 | +using Windows.Foundation; |
| 7 | +#if WINDOWS_UWP |
| 8 | +using Windows.UI.Xaml; |
| 9 | +using Windows.UI.Xaml.Media; |
| 10 | +using Path = Windows.UI.Xaml.Shapes.Path; |
| 11 | +#else |
| 12 | +using Microsoft.UI.Xaml; |
| 13 | +using Microsoft.UI.Xaml.Media; |
| 14 | +using Path = Microsoft.UI.Xaml.Shapes.Path; |
| 15 | +#endif |
| 16 | + |
| 17 | +namespace Project2FA.Controls |
| 18 | +{ |
| 19 | + public partial class RingShape : Path |
| 20 | + { |
| 21 | + public static readonly DependencyProperty StartAngleProperty = |
| 22 | + DependencyProperty.Register( |
| 23 | + nameof(StartAngle), |
| 24 | + typeof(double), |
| 25 | + typeof(RingShape), |
| 26 | + new PropertyMetadata(0.0d, OnStartAngleChanged)); |
| 27 | + |
| 28 | + public double StartAngle |
| 29 | + { |
| 30 | + get { return (double)GetValue(StartAngleProperty); } |
| 31 | + set { SetValue(StartAngleProperty, value); } |
| 32 | + } |
| 33 | + |
| 34 | + public static readonly DependencyProperty EndAngleProperty = |
| 35 | + DependencyProperty.Register( |
| 36 | + nameof(EndAngle), |
| 37 | + typeof(double), |
| 38 | + typeof(RingShape), |
| 39 | + new PropertyMetadata(90.0d, OnEndAngleChanged)); |
| 40 | + |
| 41 | + public double EndAngle |
| 42 | + { |
| 43 | + get { return (double)GetValue(EndAngleProperty); } |
| 44 | + set { SetValue(EndAngleProperty, value); } |
| 45 | + } |
| 46 | + |
| 47 | + public static readonly DependencyProperty SweepDirectionProperty = |
| 48 | + DependencyProperty.Register( |
| 49 | + nameof(SweepDirection), |
| 50 | + typeof(SweepDirection), |
| 51 | + typeof(RingShape), |
| 52 | + new PropertyMetadata(SweepDirection.Clockwise, OnSweepDirectionChanged)); |
| 53 | + |
| 54 | + public SweepDirection SweepDirection |
| 55 | + { |
| 56 | + get { return (SweepDirection)GetValue(SweepDirectionProperty); } |
| 57 | + set { SetValue(SweepDirectionProperty, value); } |
| 58 | + } |
| 59 | + |
| 60 | + public static readonly DependencyProperty MinAngleProperty = |
| 61 | + DependencyProperty.Register( |
| 62 | + nameof(MinAngle), |
| 63 | + typeof(double), |
| 64 | + typeof(RingShape), |
| 65 | + new PropertyMetadata(0.0d, OnMinAngleChanged)); |
| 66 | + |
| 67 | + public double MinAngle |
| 68 | + { |
| 69 | + get { return (double)GetValue(MinAngleProperty); } |
| 70 | + set { SetValue(MinAngleProperty, value); } |
| 71 | + } |
| 72 | + |
| 73 | + public static readonly DependencyProperty MaxAngleProperty = |
| 74 | + DependencyProperty.Register( |
| 75 | + nameof(MaxAngle), |
| 76 | + typeof(double), |
| 77 | + typeof(RingShape), |
| 78 | + new PropertyMetadata(360.0d, OnMaxAngleChanged)); |
| 79 | + |
| 80 | + public double MaxAngle |
| 81 | + { |
| 82 | + get { return (double)GetValue(MaxAngleProperty); } |
| 83 | + set { SetValue(MaxAngleProperty, value); } |
| 84 | + } |
| 85 | + |
| 86 | + public static readonly DependencyProperty RadiusWidthProperty = |
| 87 | + DependencyProperty.Register( |
| 88 | + nameof(RadiusWidth), |
| 89 | + typeof(double), |
| 90 | + typeof(RingShape), |
| 91 | + new PropertyMetadata(0.0d, OnRadiusWidthChanged)); |
| 92 | + |
| 93 | + public double RadiusWidth |
| 94 | + { |
| 95 | + get { return (double)GetValue(RadiusWidthProperty); } |
| 96 | + set { SetValue(RadiusWidthProperty, value); } |
| 97 | + } |
| 98 | + |
| 99 | + public static readonly DependencyProperty RadiusHeightProperty = |
| 100 | + DependencyProperty.Register( |
| 101 | + nameof(RadiusHeight), |
| 102 | + typeof(double), |
| 103 | + typeof(RingShape), |
| 104 | + new PropertyMetadata(0.0d, OnRadiusHeightChanged)); |
| 105 | + |
| 106 | + public double RadiusHeight |
| 107 | + { |
| 108 | + get { return (double)GetValue(RadiusHeightProperty); } |
| 109 | + set { SetValue(RadiusHeightProperty, value); } |
| 110 | + } |
| 111 | + |
| 112 | + public static readonly DependencyProperty IsCircleProperty = |
| 113 | + DependencyProperty.Register( |
| 114 | + nameof(IsCircle), |
| 115 | + typeof(bool), |
| 116 | + typeof(RingShape), |
| 117 | + new PropertyMetadata(false, OnIsCircleChanged)); |
| 118 | + |
| 119 | + public bool IsCircle |
| 120 | + { |
| 121 | + get { return (bool)GetValue(IsCircleProperty); } |
| 122 | + set { SetValue(IsCircleProperty, value); } |
| 123 | + } |
| 124 | + |
| 125 | + public static readonly DependencyProperty CenterProperty = |
| 126 | + DependencyProperty.Register( |
| 127 | + nameof(Center), |
| 128 | + typeof(Point), |
| 129 | + typeof(RingShape), |
| 130 | + new PropertyMetadata(default(Point))); |
| 131 | + |
| 132 | + public Point Center |
| 133 | + { |
| 134 | + get { return (Point)GetValue(CenterProperty); } |
| 135 | + set { SetValue(CenterProperty, value); } |
| 136 | + } |
| 137 | + |
| 138 | + public static readonly DependencyProperty ActualRadiusWidthProperty = |
| 139 | + DependencyProperty.Register( |
| 140 | + nameof(ActualRadiusWidth), |
| 141 | + typeof(double), |
| 142 | + typeof(RingShape), |
| 143 | + new PropertyMetadata(0.0d)); |
| 144 | + |
| 145 | + public double ActualRadiusWidth |
| 146 | + { |
| 147 | + get { return (double)GetValue(ActualRadiusWidthProperty); } |
| 148 | + set { SetValue(ActualRadiusWidthProperty, value); } |
| 149 | + } |
| 150 | + |
| 151 | + public static readonly DependencyProperty AActualRadiusHeightProperty = |
| 152 | + DependencyProperty.Register( |
| 153 | + nameof(ActualRadiusHeight), |
| 154 | + typeof(double), |
| 155 | + typeof(RingShape), |
| 156 | + new PropertyMetadata(0.0d)); |
| 157 | + public double ActualRadiusHeight |
| 158 | + { |
| 159 | + get { return (double)GetValue(AActualRadiusHeightProperty); } |
| 160 | + set { SetValue(AActualRadiusHeightProperty, value); } |
| 161 | + } |
| 162 | + |
| 163 | + |
| 164 | + private static void OnStartAngleChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) |
| 165 | + { |
| 166 | + if (dependencyObject is RingShape ringShape) |
| 167 | + { |
| 168 | + ringShape.StartAngleChanged(); |
| 169 | + } |
| 170 | + } |
| 171 | + |
| 172 | + private static void OnEndAngleChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) |
| 173 | + { |
| 174 | + if (dependencyObject is RingShape ringShape) |
| 175 | + { |
| 176 | + ringShape.EndAngleChanged(); |
| 177 | + } |
| 178 | + } |
| 179 | + |
| 180 | + private static void OnSweepDirectionChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) |
| 181 | + { |
| 182 | + if (dependencyObject is RingShape ringShape) |
| 183 | + { |
| 184 | + ringShape.SweepDirectionChanged(); |
| 185 | + } |
| 186 | + } |
| 187 | + |
| 188 | + private static void OnMinAngleChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) |
| 189 | + { |
| 190 | + if (dependencyObject is RingShape ringShape) |
| 191 | + { |
| 192 | + ringShape.MinMaxAngleChanged(false); |
| 193 | + } |
| 194 | + } |
| 195 | + |
| 196 | + private static void OnMaxAngleChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) |
| 197 | + { |
| 198 | + if (dependencyObject is RingShape ringShape) |
| 199 | + { |
| 200 | + ringShape.MinMaxAngleChanged(true); |
| 201 | + } |
| 202 | + } |
| 203 | + |
| 204 | + private static void OnRadiusWidthChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) |
| 205 | + { |
| 206 | + if (dependencyObject is RingShape ringShape) |
| 207 | + { |
| 208 | + ringShape.RadiusWidthChanged(); |
| 209 | + } |
| 210 | + } |
| 211 | + |
| 212 | + private static void OnRadiusHeightChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) |
| 213 | + { |
| 214 | + if (dependencyObject is RingShape ringShape) |
| 215 | + { |
| 216 | + ringShape.RadiusHeightChanged(); |
| 217 | + } |
| 218 | + } |
| 219 | + |
| 220 | + private static void OnIsCircleChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) |
| 221 | + { |
| 222 | + if (dependencyObject is RingShape ringShape) |
| 223 | + { |
| 224 | + ringShape.IsCircleChanged(); |
| 225 | + } |
| 226 | + } |
| 227 | + } |
| 228 | +} |
0 commit comments