日期:2014-05-18 浏览次数:20781 次
using (MyProgressBar ms = new MyProgressBar()) { ms.ShowDialog(); }
public class MyProgressBar : Form { public MyProgressBar() : base() { MouseMove += User_MouseMove; MouseUp += User_MouseUp; MouseDown += User_MouseDown; Load += StartupLoad_Load; this.SuspendLayout(); this.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.DoubleBuffered = true; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.ShowInTaskbar = false; this.Text = "进度条"; this.Opacity = 0.7; this.TopMost = true; this.ResumeLayout(false); } private void StartupLoad_Load(object sender, System.EventArgs e) { this.Size = new System.Drawing.Size(258, 30); timer = new System.Threading.Timer(new System.Threading.TimerCallback(TimerChangeInvoke), null, 10, 30); } protected override void Dispose(bool disposing) { try { if (timer != null) { timer.Dispose(); timer = null; } } finally { base.Dispose(disposing); } } /// <summary> /// 阴影坐标 /// </summary> /// <remarks></remarks> private Rectangle backlint = new Rectangle(0, 0, 101, 0); /// <summary> /// 重绘工作区域 /// </summary> /// <param name="e"></param> /// <remarks></remarks> protected override void OnSizeChanged(System.EventArgs e) { base.OnSizeChanged(e); using (GraphicsPath r = new GraphicsPath()) { Rectangle[] re = new Rectangle[] { new Rectangle(2, 0, Width - 4, 1), new Rectangle(1, 1, Width - 2, 1), new Rectangle(0, 2, Width, Height - 4), new Rectangle(1, Height - 2, Width - 2, 1), new Rectangle(2, Height - 1, Width - 4, 1) }; r.AddRectangles(re); this.Region = new Region(r); backlint.Height = this.Height; } this.Refresh(); } /// <summary> /// 重绘窗体 /// </summary> /// <param name="e"></param> /// <remarks></remarks> protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs e) { if (e != null) { Color bordercol = Color.FromArgb(81, 169, 215); Color backcol = Color.FromArgb(228, 242, 249); Color titlecol = Color.FromArgb(24, 122, 174); Color jianbiancol = Color.FromArgb(182, 225, 247); e.Graphics.Clear(Color.White); using (LinearGradientBrush br = new LinearGradientBrush(DisplayRectangle, Color.Transparent, Color.Transparent, 80f)) { ColorBlend sb = new ColorBlend(); sb.Colors = new Color[] {