Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version
Go to top

AlphaGradientPanel, an extended panel

, 24 Mar 2006
A panel that has rounded borders, gradients, and transparency.
Imports System.Drawing.Design
Imports System.ComponentModel

<TypeConverter(GetType(ColorWithAlphaCollectionConverter)), _
Editor(GetType(ColorWithAlphaCollectionEditor), GetType(UITypeEditor)), _
DesignTimeVisible(False), _
ToolboxItem(False), _
Serializable()> _
Public Class ColorWithAlphaCollection
    Inherits CollectionBase
    Implements ICustomTypeDescriptor

    Private ctlParent As Control

    Sub New()

    End Sub

    Sub New(ByVal ParentControl As Control)
        Parent = ParentControl
    End Sub

    <Browsable(False)> _
    Property Parent() As Control
        Get
            Return ctlParent
        End Get
        Set(ByVal value As Control)
            ctlParent = value
        End Set
    End Property

    Protected Overrides Sub OnSet(ByVal index As Integer, ByVal oldValue As Object, ByVal newValue As Object)
        CType(newValue, ColorWithAlpha).Parent = Parent
        MyBase.OnSet(index, oldValue, newValue)
    End Sub

    Protected Overrides Sub OnInsert(ByVal index As Integer, ByVal value As Object)
        CType(value, ColorWithAlpha).Parent = Parent
        MyBase.OnInsert(index, value)
    End Sub

    Default ReadOnly Property Item(ByVal Index As Integer) As ColorWithAlpha
        Get
            Return DirectCast(List(Index), ColorWithAlpha)
        End Get
    End Property

    Public Function Add(ByVal value As ColorWithAlpha) As ColorWithAlpha
        List.Add(value)
        Return value
    End Function

    Public Function Contains(ByVal value As ColorWithAlpha) As Boolean
        Return List.Contains(value)
    End Function

    Public Sub Remove(ByVal value As ColorWithAlpha)
        List.Remove(value)
    End Sub

    Public Function IndexOf(ByVal value As ColorWithAlpha) As Integer
        Return List.IndexOf(value)
    End Function

    Public Sub Insert(ByVal index As Integer, ByVal value As ColorWithAlpha)
        List.Insert(index, value)
    End Sub

    Public Shadows Sub Clear()
        MyBase.Clear()
    End Sub

    Public Function GetAttributes() As System.ComponentModel.AttributeCollection Implements System.ComponentModel.ICustomTypeDescriptor.GetAttributes
        Return TypeDescriptor.GetAttributes(Me, True)
    End Function

    Public Function GetClassName() As String Implements System.ComponentModel.ICustomTypeDescriptor.GetClassName
        Return TypeDescriptor.GetClassName(Me, True)
    End Function

    Public Function GetComponentName() As String Implements System.ComponentModel.ICustomTypeDescriptor.GetComponentName
        Return TypeDescriptor.GetComponentName(Me, True)
    End Function

    Public Function GetConverter() As System.ComponentModel.TypeConverter Implements System.ComponentModel.ICustomTypeDescriptor.GetConverter
        Return TypeDescriptor.GetConverter(Me, True)
    End Function

    Public Function GetDefaultEvent() As System.ComponentModel.EventDescriptor Implements System.ComponentModel.ICustomTypeDescriptor.GetDefaultEvent
        Return TypeDescriptor.GetDefaultEvent(Me, True)
    End Function

    Public Function GetDefaultProperty() As System.ComponentModel.PropertyDescriptor Implements System.ComponentModel.ICustomTypeDescriptor.GetDefaultProperty
        Return TypeDescriptor.GetDefaultProperty(Me, True)
    End Function

    Public Function GetEditor(ByVal editorBaseType As System.Type) As Object Implements System.ComponentModel.ICustomTypeDescriptor.GetEditor
        Return TypeDescriptor.GetEditor(Me, editorBaseType, True)
    End Function

    Public Overloads Function GetEvents() As System.ComponentModel.EventDescriptorCollection Implements System.ComponentModel.ICustomTypeDescriptor.GetEvents
        Return TypeDescriptor.GetEvents(Me, True)
    End Function

    Public Overloads Function GetEvents(ByVal attributes() As System.Attribute) As System.ComponentModel.EventDescriptorCollection Implements System.ComponentModel.ICustomTypeDescriptor.GetEvents
        Return TypeDescriptor.GetEvents(Me, attributes, True)
    End Function

    Public Overloads Function GetProperties() As System.ComponentModel.PropertyDescriptorCollection Implements System.ComponentModel.ICustomTypeDescriptor.GetProperties
        Return Nothing
    End Function

    Public Overloads Function GetProperties(ByVal attributes() As System.Attribute) As System.ComponentModel.PropertyDescriptorCollection Implements System.ComponentModel.ICustomTypeDescriptor.GetProperties
        Dim pdcProperties As New PropertyDescriptorCollection(Nothing)
        For i As Integer = 0 To List.Count - 1
            Dim pdProperty As New ColorWithAlphaCollectionPropertyDescriptor(Me, i)
            pdcProperties.Add(pdProperty)
        Next
        Return pdcProperties
    End Function

    Public Function GetPropertyOwner(ByVal pd As System.ComponentModel.PropertyDescriptor) As Object Implements System.ComponentModel.ICustomTypeDescriptor.GetPropertyOwner
        Return Me
    End Function

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Nicolas Wälti
Software Developer (Senior)
Switzerland Switzerland
No Biography provided

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 24 Mar 2006
Article Copyright 2006 by Nicolas Wälti
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid