Multi Colored Progress Bar
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
First New Project. Then New Class. Delete All Code And Add This
Code: Select all
Imports System.Drawing.Drawing2D
Class MultiColorProgressBar
Inherits Control
#Region " Properties "
Private _Maximum As Double = 100
Public Property Maximum() As Double
Get
Return _Maximum
End Get
Set(ByVal v As Double)
_Maximum = v
Value = _Current / v * 100
Invalidate()
End Set
End Property
Private _Current As Double
Public Property Current() As Double
Get
Return _Current
End Get
Set(ByVal v As Double)
_Current = v
Value = v / _Maximum * 100
Invalidate()
End Set
End Property
Private _Value As Integer
Public Property Value() As Double
Get
Return _Value
End Get
Set(ByVal v As Double)
If v < 0 Then v = 0 Else If v > 100 Then v = 100
_Value = Convert.ToInt32(v)
_Current = v * 0.01 * _Maximum
If Width > 0 Then UpdateProgress()
Invalidate()
End Set
End Property
Dim C2 As Color = Color.FromArgb(6, 96, 149) 'Dark Color
Public Property Color1() As Color
Get
Return C2
End Get
Set(ByVal v As Color)
C2 = v
UpdateColors()
Invalidate()
End Set
End Property
Dim C3 As Color = Color.FromArgb(70, 167, 220) 'Light color
Public Property Color2() As Color
Get
Return C3
End Get
Set(ByVal v As Color)
C3 = v
UpdateColors()
Invalidate()
End Set
End Property
#End Region
Protected Overrides Sub OnPaintBackground(ByVal pevent As PaintEventArgs)
End Sub
Dim G As Graphics, B As Bitmap, R1, R2 As Rectangle, X As ColorBlend
Dim C1 As Color, P1, P2, P3 As Pen, B1, B2 As LinearGradientBrush, B3 As SolidBrush
Sub New()
C1 = Color.FromArgb(22, 22, 22) 'Background
P1 = New Pen(Color.FromArgb(70, Color.White), 2)
P2 = New Pen(C2)
P3 = New Pen(Color.FromArgb(49, 49, 49)) 'Highlight
B3 = New SolidBrush(Color.FromArgb(100, Color.White))
X = New ColorBlend(4)
X.Colors = New Color() {C2, C3, C3, C2}
X.Positions = New Single() {0.0F, 0.1F, 0.9F, 1.0F}
R2 = New Rectangle(2, 2, 2, 2)
B2 = New LinearGradientBrush(R2, Nothing, Nothing, 180.0F)
B2.InterpolationColors = X
End Sub
Sub UpdateColors()
P2.Color = C2
X.Colors = New Color() {C2, C3, C3, C2}
B2.InterpolationColors = X
End Sub
Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
R1 = New Rectangle(0, 1, Width, 4)
B1 = New LinearGradientBrush(R1, Color.FromArgb(60, Color.Black), Color.Transparent, 90.0F)
UpdateProgress()
Invalidate()
MyBase.OnSizeChanged(e)
End Sub
Sub UpdateProgress()
If _Value = 0 Then Return
R2 = New Rectangle(2, 2, Convert.ToInt32((Width - 4) * (_Value * 0.01)), Height - 4)
B2 = New LinearGradientBrush(R2, Nothing, Nothing, 180.0F)
B2.InterpolationColors = X
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
B = New Bitmap(Width, Height)
G = Graphics.FromImage(B)
G.Clear(C1)
G.FillRectangle(B1, R1)
If _Value > 0 Then
G.FillRectangle(B2, R2)
G.FillRectangle(B3, 2, 3, R2.Width, 4)
G.DrawRectangle(P1, 4, 4, R2.Width - 4, Height - 8)
G.DrawRectangle(P2, 2, 2, R2.Width - 1, Height - 5)
End If
G.DrawRectangle(P3, 0, 0, Width - 1, Height - 1)
e.Graphics.DrawImage(B, 0, 0)
G.Dispose()
B.Dispose()
End Sub
End Class
nice im going to use this cooll;
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that 

nice, does it have increment?
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
can someone tell me how to get this to work properly
just add a new class, delete all the new classes code add my code run program stop program and u have a new item in your toolbox
Copyright Information
Copyright © Codenstuff.com 2020 - 2023