仿蘋果AppStore 下載進度條

來源:互聯網
上載者:User

標籤:oid   arc   使用者   graphics   turn   ase   rri   hang   protected   

以前項目自己寫的 ,一個模仿蘋果AppStore 下載進度條的winfrom使用者控制項,GDI繪製。效果

 1 using System.Drawing; 2 using System.Windows.Forms; 3 using System.ComponentModel; 4 namespace test 5 { 6     public class CircleProgressBar : Control 7     { 8         float _progress = 0F; 9         float _Wpen = 1;10         float _Npen = 5;11         float _Fwidth = 10;12         [Description("進度條顏色")]13         public Color CircleColor14         {15             get;16             set;17         }18         [Description("外圈粗度")]19         public float WpenThin20         {21             get { return _Wpen; }22             set { _Wpen = value; }23         }24         [Description("內圈粗度")]25         public float NpenThin26         {27             get { return _Npen; }28             set { _Npen = value; }29         }30         [Description("內心方形邊長")]31         public float Fwitdh32         {33             get { return _Fwidth; }34             set { _Fwidth = value; }35         }36         public void PaintProgress(PaintEventArgs e)37         {38             float x = this.Width / 2;39             float y = this.Height / 2;//圓心座標40             float Wr = x - WpenThin / 2;//外圈半徑41             float Nr = x - NpenThin / 2;//內圈半徑42             int Wx = (int)(x - Wr);43             int Wy = (int)(y - Wr);//外圈起始座標44             int Nx = (int)(x - Nr);45             int Ny = (int)(y - Nr);//外圈起始座標46             int Fy = (int)(y - Fwitdh/2);47             int Fx = (int)(x - Fwitdh/2);// 內心方形座標48             Graphics dc = this.CreateGraphics();49             dc.Clear(this.BackColor);50             Pen Wpen = new Pen(CircleColor, WpenThin);51             Pen Npen = new Pen(CircleColor, NpenThin);52             Brush Fbrush = new SolidBrush(CircleColor);53             dc.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;54             float startAngle = -90;55             float sweepAngle = Progress / 100 * 360;//起始角度56             Rectangle Wrec = new Rectangle(Wx, Wy, 2 * (int)Wr, 2 * (int)Wr);57             Rectangle Nrec = new Rectangle(Nx, Ny, 2 * (int)Nr, 2 * (int)Nr);58             Rectangle Frec = new Rectangle(Fx, Fy, (int)Fwitdh, (int)Fwitdh);59             dc.DrawEllipse(Wpen, Wrec);60             dc.FillRectangle(Fbrush, Frec);61             dc.DrawArc(Npen, Nrec, startAngle, sweepAngle);62         }63         public float Progress64         {65             get { return _progress; }66             set67             {68                 if (_progress != value && value >= 0 && value <= 100)69                 {70                     _progress = value;71                     OnProgressChanged();72                 }73             }74         }75         protected virtual void OnProgressChanged()76         {77             this.Invalidate();78         }79         protected override void OnPaint(PaintEventArgs e)80         {81             PaintProgress(e);82             base.OnPaint(e);83         }84     }85 }

 

仿蘋果AppStore 下載進度條

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.