Hi,
i found a user control on the net see code below
it is part of VSEssential but I like the coolProgressBar. Zo I want to use
it into my program and I always get the error that it can't find the control
or the control isn't into the toolbar
Who has an idee
Jan
'----------------start code--------------------------------
Imports System.Management
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Imports System.Drawing.Text
Public Class CoolProgressbar
Inherits System.Windows.Forms.Panel
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
Me.Font = New System.Drawing.Font("Arial", 10.0!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
End Sub
'UserControl overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'
'CoolProgressbar
'
Me.Name = "CoolProgressbar"
End Sub
#End Region
#Region " Fillstyle Enumeration "
'enumeration for fillstyles
Public Enum fillstyle
Solid = 0
Gradient = 1
End Enum
#End Region
#Region " Declare Variables & Default Values "
Private m_value As Integer = 0
Private m_maximum As Integer = 100
Private m_fillstyle As LinearGradientMode = LinearGradientMode.Vertical
Private m_fill1 As Color = Color.Red
Private m_fill2 As Color = Color.Black
Private m_border As Color = SystemColors.ControlDark
Private m_borderwidth As Integer = 1
Private m_showpercent As Boolean = True
Private m_showborder As Boolean = True
Private m_TextColor As Color = Color.White
Private m_ShadowColor As Color = Color.Black
Private m_aText As String = ""
Private m_bText As String = ""
Private m_backfillstyle As LinearGradientMode =
LinearGradientMode.Horizontal
Private m_backfill1 As Color = SystemColors.ControlLight
Private m_backfill2 As Color = SystemColors.ControlDark
#End Region
#Region " Public Properties "
Public Property Gradient_BackFill_2() As Color
Get
Return m_backfill2
End Get
Set(ByVal Value As Color)
m_backfill2 = Value
Invalidate()
End Set
End Property
Public Property Gradient_BackFill_1() As Color
Get
Return m_backfill1
End Get
Set(ByVal Value As Color)
m_backfill1 = Value
Invalidate()
End Set
End Property
Public Property BackFill() As LinearGradientMode
Get
Return m_backfillstyle
End Get
Set(ByVal Value As LinearGradientMode)
m_backfillstyle = Value
Invalidate()
End Set
End Property
Public Property BeforeText() As String
Get
Return m_bText
End Get
Set(ByVal Value As String)
m_bText = Value
Invalidate()
End Set
End Property
Public Property AfterText() As String
Get
Return m_aText
End Get
Set(ByVal Value As String)
m_aText = Value
Invalidate()
End Set
End Property
Public Property ShadowColor() As Color
Get
Return m_ShadowColor
End Get
Set(ByVal Value As Color)
m_ShadowColor = Value
Invalidate()
End Set
End Property
Public Property TextColor() As Color
Get
Return m_TextColor
End Get
Set(ByVal Value As Color)
m_TextColor = Value
Invalidate()
End Set
End Property
Public Property Borderwidth() As Integer
Get
Return m_borderwidth
End Get
Set(ByVal Value As Integer)
m_borderwidth = Value
Invalidate()
End Set
End Property
Public Property Border() As Color
Get
Return m_border
End Get
Set(ByVal Value As Color)
m_border = Value
Invalidate()
End Set
End Property
Public Property Showborder() As Boolean
Get
Return m_showborder
End Get
Set(ByVal Value As Boolean)
m_showborder = Value
Invalidate()
End Set
End Property
Public Property ShowPercent() As Boolean
Get
Return m_showpercent
End Get
Set(ByVal Value As Boolean)
m_showpercent = Value
Invalidate()
End Set
End Property
Public Property Gradient_Fill_2() As Color
Get
Return m_fill2
End Get
Set(ByVal Value As Color)
m_fill2 = Value
Invalidate()
End Set
End Property
Public Property Gradient_Fill_1() As Color
Get
Return m_fill1
End Get
Set(ByVal Value As Color)
m_fill1 = Value
Invalidate()
End Set
End Property
Public Property Fill() As LinearGradientMode
Get
Return m_fillstyle
End Get
Set(ByVal Value As LinearGradientMode)
m_fillstyle = Value
Invalidate()
End Set
End Property
Public Property Maximum() As Integer
Get
Return m_maximum
End Get
Set(ByVal Value As Integer)
If Me.Value > Value Then Value = Me.Value
If Value < 1 Then Value = 1
m_maximum = Value
Invalidate()
End Set
End Property
Public Property Value() As Integer
Get
Return m_value
End Get
Set(ByVal Value As Integer)
If Value > Me.Maximum Then Value = Me.Maximum
m_value = Value
Invalidate()
End Set
End Property
#End Region
Public Sub Increment()
If Value < Maximum Then Value += 1
End Sub
Private Function ComputeAreaFill() As Rectangle
If Value > 0 Then
Return New Rectangle(0, 0, Width * Value / Maximum, Height)
Else
Return New Rectangle(0, 0, 1, Height)
End If
End Function
Private Function ComputeTotalArea(ByVal iOffset As Integer) As Rectangle
Return New Rectangle(0, 0, Width - iOffset, Height - iOffset)
End Function
Private Sub DrawFillComplete(ByVal e As Graphics)
Dim rect As Rectangle = ComputeAreaFill()
Dim SBrush As SolidBrush = New SolidBrush(Gradient_Fill_1)
Dim LBrush As LinearGradientBrush = New LinearGradientBrush(rect, m_fill1,
m_fill2, Fill)
Dim BBrush As LinearGradientBrush = New LinearGradientBrush(rect,
m_backfill1, m_backfill2, BackFill)
'draw the background
e.FillRectangle(BBrush, 0, 0, Me.Width, Me.Height)
If Value > 0 Then
'draw the actual progress state
e.FillRectangle(LBrush, rect)
End If
'draw the border if the user wants it
If m_showborder = True Then
e.DrawRectangle(New Pen(m_border, m_borderwidth), ComputeTotalArea(1))
End If
SBrush.Dispose()
LBrush.Dispose()
BBrush.Dispose()
End Sub
Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
DrawFillComplete(e.Graphics)
If ShowPercent Then DrawPercentText(e.Graphics)
End Sub
Private Sub DrawPercentText(ByVal e As Graphics)
Dim sDisplayText As String
Dim TextPercent As Integer
If Value > 0 Then
TextPercent = Math.Round(Value / Maximum * 100)
sDisplayText = CStr(TextPercent)
Else
TextPercent = 0
sDisplayText = CStr(TextPercent)
End If
sDisplayText = sDisplayText & "%"
If m_bText <> "" Then sDisplayText = m_bText & " " & sDisplayText
If m_aText <> "" Then sDisplayText = sDisplayText & " " & m_aText
Dim strsize As SizeF = e.MeasureString(sDisplayText, Font)
Dim OffsetY As Integer
Select Case Me.BorderStyle
Case BorderStyle.Fixed3D : OffsetY = 3
Case Else : OffsetY = 0
End Select
'draw the text
e.DrawString(sDisplayText, Font, New SolidBrush(m_ShadowColor), ((Width -
strsize.Width) / 2), ((Height - strsize.Height) / 2 - OffsetY))
e.DrawString(sDisplayText, Font, New SolidBrush(m_TextColor), ((Width -
strsize.Width) / 2) - 1, ((Height - strsize.Height) / 2 - OffsetY) - 1)
End Sub
End Class