ICreate.Controls.Bars Send comments on this topic.
TaskBar Class
See Also  Members   Example 
ICreate.Controls.Bars Namespace : TaskBar Class






A TaskBar is a collapsible container control that can contain any number of TaskBarItem components. Each TaskBarItem is drawn as a hyperlink with optional image on the left.

Object Model


Syntax

Visual Basic (Declaration) 
Public Class TaskBar 
   Inherits Bar
   Implements IMouseEventProcessor 
Visual Basic (Usage)Copy Code
Dim instance As TaskBar
C# 
public class TaskBar : Bar, IMouseEventProcessor  
Delphi 
public class TaskBar = class(Bar, IMouseEventProcessor)
JScript 
public class TaskBar extends Bar implements IMouseEventProcessor 
Managed Extensions for C++ 
public __gc class TaskBar : public Bar, IMouseEventProcessor  
C++/CLI 
public ref class TaskBar : public Bar, IMouseEventProcessor  

Example

This example shows how to create a TaskBar with three TaskBarItem components. It also shows how to subscribe to the TaskBar ItemSelected event.
C#Copy Code
using System; 
using System.Drawing; 
using System.Windows.Forms; 
using ICreate.Controls.Bars; 
 
namespace ExamplesTaskBarCSharp 

    public partial class TaskBarClassExample : Form 
    { 
        public TaskBarClassExample() 
        { 
            InitializeComponent(); 
 
            taskBar = new TaskBar(); 
 
            TaskBarItem alignLeft = new TaskBarItem( "Left", Image.FromFile( @"Resources\left.png" )); 
            TaskBarItem alignCentre = new TaskBarItem( "Centre", Image.FromFile( @"Resources\left.png" )); 
            TaskBarItem alignRight = new TaskBarItem( "Right", Image.FromFile( @"Resources\right.png" )); 
 
            alignLeft.Name = "AlignLeft"; 
            alignCentre.Name = "AlignCentre"; 
            alignRight.Name = "AlignRight"; 
 
            taskBar.Text = "Image alignment"; 
            taskBar.TitleImage = Image.FromFile(@"Resources\alignment.png"); 
            taskBar.Watermark = Image.FromFile(@"Resources\alignment.png"); 
            taskBar.WatermarkBounds = new Rectangle(100, 10, 96, 96); 
            taskBar.Animate = true; 
            taskBar.ItemSelected += new TaskBarItemEventHandler(OnItemSelected); 
 
            taskBar.Items.Add(alignLeft); 
            taskBar.Items.Add(alignCentre); 
            taskBar.Items.Add(alignRight); 
 
            this.Controls.Add(taskBar); 
        } 
 
        void OnItemSelected(object sender, TaskBarItemEventArgs args) 
        { 
            if (args.Item.Name == "AlignLeft") 
                LeftAlignItems(); 
            else if (args.Item.Name == "AlignCentre") 
                CentreAlignItems(); 
            else if (args.Item.Name == "AlignRight") 
                RightAlignItems(); 
        } 
 
        private void LeftAlignItems() 
        { 
            MessageBox.Show("Left align the selected items."); 
        } 
 
        private void CentreAlignItems() 
        { 
            MessageBox.Show("Centre align the selected items."); 
        } 
 
        private void RightAlignItems() 
        { 
            MessageBox.Show("Right align the selected items."); 
        } 
 
        private TaskBar taskBar; 
    } 
}
Visual BasicCopy Code
Imports ICreate.Controls.Bars

