@@ -68,12 +68,12 @@ public partial class ProgressBar : Control
68
68
[ Description ( "The color used for the background rectangle of this control." ) ]
69
69
public Color BackgroundColor
70
70
{
71
- get { return this . _backgroundColor ; }
71
+ get { return _backgroundColor ; }
72
72
set
73
73
{
74
- if ( this . _backgroundColor != value )
74
+ if ( _backgroundColor != value )
75
75
{
76
- this . _backgroundColor = value ;
76
+ _backgroundColor = value ;
77
77
OnBackgroundColorChanged ( this , EventArgs . Empty ) ;
78
78
}
79
79
}
@@ -90,12 +90,12 @@ public Color BackgroundColor
90
90
[ Description ( "The color used for the value rectangle of this control." ) ]
91
91
public Color ValueColor
92
92
{
93
- get { return this . _valueColor ; }
93
+ get { return _valueColor ; }
94
94
set
95
95
{
96
- if ( this . _valueColor != value )
96
+ if ( _valueColor != value )
97
97
{
98
- this . _valueColor = value ;
98
+ _valueColor = value ;
99
99
OnValueColorChanged ( this , EventArgs . Empty ) ;
100
100
}
101
101
}
@@ -110,12 +110,12 @@ public Color ValueColor
110
110
/// </value>
111
111
public Color BorderColor
112
112
{
113
- get { return this . _borderColor ; }
113
+ get { return _borderColor ; }
114
114
set
115
115
{
116
- if ( this . _borderColor != value )
116
+ if ( _borderColor != value )
117
117
{
118
- this . _borderColor = value ;
118
+ _borderColor = value ;
119
119
OnBorderColorChanged ( this , EventArgs . Empty ) ;
120
120
}
121
121
}
@@ -143,10 +143,10 @@ public Color BorderColor
143
143
[ Description ( "The upper bound of range this ProgressBar is working with." ) ]
144
144
public int Maximum
145
145
{
146
- get { return this . _iMaximum ; }
146
+ get { return _iMaximum ; }
147
147
set
148
148
{
149
- if ( this . _iMaximum != value )
149
+ if ( _iMaximum != value )
150
150
{
151
151
if ( value < 0 )
152
152
{
@@ -158,15 +158,15 @@ public int Maximum
158
158
nameof ( Maximum ) ) ) ;
159
159
}
160
160
161
- if ( this . _iMinimum > value )
161
+ if ( _iMinimum > value )
162
162
{
163
- this . _iMinimum = value ;
163
+ _iMinimum = value ;
164
164
}
165
165
166
- this . _iMaximum = value ;
167
- if ( this . _iValue > this . _iMaximum )
166
+ _iMaximum = value ;
167
+ if ( _iValue > _iMaximum )
168
168
{
169
- this . _iValue = this . _iMaximum ;
169
+ _iValue = _iMaximum ;
170
170
}
171
171
172
172
UpdatePos ( ) ;
@@ -185,10 +185,10 @@ public int Maximum
185
185
[ Description ( "The lower bound of range this ProgressBar is working with." ) ]
186
186
public int Minimum
187
187
{
188
- get { return this . _iMinimum ; }
188
+ get { return _iMinimum ; }
189
189
set
190
190
{
191
- if ( this . _iMinimum != value )
191
+ if ( _iMinimum != value )
192
192
{
193
193
if ( value < 0 )
194
194
{
@@ -200,15 +200,15 @@ public int Minimum
200
200
nameof ( Minimum ) ) ) ;
201
201
}
202
202
203
- if ( this . _iMaximum < value )
203
+ if ( _iMaximum < value )
204
204
{
205
- this . _iMaximum = value ;
205
+ _iMaximum = value ;
206
206
}
207
207
208
- this . _iMinimum = value ;
209
- if ( this . _iValue < this . _iMinimum )
208
+ _iMinimum = value ;
209
+ if ( _iValue < _iMinimum )
210
210
{
211
- this . _iValue = this . _iMinimum ;
211
+ _iValue = _iMinimum ;
212
212
}
213
213
214
214
UpdatePos ( ) ;
@@ -228,23 +228,23 @@ public int Minimum
228
228
"The current value for the ProgressBar, in the range specified by the minimum and maximum properties." ) ]
229
229
public int Value
230
230
{
231
- get { return this . _iValue ; }
231
+ get { return _iValue ; }
232
232
set
233
233
{
234
- if ( this . _iValue != value )
234
+ if ( _iValue != value )
235
235
{
236
- if ( value < this . _iMinimum || value > this . _iMaximum )
236
+ if ( value < _iMinimum || value > _iMaximum )
237
237
{
238
238
throw new ArgumentOutOfRangeException ( nameof ( Value ) ,
239
239
string . Format ( CultureInfo . InvariantCulture ,
240
240
Resources . IDS_InvalidBoundArgument ,
241
- new object [ ]
242
- {
243
- "Value" , value . ToString ( CultureInfo . CurrentCulture ) , " 'minimum'", "'maximum'"
244
- } ) ) ;
241
+ nameof ( Value ) ,
242
+ value . ToString ( CultureInfo . CurrentCulture ) ,
243
+ " 'minimum'",
244
+ "'maximum'" ) ) ;
245
245
}
246
246
247
- this . _iValue = value ;
247
+ _iValue = value ;
248
248
UpdatePos ( ) ;
249
249
}
250
250
}
@@ -259,18 +259,18 @@ public int Value
259
259
/// </summary>
260
260
public ProgressBar ( )
261
261
{
262
- this . SetStyle ( ControlStyles . AllPaintingInWmPaint , true ) ;
263
- this . SetStyle ( ControlStyles . UserPaint , true ) ;
264
- this . SetStyle ( ControlStyles . OptimizedDoubleBuffer , true ) ;
265
- this . SetStyle ( ControlStyles . ResizeRedraw , true ) ;
266
- this . SetStyle ( ControlStyles . SupportsTransparentBackColor , true ) ;
262
+ SetStyle ( ControlStyles . AllPaintingInWmPaint , true ) ;
263
+ SetStyle ( ControlStyles . UserPaint , true ) ;
264
+ SetStyle ( ControlStyles . OptimizedDoubleBuffer , true ) ;
265
+ SetStyle ( ControlStyles . ResizeRedraw , true ) ;
266
+ SetStyle ( ControlStyles . SupportsTransparentBackColor , true ) ;
267
267
InitializeComponent ( ) ;
268
268
269
- this . _iMaximum = 100 ;
270
- this . _backgroundColor = Color . FromArgb ( 20 , 20 , 255 ) ;
271
- this . _valueColor = Color . FromArgb ( 255 , 0 , 255 ) ;
272
- this . _borderColor = SystemColors . ActiveBorder ;
273
- this . BackColor = Color . Transparent ;
269
+ _iMaximum = 100 ;
270
+ _backgroundColor = Color . FromArgb ( 20 , 20 , 255 ) ;
271
+ _valueColor = Color . FromArgb ( 255 , 0 , 255 ) ;
272
+ _borderColor = SystemColors . ActiveBorder ;
273
+ BackColor = Color . Transparent ;
274
274
}
275
275
276
276
#endregion
@@ -286,27 +286,26 @@ protected override void OnPaint(PaintEventArgs e)
286
286
using ( var antiAlias = new UseAntiAlias ( e . Graphics ) )
287
287
{
288
288
var graphics = e . Graphics ;
289
- DrawProgressBar (
290
- graphics ,
291
- this . ClientRectangle ,
292
- this . _backgroundColor ,
293
- this . _valueColor ,
294
- this . _borderColor ,
295
- this . RightToLeft ,
296
- this . Minimum ,
297
- this . Maximum ,
298
- this . Value ) ;
299
-
300
- if ( string . IsNullOrEmpty ( this . Text ) == false )
289
+ DrawProgressBar ( graphics ,
290
+ ClientRectangle ,
291
+ _backgroundColor ,
292
+ _valueColor ,
293
+ _borderColor ,
294
+ RightToLeft ,
295
+ Minimum ,
296
+ Maximum ,
297
+ Value ) ;
298
+
299
+ if ( string . IsNullOrEmpty ( Text ) == false )
301
300
{
302
301
using ( var useClearTypeGridFit = new UseClearTypeGridFit ( graphics ) )
303
302
{
304
- using ( SolidBrush textBrush = new SolidBrush ( this . ForeColor ) )
303
+ using ( var textBrush = new SolidBrush ( ForeColor ) )
305
304
{
306
- using ( StringFormat stringFormat = new StringFormat ( ) )
305
+ using ( var stringFormat = new StringFormat ( ) )
307
306
{
308
307
stringFormat . FormatFlags = StringFormatFlags . NoWrap ;
309
- if ( this . RightToLeft == RightToLeft . Yes )
308
+ if ( RightToLeft == RightToLeft . Yes )
310
309
{
311
310
stringFormat . FormatFlags |= StringFormatFlags . DirectionRightToLeft ;
312
311
}
@@ -315,8 +314,8 @@ protected override void OnPaint(PaintEventArgs e)
315
314
stringFormat . LineAlignment = StringAlignment . Center ;
316
315
stringFormat . Alignment = StringAlignment . Center ;
317
316
318
- Rectangle stringRectangle = this . ClientRectangle ;
319
- graphics . DrawString ( this . Text , this . Font , textBrush , stringRectangle , stringFormat ) ;
317
+ var stringRectangle = ClientRectangle ;
318
+ graphics . DrawString ( Text , Font , textBrush , stringRectangle , stringFormat ) ;
320
319
}
321
320
}
322
321
}
@@ -331,10 +330,10 @@ protected override void OnPaint(PaintEventArgs e)
331
330
/// <param name="e">A EventArgs that contains the event data.</param>
332
331
protected virtual void OnBorderColorChanged ( object sender , EventArgs e )
333
332
{
334
- this . Invalidate ( true ) ;
335
- if ( this . BorderColorChanged != null )
333
+ Invalidate ( true ) ;
334
+ if ( BorderColorChanged != null )
336
335
{
337
- this . BorderColorChanged ( sender , e ) ;
336
+ BorderColorChanged ( sender , e ) ;
338
337
}
339
338
}
340
339
@@ -346,9 +345,9 @@ protected virtual void OnBorderColorChanged(object sender, EventArgs e)
346
345
protected virtual void OnBackgroundColorChanged ( object sender , EventArgs e )
347
346
{
348
347
Invalidate ( ) ;
349
- if ( this . BackgroundColorChanged != null )
348
+ if ( BackgroundColorChanged != null )
350
349
{
351
- this . BackgroundColorChanged ( sender , e ) ;
350
+ BackgroundColorChanged ( sender , e ) ;
352
351
}
353
352
}
354
353
@@ -360,9 +359,9 @@ protected virtual void OnBackgroundColorChanged(object sender, EventArgs e)
360
359
protected virtual void OnValueColorChanged ( object sender , EventArgs e )
361
360
{
362
361
Invalidate ( true ) ;
363
- if ( this . ValueColorChanged != null )
362
+ if ( ValueColorChanged != null )
364
363
{
365
- this . ValueColorChanged ( sender , e ) ;
364
+ ValueColorChanged ( sender , e ) ;
366
365
}
367
366
}
368
367
@@ -372,7 +371,7 @@ protected virtual void OnValueColorChanged(object sender, EventArgs e)
372
371
373
372
private void UpdatePos ( )
374
373
{
375
- this . Invalidate ( true ) ;
374
+ Invalidate ( true ) ;
376
375
}
377
376
378
377
private static void DrawProgressBar (
@@ -503,15 +502,11 @@ private static LinearGradientBrush GetGradientBackBrush(Rectangle bounds, Color
503
502
return null ;
504
503
}
505
504
506
- LinearGradientBrush linearGradientBrush = linearGradientBrush =
507
- new LinearGradientBrush ( bounds , Color . White , backColor , LinearGradientMode . Vertical ) ;
508
- if ( linearGradientBrush != null )
509
- {
510
- Blend blend = new Blend ( ) ;
511
- blend . Positions = new float [ ] { 0.0F , 0.2F , 0.3F , 0.5F , 0.6F , 0.8F , 1.0F } ;
512
- blend . Factors = new float [ ] { 0.3F , 0.4F , 0.5F , 0.8F , 1.0F , 1.0F , 0.9F } ;
513
- linearGradientBrush . Blend = blend ;
514
- }
505
+ var linearGradientBrush = new LinearGradientBrush ( bounds , Color . White , backColor , LinearGradientMode . Vertical ) ;
506
+ var blend = new Blend ( ) ;
507
+ blend . Positions = new [ ] { 0.0F , 0.2F , 0.3F , 0.5F , 0.6F , 0.8F , 1.0F } ;
508
+ blend . Factors = new [ ] { 0.3F , 0.4F , 0.5F , 0.8F , 1.0F , 1.0F , 0.9F } ;
509
+ linearGradientBrush . Blend = blend ;
515
510
516
511
return linearGradientBrush ;
517
512
}
0 commit comments