1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim g As Graphics = e.Graphics
Dim r As New Rectangle(0, 0, Me.Width - 1, Me.Height - 1)
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias
g.CompositingQuality = CompositingQuality.HighQuality
Dim center As New PointF(r.Width / 2, r.Height / 2)
Dim innerR As Integer = CInt(center.X / 2)
Dim thickness As Integer = CInt(center.Y / 2)
Dim startAngle As Integer = 180
Dim arcLength As Integer = 180
Dim outerR = innerR + thickness
Dim outerRect As New Rectangle(center.X - outerR, center.Y - outerR, 2 * outerR, 2 * outerR)
Dim innerRect As New Rectangle(center.X - innerR, center.Y - innerR, 2 * innerR, 2 * innerR)
Using p As New GraphicsPath()
p.AddArc(outerRect, startAngle, arcLength)
p.AddArc(innerRect, startAngle + arcLength, -arcLength)
p.CloseFigure()
g.FillPath(New SolidBrush(Me.BackColor), p)
g.DrawPath(New Pen(New SolidBrush(Color.Black), 4), p)
End Using
end sub |
Partager