小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Windows mobile 開發(fā)入門—控件開發(fā)(漂亮的進(jìn)度條)

 江江385 2015-09-23

mobile-rm-50001

 

最終的效果如上圖.它主要是由幾個(gè)圖片繪制而成,左右兩個(gè)圓角、經(jīng)過的、未經(jīng)過的還有一個(gè)%分?jǐn)?shù)。原理非常簡(jiǎn)單,我們看看代碼吧。

Code

  1using System;
  2
  3using System.Collections.Generic;
  4using System.ComponentModel;
  5using System.Data;
  6using System.Drawing;
  7using System.Text;
  8using System.Windows.Forms;
  9using System.Drawing.Imaging;
 10using System.Reflection;
 11
 12namespace Mediar.Controls
 13{
 14    public partial class ProgressBar : Control
 15    {
 16        
 17
 18        private byte maximum = 100;
 19        public byte Maximum
 20        {
 21            set { maximum = value; }
 22            get return maximum; }
 23
 24        }

 25
 26        private byte minimum = 0;
 27        public byte Minimum
 28        {
 29            set { minimum = value; }
 30            get return minimum; }
 31
 32        }

 33       
 34       
 35
 36        public int Value      getset; }
 37
 38
 39        private Color passColor = Color.Blue;
 40        public Color PassColor
 41        {
 42            set { passColor = value; }
 43            get return passColor;  }
 44
 45        }

 46
 47        private Color unPassColor = Color.Gray;
 48        public Color UnPassColor
 49        {
 50            set { unPassColor = value; }
 51            get return unPassColor; }
 52
 53        }

 54
 55        public ProgressBar()
 56        {
 57            this.Height = 33;
 58            InitializeComponent();
 59          
 60        }

 61
 62        protected override void OnPaint(PaintEventArgs pe)
 63        {   
 64
 65            DrawEllipse();
 66
 67
 68            base.OnPaint(pe);
 69        }

 70        private void DrawEllipse()
 71        {
 72            //System.Drawing.Pen myPen;
 73            //myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
 74
 75            Brush bUnPass = new SolidBrush(unPassColor);
 76
 77            Brush bPass = new SolidBrush(passColor);
 78
 79            Assembly assembly = this.GetType().Assembly;
 80            System.IO.Stream passStart = assembly.GetManifestResourceStream(@"Mediar.Controls.Images.passStart.png");
 81            System.IO.Stream pass = assembly.GetManifestResourceStream(@"Mediar.Controls.Images.pass.png");
 82            System.IO.Stream unpass = assembly.GetManifestResourceStream(@"Mediar.Controls.Images.unpass.png");
 83            System.IO.Stream textBackgroud = assembly.GetManifestResourceStream(@"Mediar.Controls.Images.textBackgroud.png");
 84            System.IO.Stream end = assembly.GetManifestResourceStream(@"Mediar.Controls.Images.end.png");
 85
 86
 87            Image passStartpng = new Bitmap(passStart);
 88
 89            System.Drawing.Graphics formGraphics = this.CreateGraphics();
 90
 91            int iPass = (int)((Value * 1.0 / (Maximum - Minimum)) * this.Width);
 92            int y = 10;
 93
 94            formGraphics.DrawImage(passStartpng, 0, y);
 95
 96
 97            formGraphics.DrawImage(new Bitmap(pass), new Rectangle(8, y, iPass, 12), new Rectangle(00112), GraphicsUnit.Pixel);
 98
 99            formGraphics.DrawImage(new Bitmap(unpass), new Rectangle(8 + iPass, y, this.Width - iPass - 1412), new Rectangle(00112), GraphicsUnit.Pixel);
100
101
102            formGraphics.DrawImage(new Bitmap(end), this.Width - 8, y);
103
104            if (this.Width - iPass < 25)
105                iPass = this.Width - 25;
106            else if (iPass < 25)
107                iPass = 25;
108
109
110
111
112            formGraphics.DrawImage(new Bitmap(textBackgroud), iPass - 250);
113
114            SizeF sf = formGraphics.MeasureString(string.Format("{0}%", Value), this.Font);
115            formGraphics.DrawString(string.Format("{0}%", Value), this.Font, new SolidBrush(this.ForeColor), iPass - sf.Width / 2, (33 - sf.Height) / 2);
116
117
118
119
120            bPass.Dispose();
121            formGraphics.Dispose();
122        }

123
124 
125
126
127        internal Color GetTransparentColor(Bitmap image)
128        {
129            return image.GetPixel(00);
130        }

131    }

132}

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多