Progressbar like Google Chrom



private void PaintProgress(PaintEventArgs e)
{
  using( SolidBrush progressBrush = new SolidBrush(this.ProgressColor))
  {
      Rectangle rect = LayoutInternal.ProgressRectangle;
      rect.Inflate(-2, -2);
      rect.Height -= 2; rect.Width -= 2;
      float startAngle = -90;
      float sweepAngle = Progress / 100 * 360;
      e.Graphics.FillPie(progressBrush, rect, startAngle, sweepAngle);
  }
}
//----------------------------------------------------------------
private void PaintBorder(PaintEventArgs e)
{
   GraphicsPath borderPath = new GraphicsPath();
   Rectangle progressRect = LayoutInternal.ProgressRectangle;
   borderPath.AddArc(progressRect, 0, 360);
   ....
   ....
   ....
   using (Pen borderPen = new Pen(this.BorderColor, 2))
   {
       e.Graphics.DrawPath(borderPen, borderPath);
       e.Graphics.DrawLine(borderPen,
           new Point(progressRect.Left + progressRect.Width / 2, progressRect.Top),
           new Point(progressRect.Left + progressRect.Width / 2, progressRect.Bottom));
       e.Graphics.DrawLine(borderPen,
           new Point(progressRect.Left, progressRect.Top + progressRect.Height / 2),
           new Point(progressRect.Right, progressRect.Top + progressRect.Height / 2));
       e.Graphics.DrawLine(borderPen,
            new Point(progressRect.Left ,progressRect.Top),
            new Point(progressRect.Right,progressRect.Bottom));
       e.Graphics.DrawLine(borderPen,
           new Point(progressRect.Left, progressRect.Bottom),
           new Point(progressRect.Right, progressRect.Top ));
   }
   e.Graphics.Clip = clip;
}

No comments: