Class CircularPb Inherits Control Public Property Interval As Integer = 50 Public Property StartAngle As Single = 30 Public Property PenColor As Color = Color.FromArgb(58, 58, 58) Private Pen As New Pen(PenColor, 2) Private Timer As New Timers.Timer(Interval) Private Spokes As List(Of Spoke) = Nothing Private _InnerRadius As Integer = 4 Private _OuterRadius As Integer = 8 Private _AlphaStartValue As Integer = 255 Private _SpokesCount As Integer = 12 Private _AlphaChange As Integer = 0 Private _AlphaLowerLimit As Integer = 15 Private _AngleIncrement As Single = 0 Public Sub New() Me.DoubleBuffered = True Me.Size = New Size(65, 65) Pen.EndCap = Drawing2D.LineCap.Round Pen.StartCap = Drawing2D.LineCap.Round AddHandler Timer.Elapsed, AddressOf OnTimerElapsed 'Start() End Sub Protected Overrides Sub OnSizeChanged(e As EventArgs) MyBase.OnSizeChanged(e) SpokesPoints() End Sub Protected Overrides Sub OnPaint(e As PaintEventArgs) MyBase.OnPaintBackground(e) Dim G As Graphics = e.Graphics G.Clear(BackColor) G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality G.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic Dim alpha As Integer = _AlphaStartValue For i As Integer = 0 To _SpokesCount - 1 Pen.Color = Color.FromArgb(alpha, PenColor) G.DrawLine(Pen, Spokes(i).StartPoint, Spokes(i).EndPoint) alpha -= _AlphaChange If alpha < _AlphaLowerLimit Then alpha = 255 - _AlphaChange Next End Sub Public Sub Start() Timer.Enabled = True End Sub Public Sub [Stop]() Timer.Enabled = False End Sub Private Sub OnTimerElapsed(sender As Object, e As Timers.ElapsedEventArgs) StartAngle += _AngleIncrement If StartAngle >= 360 Then StartAngle = 0 _AlphaStartValue -= _AlphaChange If _AlphaStartValue < _AlphaLowerLimit Then _AlphaStartValue = 255 - _AlphaChange Invalidate() End Sub Private Structure Spoke Public StartPoint As PointF Public EndPoint As PointF Public Sub New(pt1 As PointF, pt2 As PointF) StartPoint = pt1 EndPoint = pt2 End Sub End Structure Private Sub SpokesPoints() Spokes = New List(Of Spoke) _AngleIncrement = (360 / CSng(_SpokesCount)) _AlphaChange = CInt((255 - _AlphaLowerLimit) / _SpokesCount) Dim width As Integer = If((Me.Width < Me.Height), Me.Width, Me.Height) Dim _CentrePt = New PointF(Me.Width / 2, Me.Height / 2) Pen.Width = CInt(width / 15) If Pen.Width < 2 Then Pen.Width = 2 _InnerRadius = CInt(width * 0.175F) _OuterRadius = CInt(width * 0.3125F) Dim angle As Single = 0 For i As Integer = 0 To _SpokesCount - 1 Dim pt1 As New PointF(_InnerRadius * CSng(Math.Cos((Math.PI / CDbl(180)) * angle)), _InnerRadius * CSng(Math.Sin((Math.PI / CDbl(180)) * angle))) Dim pt2 As New PointF(_OuterRadius * CSng(Math.Cos((Math.PI / CDbl(180)) * angle)), _OuterRadius * CSng(Math.Sin((Math.PI / CDbl(180)) * angle))) pt1.X += _CentrePt.X pt1.Y += _CentrePt.Y pt2.X += _CentrePt.X pt2.Y += _CentrePt.Y Spokes.Add(New Spoke(pt1, pt2)) angle -= _AngleIncrement Next End Sub End Class