Previously written by the project itself, a Winfrom user control that mimics the Apple AppStore download progress bar, is drawn by GDI. Effect
1 usingSystem.Drawing;2 usingSystem.Windows.Forms;3 usingSystem.ComponentModel;4 namespaceTest5 {6 Public classCircleprogressbar:control7 {8 float_progress =0F;9 float_wpen =1;Ten float_npen =5; One float_fwidth =Ten; A[Description ("progress bar Color")] - PublicColor Circlecolor - { the Get; - Set; - } -[Description ("outer diameter roughness")] + Public floatWpenthin - { + Get{return_wpen;} A Set{_wpen =value;} at } -[Description ("thickness of inner ring")] - Public floatNpenthin - { - Get{return_npen;} - Set{_npen =value;} in } -[Description ("Inner square side length")] to Public floatFWITDH + { - Get{return_fwidth;} the Set{_fwidth =value;} * } $ Public voidpaintprogress (PaintEventArgs e)Panax Notoginseng { - floatx = This. Width/2; the floaty = This. Height/2;//Center coordinates + floatWr = X-wpenthin/2;//Outer ring Radius A floatNr = X-npenthin/2;//Inner Ring Radius the intWx = (int) (X-Wr); + intWy = (int) (Y-WR);//Outer ring starting coordinates - intNx = (int) (X-Nr); $ intNy = (int) (Y-NR);//Outer ring starting coordinates $ intFy = (int) (y-fwitdh/2); - intFx = (int) (x-fwitdh/2);//Inner Square coordinates -Graphics DC = This. CreateGraphics (); thedc. Clear ( This. BackColor); -Pen Wpen =NewPen (Circlecolor, Wpenthin);WuyiPen Npen =NewPen (Circlecolor, Npenthin); theBrush Fbrush =NewSolidBrush (circlecolor); -dc. SmoothingMode =System.Drawing.Drawing2D.SmoothingMode.HighQuality; Wu floatStartAngle =- -; - floatSweepAngle = Progress/ -* the;//Starting Angle AboutRectangle Wrec =NewRectangle (Wx, Wy,2* (int) Wr,2* (int) Wr); $Rectangle Nrec =NewRectangle (Nx, Ny,2* (int) Nr,2* (int) Nr); -Rectangle Frec =NewRectangle (Fx, Fy, (int) FWITDH, (int) FWITDH); - DC. DrawEllipse (Wpen, wrec); - DC. FillRectangle (Fbrush, Frec); A DC. DrawArc (Npen, Nrec, StartAngle, sweepAngle); + } the Public floatProgress - { $ Get{return_progress;} the Set the { the if(_progress! = value && value >=0&& value <= -) the { -_progress =value; in onprogresschanged (); the } the } About } the protected Virtual voidonprogresschanged () the { the This. Invalidate (); + } - protected Override voidOnPaint (PaintEventArgs e) the {Bayi paintprogress (e); the Base. OnPaint (e); the } - } -}
Imitation apple AppStore download progress bar