Public Class TaskBarClassExample

    Public Sub New()

        InitializeComponent()

        taskBar = New TaskBar
        Dim alignLeft As TaskBarItem = New TaskBarItem("Left", Image.FromFile("Resources\left.png"))
        Dim alignCentre As TaskBarItem = New TaskBarItem("Centre", Image.FromFile("Resources\left.png"))
        Dim alignRight As TaskBarItem = New TaskBarItem("Right", Image.FromFile("Resources\right.png"))

        alignLeft.Name = "AlignLeft"
        alignCentre.Name = "AlignCentre"
        alignRight.Name = "AlignRight"

        taskBar.Text = "Image alignment"
        taskBar.TitleImage = Image.FromFile("Resources\alignment.png")
        taskBar.Watermark = Image.FromFile("Resources\alignment.png")
        taskBar.WatermarkBounds = New Rectangle(100, 10, 96, 96)
        taskBar.Animate = True

        AddHandler taskBar.ItemSelected, AddressOf OnItemSelected

        taskBar.Items.Add(alignLeft)
        taskBar.Items.Add(alignCentre)
        taskBar.Items.Add(alignRight)

        Me.Controls.Add(taskBar)

    End Sub

    Sub OnItemSelected(ByVal sender As Object, ByVal args As TaskBarItemEventArgs)

        If args.Item.Name = "AlignLeft" Then
            LeftAlignItems()
        Else
            If args.Item.Name = "AlignCentre" Then
                CentreAlignItems()
            Else
                If args.Item.Name = "AlignRight" Then
                    RightAlignItems()
                End If
            End If
        End If

    End Sub

    Private Sub LeftAlignItems()

        MessageBox.Show("Left align the selected items.")

    End Sub

    Private Sub CentreAlignItems()

        MessageBox.Show("Centre align the selected items.")

    End Sub

    Private Sub RightAlignItems()

        MessageBox.Show("Right align the selected items.")

    End Sub

    Private taskBar As TaskBar

End Class

Remarks

A TaskBar is a collapsible container control that can contain any number of TaskBarItem components. Each TaskBarItem is drawn as a hyperlink with optional image on the left.

The TaskBar has a title bar and body section. The title bar can include a TitleImage and Text. The TitleImage is drawn on the left side of the title bar. The horizontal position of the Text is set using the TitleTextAlign property, and the TitleFont specifies the Font of the title Text. The TitleBackColor property sets the background colour of the title bar, the TitleForeColor property the colour of the Text on the title bar. The HotTrackTitleBackColor and HotTrackTitleForeColor properties specify these colours when the TaskBar is hot. A TaskBar is hot when it contains the mouse cursor or the input focus.

The body section displays the TaskBarItem Items. Each TaskBarItem can have an Image and Text. The body section can display a Watermark. The WatermarkBounds Rectangle specifies the position and size of the Watermark. The WatermarkOpacity specifies the opacity of the Watermark, and WatermarkHotOpacity the opacity of the Watermark when the TaskBar is hot. The BackColor property represents the colour of the body background. The ForeColor sets the colour of the TaskBarItems Text. This applies to all TaskBarItems owned by the TaskBar. The Text  colour of an individual TaskBarItem can be set using the TaskBarItem ForeColor property. Similarly the Font property determines the Font of the Text for all TaskBarItems. The Font for a particular TaskBarItem can be set using the item's Font property.

The TaskBar can be expanded by calling the Expand method or setting the Collapsed property false. The TaskBar can be collapsed by calling the Collapse method or setting the Collapsed property true. When a TaskBar expands the BarExpanding and BarExpanded events are raised. When a TaskBar collapses the BarCollapsing and BarCollapsed events are raised.

The Style property controls the overall appearance of the TaskBar. The Animate property determines if colour changes are instantaneous or occur as a fade transition. The Animate property also determines if a TaskBar expands and collapses instantaneously or as a number of animated steps.

When a user selects a TaskBarItem the ItemSelected and Click events are raised.

Fore more information on the TaskBar please see Anatomy of TaskBar

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Windows.Forms.Control
            System.Windows.Forms.ScrollableControl
               System.Windows.Forms.ContainerControl
                  ICreate.Controls.Bars.Bar
                     ICreate.Controls.Bars.TaskBar

Requirements

Namespace: ICreate.Controls.Bars

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: ICreate.Controls.Bars (in ICreate.Controls.Bars.dll)

See Also