Imports System.Convert
Public Class ProgressBlocks
Private prv_blockCount As Integer = 7
Private prv_blockSpacing As Integer = 3
Private prv_activeBlock As Integer = 0
Private prv_marquee As Boolean = False
Public Sub New()
InitializeComponent()
Me.DoubleBuffered = True
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
Me.drawBlocks(e.Graphics)
End Sub
Private Sub drawBlocks(ByVal canvas As Graphics)
Dim blockWidth As Single = ToSingle((Me.Width - Me.Padding.Horizontal - (Me.prv_blockSpacing * (Me.prv_blockCount - 1))) / Me.prv_blockCount)
Dim x As Single = Me.Padding.Left
For i As Integer = 0 To Me.prv_blockCount - 1 Step 1
If i = Me.prv_activeBlock Then
canvas.FillRectangle(Brushes.Orange, x, Me.Padding.Top, blockWidth, Me.Height - Me.Padding.Vertical)
Else
canvas.FillRectangle(Brushes.SlateBlue, x, Me.Padding.Top, blockWidth, Me.Height - Me.Padding.Vertical)
End If
x += blockWidth + Me.prv_blockSpacing
Next
End Sub
Private Sub tmr_marquee_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr_marquee.Tick
Me.prv_activeBlock += 1
If Me.prv_activeBlock >= Me.prv_blockCount Then Me.prv_activeBlock = 0
Me.Refresh()
End Sub
End Class