zoukankan      html  css  js  c++  java
  • C#控件之:进度条(ProgressBar)

    一、重绘进度条

    public class CustomProgressBar:ProgressBar
        {
            public CustomProgressBar()
            {
                this.SetStyle(ControlStyles.UserPaint, true);
                this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            }
            protected override void OnPaint(PaintEventArgs e)
            {
                SolidBrush brush = null;
                Rectangle rec = new Rectangle(0, 0, this.Width, this.Height);
    
                if(ProgressBarRenderer.IsSupported)
                {
                    ProgressBarRenderer.DrawHorizontalBar(e.Graphics, rec);
                }
                Pen pen = new Pen(this.ForeColor, 1);
                e.Graphics.DrawRectangle(pen, rec);
                e.Graphics.FillRectangle(new SolidBrush(this.BackColor), 2, 2, rec.Width - 4, rec.Height - 4);
    
                rec.Height -= 4;
                rec.Width = (int)(rec.Width * ((double)Value / Maximum)) - 4;
                brush = new SolidBrush(this.ForeColor);
                e.Graphics.FillRectangle(brush, 2, 2, rec.Width, rec.Height);
            }
        }
  • 相关阅读:
    CF 13B Letter A
    CF12D Ball
    题解 CF11C
    CF10E Greedy Change
    CF10D LCIS&&Acwing 272
    CF10C Digital Root
    yLOI2019 青原樱
    js有关时间日期的操作
    js 读取 cookie
    nginx有关.htaccess小结
  • 原文地址:https://www.cnblogs.com/tinaluo/p/7453731.html
Copyright © 2011-2022 走看看