Click here to Skip to main content
15,897,187 members
Articles / Desktop Programming / Windows Forms

MS Office-like TaskPane Control

Rate me:
Please Sign up or sign in to vote.
4.85/5 (25 votes)
24 Apr 2007CPOL10 min read 128.9K   8.4K   262  
A .NET TaskPane control, with full design-time support.
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Text
Imports System.Windows.Forms
Imports Ascend.Windows.Forms

Public Class TaskPanePageActionList
    Inherits DesignerActionList

    Private m_TaskPanePage As TaskPanePage

    ''' <summary>
    ''' Initializes a new instance of the TaskPanePageActionList class.
    ''' </summary>
    ''' <param name="argPage">A TaskPanePage component.</param>
    Public Sub New(ByVal argPage As TaskPanePage)
        MyBase.New(argPage)

        'Me.AutoShow = True
        m_TaskPanePage = argPage
    End Sub

    ''' <summary>
    ''' Gets or sets the Caption to be used for this TaskPanePage
    ''' </summary>
    ''' <value>
    ''' <para>System.String.  The text that appears on the TaskPane dropdown menu.</para>
    ''' <para>This property is read/write</para>
    ''' </value>
    Public Property Caption() As String
        Get
            Return Me.m_TaskPanePage.Caption
        End Get
        Set(ByVal value As String)
            Me.GetPropertyByName("Caption").SetValue(Me.m_TaskPanePage, value)
        End Set
    End Property

    ''' <summary>
    ''' Gets or sets the Caption Image to be used for this TaskPanePage
    ''' </summary>
    ''' <value>
    ''' <para>System.Drawing.Image.  The image that appears on the TaskPane dropdown menu.</para>
    ''' <para>This property is read/write</para>
    ''' </value>
    Public Property CaptionImage() As Image
        Get
            Return Me.m_TaskPanePage.CaptionImage
        End Get
        Set(ByVal value As Image)
            Me.GetPropertyByName("CaptionImage").SetValue(Me.m_TaskPanePage, value)
        End Set
    End Property

    ''' <summary>
    ''' Gets or sets the gradient high (lighter) color for the control.
    ''' </summary>
    ''' <value>
    ''' <para>
    ''' System.Drawing.Color . A Color that represents the gradient high color of the control.
    ''' </para>
    ''' <para>
    ''' This property is read/write. 
    ''' </para>
    ''' </value>
    Public Property GradientHighColor() As Color
        Get
            Return Me.m_TaskPanePage.GradientHighColor
        End Get
        Set(ByVal value As Color)
            Me.GetPropertyByName("GradientHighColor").SetValue(Me.m_TaskPanePage, value)
        End Set
    End Property

    ''' <summary>
    ''' Gets or sets the gradient low (darker) color for the control.
    ''' </summary>
    ''' <value>
    ''' <para>
    ''' System.Drawing.Color . A Color that represents the gradient low color of the control.
    ''' </para>
    ''' <para>
    ''' This property is read/write. 
    ''' </para>
    ''' </value>
    Public Property GradientLowColor() As Color
        Get
            Return Me.m_TaskPanePage.GradientLowColor
        End Get
        Set(ByVal value As Color)
            Me.GetPropertyByName("GradientLowColor").SetValue(Me.m_TaskPanePage, value)
        End Set
    End Property

    ''' <summary>
    ''' Specifies the direction of a linear gradient.
    ''' </summary>
    ''' <value>
    ''' <para>
    ''' System.Drawing.Drawing2D.LinearGradientMode . Specifies the direction of a linear gradient.
    ''' </para>
    ''' <para>
    ''' This property is read/write. 
    ''' </para>
    ''' </value>
    Public Property GradientMode() As LinearGradientMode
        Get
            Return Me.m_TaskPanePage.GradientMode
        End Get
        Set(ByVal value As LinearGradientMode)
            Me.GetPropertyByName("GradientMode").SetValue(Me.m_TaskPanePage, value)
        End Set
    End Property

    ''' <summary>
    ''' Gets or sets the painting style applied to the background in a control.
    ''' </summary>
    ''' <value>
    ''' <para>
    ''' This property is read/write. 
    ''' </para>
    ''' </value>
    Public Property RenderMode() As RenderMode
        Get
            Return Me.m_TaskPanePage.RenderMode
        End Get
        Set(ByVal value As RenderMode)
            Me.GetPropertyByName("RenderMode").SetValue(Me.m_TaskPanePage, value)
        End Set
    End Property

    Private Function GetPropertyByName(ByVal propertyName As String) As PropertyDescriptor
        Dim propertyDescriptor As PropertyDescriptor
        propertyDescriptor = TypeDescriptor.GetProperties(Me.m_TaskPanePage)(propertyName)
        If propertyDescriptor Is Nothing Then
            Throw New ArgumentException("Matching TaskPanePage property not found: " & propertyName)
        Else
            Return propertyDescriptor
        End If
    End Function

    ''' <summary>
    ''' Returns the collection of DesignerActionItem objects contained in the list. 
    ''' </summary>
    ''' <returns>A DesignerActionItem array that contains the items in this list.</returns>
    Public Overrides Function GetSortedActionItems() As DesignerActionItemCollection
        Dim items As DesignerActionItemCollection = New DesignerActionItemCollection

        items.Add(New DesignerActionHeaderItem(m_TaskPanePage.Site.Name & " Actions", "TaskPanePageActions"))

        items.Add(New DesignerActionHeaderItem("TaskPane Menu", "MenuAppearance"))
        items.Add(New DesignerActionTextItem("Controls the appearance of the TaskPane dropdown menu", "MenuAppearance"))
        items.Add(New DesignerActionPropertyItem("Caption", "Caption", "MenuAppearance", "The text that appears on the TaskPane dropdown menu"))
        items.Add(New DesignerActionPropertyItem("CaptionImage", "Caption Image", "MenuAppearance", "The image that appears on the TaskPane dropdown menu"))

        items.Add(New DesignerActionHeaderItem("Appearance", "PanePageAppearance"))
        items.Add(New DesignerActionTextItem("Properties that affect how the control looks", "PanePageAppearance"))
        items.Add(New DesignerActionPropertyItem("RenderMode", "RenderMode", "PanePageAppearance", "Specifies the painting style applied to the background in a control."))
        items.Add(New DesignerActionPropertyItem("GradientHighColor", "GradientHighColor", "PanePageAppearance", "Sets the gradient high (lighter) color for the control."))
        items.Add(New DesignerActionPropertyItem("GradientLowColor", "GradientLowColor", "PanePageAppearance", "Sets the gradient low (darker) color for the control."))
        items.Add(New DesignerActionPropertyItem("GradientMode", "GradientMode", "PanePageAppearance", "Specifies the direction of a linear gradient."))

        Return items
    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)


Written By
Software Developer Microsoft
United States United States
I did some stuff.. I live in Seattle.. now I work for Live Search at Microsoft Smile | :)

Comments and Discussions