@@ -23,35 +23,96 @@ public partial class PullRequestStatusCircle : UserControl
2323 {
2424 public static readonly DependencyProperty ErrorCountProperty = DependencyProperty . Register (
2525 "ErrorCount" , typeof ( int ) , typeof ( PullRequestStatusCircle ) ,
26- new PropertyMetadata ( 0 , ( d , args ) => ( ( PullRequestStatusCircle ) d ) . ErrorCount = ( int ) args . NewValue ) ) ;
26+ new PropertyMetadata ( 0 , OnErrorCountChanged ) ) ;
27+
28+ private static void OnErrorCountChanged ( DependencyObject dependencyObject , DependencyPropertyChangedEventArgs eventArgs )
29+ {
30+ var pullRequestStatusCircle = ( ( PullRequestStatusCircle ) dependencyObject ) ;
31+ pullRequestStatusCircle . ErrorCount = ( int ) eventArgs . NewValue ;
32+ pullRequestStatusCircle . GeneratePolygons ( ) ;
33+ }
2734
2835 public static readonly DependencyProperty SuccessCountProperty = DependencyProperty . Register (
2936 "SuccessCount" , typeof ( int ) , typeof ( PullRequestStatusCircle ) ,
30- new PropertyMetadata ( 0 , ( d , args ) => ( ( PullRequestStatusCircle ) d ) . SuccessCount = ( int ) args . NewValue ) ) ;
37+ new PropertyMetadata ( 0 , OnSuccessCountChanged ) ) ;
38+
39+ private static void OnSuccessCountChanged ( DependencyObject dependencyObject , DependencyPropertyChangedEventArgs eventArgs )
40+ {
41+ var pullRequestStatusCircle = ( ( PullRequestStatusCircle ) dependencyObject ) ;
42+ pullRequestStatusCircle . SuccessCount = ( int ) eventArgs . NewValue ;
43+ pullRequestStatusCircle . GeneratePolygons ( ) ;
44+ }
3145
3246 public static readonly DependencyProperty PendingCountProperty = DependencyProperty . Register (
3347 "PendingCount" , typeof ( int ) , typeof ( PullRequestStatusCircle ) ,
34- new PropertyMetadata ( 0 , ( d , args ) => ( ( PullRequestStatusCircle ) d ) . PendingCount = ( int ) args . NewValue ) ) ;
48+ new PropertyMetadata ( 0 , OnPendingCountChanged ) ) ;
49+
50+ private static void OnPendingCountChanged ( DependencyObject dependencyObject , DependencyPropertyChangedEventArgs eventArgs )
51+ {
52+ var pullRequestStatusCircle = ( ( PullRequestStatusCircle ) dependencyObject ) ;
53+ pullRequestStatusCircle . PendingCount = ( int ) eventArgs . NewValue ;
54+ pullRequestStatusCircle . GeneratePolygons ( ) ;
55+ }
3556
3657 public static readonly DependencyProperty RadiusProperty = DependencyProperty . Register (
3758 "Radius" , typeof ( double ) , typeof ( PullRequestStatusCircle ) ,
38- new PropertyMetadata ( ( double ) 250 , ( d , args ) => ( ( PullRequestStatusCircle ) d ) . Radius = ( double ) args . NewValue ) ) ;
59+ new PropertyMetadata ( ( double ) 250 , OnRadiusChanged ) ) ;
60+
61+ private static void OnRadiusChanged ( DependencyObject dependencyObject , DependencyPropertyChangedEventArgs eventArgs )
62+ {
63+ var pullRequestStatusCircle = ( ( PullRequestStatusCircle ) dependencyObject ) ;
64+ pullRequestStatusCircle . Radius = ( double ) eventArgs . NewValue ;
65+ pullRequestStatusCircle . GenerateMask ( ) ;
66+ pullRequestStatusCircle . GeneratePolygons ( ) ;
67+ }
3968
4069 public static readonly DependencyProperty InnerRadiusProperty = DependencyProperty . Register (
4170 "InnerRadius" , typeof ( double ) , typeof ( PullRequestStatusCircle ) ,
42- new PropertyMetadata ( ( double ) 200 , ( d , args ) => ( ( PullRequestStatusCircle ) d ) . InnerRadius = ( double ) args . NewValue ) ) ;
71+ new PropertyMetadata ( ( double ) 200 , OnInnerRadiusChanged ) ) ;
72+
73+ private static void OnInnerRadiusChanged ( DependencyObject dependencyObject , DependencyPropertyChangedEventArgs eventArgs )
74+ {
75+ var pullRequestStatusCircle = ( ( PullRequestStatusCircle ) dependencyObject ) ;
76+ pullRequestStatusCircle . InnerRadius = ( double ) eventArgs . NewValue ;
77+ pullRequestStatusCircle . GenerateMask ( ) ;
78+ pullRequestStatusCircle . GeneratePolygons ( ) ;
79+ }
4380
4481 public static readonly DependencyProperty PendingColorProperty = DependencyProperty . Register (
4582 "PendingColor" , typeof ( Brush ) , typeof ( PullRequestStatusCircle ) ,
46- new PropertyMetadata ( Brushes . Yellow , ( d , args ) => ( ( PullRequestStatusCircle ) d ) . PendingColor = ( Brush ) args . NewValue ) ) ;
83+ new PropertyMetadata ( Brushes . Yellow , OnPendingColorChanged ) ) ;
84+
85+ private static void OnPendingColorChanged ( DependencyObject dependencyObject , DependencyPropertyChangedEventArgs eventArgs )
86+ {
87+ var pullRequestStatusCircle = ( ( PullRequestStatusCircle ) dependencyObject ) ;
88+ var brush = ( Brush ) eventArgs . NewValue ;
89+ pullRequestStatusCircle . PendingColor = brush ;
90+ pullRequestStatusCircle . PendingPolygon . Fill = brush ;
91+ }
4792
4893 public static readonly DependencyProperty ErrorColorProperty = DependencyProperty . Register (
4994 "ErrorColor" , typeof ( Brush ) , typeof ( PullRequestStatusCircle ) ,
50- new PropertyMetadata ( Brushes . Red , ( d , args ) => ( ( PullRequestStatusCircle ) d ) . ErrorColor = ( Brush ) args . NewValue ) ) ;
95+ new PropertyMetadata ( Brushes . Red , OnErrorColorChanged ) ) ;
96+
97+ private static void OnErrorColorChanged ( DependencyObject dependencyObject , DependencyPropertyChangedEventArgs eventArgs )
98+ {
99+ var pullRequestStatusCircle = ( ( PullRequestStatusCircle ) dependencyObject ) ;
100+ var brush = ( Brush ) eventArgs . NewValue ;
101+ pullRequestStatusCircle . ErrorColor = brush ;
102+ pullRequestStatusCircle . ErrorPolygon . Fill = brush ;
103+ }
51104
52105 public static readonly DependencyProperty SuccessColorProperty = DependencyProperty . Register (
53106 "SuccessColor" , typeof ( Brush ) , typeof ( PullRequestStatusCircle ) ,
54- new PropertyMetadata ( Brushes . Green , ( d , args ) => ( ( PullRequestStatusCircle ) d ) . SuccessColor = ( Brush ) args . NewValue ) ) ;
107+ new PropertyMetadata ( Brushes . Green , OnSuccessColorChanged ) ) ;
108+
109+ private static void OnSuccessColorChanged ( DependencyObject dependencyObject , DependencyPropertyChangedEventArgs eventArgs )
110+ {
111+ var pullRequestStatusCircle = ( ( PullRequestStatusCircle ) dependencyObject ) ;
112+ var brush = ( Brush ) eventArgs . NewValue ;
113+ pullRequestStatusCircle . SuccessColor = brush ;
114+ pullRequestStatusCircle . SuccessPolygon . Fill = brush ;
115+ }
55116
56117 public IEnumerable < Point > GeneratePoints ( float percentage )
57118 {
@@ -208,7 +269,6 @@ public int ErrorCount
208269 set
209270 {
210271 SetValue ( ErrorCountProperty , value ) ;
211- GeneratePolygons ( ) ;
212272 }
213273 }
214274
@@ -218,7 +278,6 @@ public int SuccessCount
218278 set
219279 {
220280 SetValue ( SuccessCountProperty , value ) ;
221- GeneratePolygons ( ) ;
222281 }
223282 }
224283
@@ -228,7 +287,6 @@ public int PendingCount
228287 set
229288 {
230289 SetValue ( PendingCountProperty , value ) ;
231- GeneratePolygons ( ) ;
232290 }
233291 }
234292
@@ -238,8 +296,6 @@ public double Radius
238296 set
239297 {
240298 SetValue ( RadiusProperty , value ) ;
241- GenerateMask ( ) ;
242- GeneratePolygons ( ) ;
243299 }
244300 }
245301
@@ -249,8 +305,6 @@ public double InnerRadius
249305 set
250306 {
251307 SetValue ( InnerRadiusProperty , value ) ;
252- GenerateMask ( ) ;
253- GeneratePolygons ( ) ;
254308 }
255309 }
256310
@@ -260,7 +314,6 @@ public Brush PendingColor
260314 set
261315 {
262316 SetValue ( PendingColorProperty , value ) ;
263- PendingPolygon . Fill = value ;
264317 }
265318 }
266319
@@ -270,7 +323,6 @@ public Brush ErrorColor
270323 set
271324 {
272325 SetValue ( ErrorColorProperty , value ) ;
273- ErrorPolygon . Fill = value ;
274326 }
275327 }
276328
@@ -280,7 +332,6 @@ public Brush SuccessColor
280332 set
281333 {
282334 SetValue ( SuccessColorProperty , value ) ;
283- SuccessPolygon . Fill = value ;
284335 }
285336 }
286337
0 commit comments