Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class AetherCircular
- Inherits Control
- Private G As Graphics
- Private ProgressAngle As Single
- Private RemainderAngle As Single
- Private ExceedingLimits As Boolean
- Private ExceedingSign As String
- Private _Progress As Single
- Private _Max As Single = 100
- Private _Min As Single = 0
- Public Property Percent As Boolean = True
- Public Property Progress As Single
- Get
- Return _Progress
- End Get
- Set(value As Single)
- Select Case value
- Case Is > Max
- value = Max
- ExceedingSign = "+"
- ExceedingLimits = True
- Invalidate()
- Case Is < Min
- value = Min
- ExceedingSign = "-"
- ExceedingLimits = True
- Invalidate()
- End Select
- _Progress = value
- Invalidate()
- End Set
- End Property
- Public Property Max As Single
- Get
- Return _Max
- End Get
- Set(value As Single)
- Select Case value
- Case Is < _Progress
- _Progress = value
- End Select
- _Max = value
- Invalidate()
- End Set
- End Property
- Public Property Min As Single
- Get
- Return _Min
- End Get
- Set(value As Single)
- Select Case value
- Case Is > _Progress
- _Progress = value
- End Select
- _Min = value
- Invalidate()
- End Set
- End Property
- Public Property Border As Color = Color.LightGray
- Public Property HatchPrimary As Color = Color.Green
- Public Property HatchSecondary As Color = Color.Red
- Public Property PostText As String = "%"
- Public Property ShowMax As Boolean = False
- Public Property HatchBrush As Boolean = False
- Sub New()
- DoubleBuffered = True
- Size = New Size(128, 128)
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- G = e.Graphics
- G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
- G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
- MyBase.OnPaint(e)
- ProgressAngle = 360 / Max * Progress
- RemainderAngle = 360 - ProgressAngle
- If HatchBrush Then
- Using P1 As New Pen(New Drawing2D.HatchBrush(Drawing2D.HatchStyle.LightUpwardDiagonal, HatchPrimary, HatchSecondary), 4), P2 As New Pen(Border, 4)
- G.DrawArc(P1, New Rectangle(2, 2, Width - 5, Height - 5), -90, ProgressAngle)
- G.DrawArc(P2, New Rectangle(2, 2, Width - 5, Height - 5), ProgressAngle - 90, RemainderAngle)
- End Using
- Else
- Using P1 As New Pen(HatchPrimary, 4), P2 As New Pen(Border, 4)
- G.DrawArc(P1, New Rectangle(2, 2, Width - 5, Height - 5), -90, ProgressAngle)
- G.DrawArc(P2, New Rectangle(2, 2, Width - 5, Height - 5), ProgressAngle - 90, RemainderAngle)
- End Using
- End If
- If Percent Then
- Using F1 As New Font("Segoe UI", 9, FontStyle.Bold)
- Dim Progress_Text As String = ""
- If ShowMax Then
- Progress_Text = Progress & "/" & Max & " " & PostText
- Else
- Progress_Text = Progress & PostText
- End If
- If ExceedingLimits Then
- CenterString(G, Progress_Text & ExceedingSign, F1, Color.FromArgb(100, 100, 100), New Rectangle(1, 1, Width, Height + 1))
- Else
- CenterString(G, Progress_Text, F1, Color.FromArgb(100, 100, 100), New Rectangle(1, 1, Width, Height + 1))
- End If
- End Using
- Else
- If ExceedingLimits Then
- CenterString(G, Progress & ExceedingSign, New Font("Segoe UI", 9, FontStyle.Bold), Color.FromArgb(100, 100, 100), New Rectangle(1, 1, Width, Height + 1))
- Else
- CenterString(G, Progress, New Font("Segoe UI", 9, FontStyle.Bold), Color.FromArgb(100, 100, 100), New Rectangle(1, 1, Width, Height + 1))
- End If
- End If
- ExceedingLimits = False
- CenterString(G, Text.ToUpper, New Font("Segoe UI", 6, FontStyle.Bold), Color.FromArgb(170, 170, 170), New Rectangle(2, 2, Width, Height + 27))
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment