cant find UserControl in toolbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JR

    cant find UserControl in toolbox

    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.Manageme nt

    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.

    InitializeCompo nent()

    'Add any initialization after the InitializeCompo nent() call

    Me.Font = New System.Drawing. Font("Arial", 10.0!,
    System.Drawing. FontStyle.Bold, System.Drawing. GraphicsUnit.Po int, 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.Disp ose()

    End If

    End If

    MyBase.Dispose( disposing)

    End Sub

    'Required by the Windows Form Designer

    Private components As System.Componen tModel.IContain er

    '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.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent()

    '

    'CoolProgressba r

    '

    Me.Name = "CoolProgressba r"

    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 LinearGradientM ode = LinearGradientM ode.Vertical

    Private m_fill1 As Color = Color.Red

    Private m_fill2 As Color = Color.Black

    Private m_border As Color = SystemColors.Co ntrolDark

    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 LinearGradientM ode =
    LinearGradientM ode.Horizontal

    Private m_backfill1 As Color = SystemColors.Co ntrolLight

    Private m_backfill2 As Color = SystemColors.Co ntrolDark

    #End Region

    #Region " Public Properties "

    Public Property Gradient_BackFi ll_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_BackFi ll_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 LinearGradientM ode

    Get

    Return m_backfillstyle

    End Get

    Set(ByVal Value As LinearGradientM ode)

    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 LinearGradientM ode

    Get

    Return m_fillstyle

    End Get

    Set(ByVal Value As LinearGradientM ode)

    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 ComputeTotalAre a(ByVal iOffset As Integer) As Rectangle

    Return New Rectangle(0, 0, Width - iOffset, Height - iOffset)

    End Function

    Private Sub DrawFillComplet e(ByVal e As Graphics)

    Dim rect As Rectangle = ComputeAreaFill ()

    Dim SBrush As SolidBrush = New SolidBrush(Grad ient_Fill_1)

    Dim LBrush As LinearGradientB rush = New LinearGradientB rush(rect, m_fill1,
    m_fill2, Fill)

    Dim BBrush As LinearGradientB rush = New LinearGradientB rush(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), ComputeTotalAre a(1))

    End If

    SBrush.Dispose( )

    LBrush.Dispose( )

    BBrush.Dispose( )

    End Sub



    Protected Overrides Sub OnPaint(ByVal e As
    System.Windows. Forms.PaintEven tArgs)

    MyBase.OnPaint( e)

    DrawFillComplet e(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(Valu e / Maximum * 100)

    sDisplayText = CStr(TextPercen t)

    Else

    TextPercent = 0

    sDisplayText = CStr(TextPercen t)

    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.Fix ed3D : OffsetY = 3

    Case Else : OffsetY = 0

    End Select

    'draw the text

    e.DrawString(sD isplayText, Font, New SolidBrush(m_Sh adowColor), ((Width -
    strsize.Width) / 2), ((Height - strsize.Height) / 2 - OffsetY))

    e.DrawString(sD isplayText, Font, New SolidBrush(m_Te xtColor), ((Width -
    strsize.Width) / 2) - 1, ((Height - strsize.Height) / 2 - OffsetY) - 1)

    End Sub

    End Class




Working...