using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Net6_GeneralUiWinFrm
public class CircularProgressBar : Control
private int progress = 0;
private int borderWidth = 20;
progress = Math.Max(0, Math.Min(100, value));
protected override void OnPaint(PaintEventArgs e)
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
using (Pen pen = new Pen(Color.LightGray, borderWidth))
pen.DashStyle = DashStyle.Dot;
e.Graphics.DrawEllipse(pen, borderWidth / 2, borderWidth / 2, this.Width - borderWidth, this.Height - borderWidth);
using (Pen pen = new Pen(Color.LightGreen, borderWidth))
pen.DashStyle = DashStyle.Solid;
float sweepAngle = (360f * progress) / 100f;
e.Graphics.DrawArc(pen, borderWidth / 2, borderWidth / 2, this.Width - borderWidth, this.Height - borderWidth, -90, sweepAngle);
string progressText = $"{progress}%";
using (Font font = new Font("Arial", 12))
using (Brush brush = new SolidBrush(Color.Black))
SizeF textSize = e.Graphics.MeasureString(progressText, font);
PointF textPoint = new PointF((this.Width - textSize.Width) / 2, (this.Height - textSize.Height) / 2);
e.Graphics.DrawString(progressText, font, brush, textPoint);