zoukankan      html  css  js  c++  java
  • ProgressBar进度条绘制

     Rectangle rec = new Rectangle(e.Bounds.X + 327, e.Bounds.Y, this.Width/3, this.Height);
                if (ProgressBarRenderer.IsSupported)
                {
                    ProgressBarRenderer.DrawHorizontalBar(e.Graphics, rec);
                }
                //边框颜色
                Pen pen = new Pen(Color.Black, 1);
                e.Graphics.DrawRectangle(pen, rec);
                //绘制进度条空白处
                e.Graphics.FillRectangle(new SolidBrush(this.BackColor), e.Bounds.X + 327, e.Bounds.Y, rec.Width/2, rec.Height/2);
    
                //进度绘制
                string s = e.CellValue as string;
                string str = s; //s.Substring(0, e.CellValue.ToString().Length - 1);
                for (int i = 0; i < serverList.Count; i++)
                {
                    string servername = serverList[i].name;
                    if (servername == str)
                    {
                        s = serverList[i].online_count_int.ToString();
                        break;
                    }
    
                }
              // s = "10";
                decimal percent = Convert.ToDecimal(s);
                int width = (int)(100 * Math.Abs(percent / 50) * e.Bounds.Width / 50);
                Rectangle rect = new Rectangle(e.Bounds.X+327, e.Bounds.Y, width, e.Bounds.Height);
                Brush b = Brushes.Green;
                if (percent > 20)
                {
                    b = Brushes.Red;
                }
               else if (percent > 10)
                {
                    b = Brushes.Yellow;
                }
                e.Graphics.FillRectangle(b, rect);

  • 相关阅读:
    [Next] 六.next的优化
    [Next] 五.next自定义内容
    Mac解决端口占用
    [Next] 四.在next中引入redux
    [Next] 服务端渲染知识补充
    [Next] 三.next自定义服务器和路由
    哪些使用UDP、TCP、IP协议
    IDEA配置git
    ssm整合配置
    git传输远程仓库
  • 原文地址:https://www.cnblogs.com/xuezhu/p/12844415.html
Copyright © 2011-2022 走看看