1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| Imports System.Drawing.Drawing2D
Public Class CirculaireProgressbar : Inherits ProgressBar
Public Sub New()
Me.SetStyle(ControlStyles.OptimizedDoubleBuffer Or ControlStyles.UserPaint, True)
Me.Size = New Size(180, 160)
End Sub
Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
Dim rect As New Rectangle(0, 0, Me.Width, Me.Height)
Dim g As Graphics = e.Graphics
g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
Using p As New GraphicsPath
g.ResetClip()
p.AddEllipse(New Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3))
g.FillPath(New SolidBrush(Color.DodgerBlue), p)
p.AddEllipse(New Rectangle(CInt(rect.Width / 4), CInt(rect.Height / 4), CInt(rect.Width / 2), CInt(rect.Height / 2)))
g.DrawPath(New Pen(New SolidBrush(Color.Black), 3), p)
g.FillPath(Brushes.Blue, p)
g.SetClip(p, CombineMode.Intersect)
Dim HeightH As Integer = CInt((rect.Height / (Maximum - Minimum)) * Value)
g.FillRectangle(New SolidBrush(Color.FromArgb(224, 224, 224)), New Rectangle(rect.X, rect.Height - HeightH, rect.Width, HeightH))
End Using
If g Is Nothing Then g.Dispose()
End Sub
End Class |
Partager