Click here to Skip to main content
15,886,788 members
Articles / Programming Languages / C#

A .NET Wizard control

Rate me:
Please Sign up or sign in to vote.
4.86/5 (89 votes)
24 Apr 2003CPOL7 min read 660.6K   8.7K   216  
A .NET Wizard control for the VS.IDE and client apps
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Data;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;
using System.Reflection;
using System.IO;
using System.Drawing.Design;

using UtilityLibrary.Collections;
using UtilityLibrary.Win32;
using UtilityLibrary.General;
using UtilityLibrary.Menus;


namespace UtilityLibrary.WinControls
{
  [ToolboxItem(false)]
  public class OutlookBarItem : Component
  {
    #region Class variables
    private string    m_strText = "";
    private string    m_strToolTip = "";
    private int       m_iImageIndex = -1;
    private object    m_tag;
    private ImageList m_imgList;
    private bool      m_checked;  
    private OutlookBar m_bar;
    #endregion

    #region Class Events
    [Category("Property Changed")]
    public event EventHandler Changed;
    
    [Category("Property Changed")]
    public event EventHandler ImageIndexChanged;
    
    [Category("Property Changed")]
    public event EventHandler ImageListChanged;
    
    [Category("Property Changed")]
    public event EventHandler TextChanged;
    
    [Category("Property Changed")]
    public event EventHandler TagChanged;
    
    [Category("Property Changed")]
    public event EventHandler ToolTipChanged;
    #endregion
    
    #region Class Constructors
    public OutlookBarItem( OutlookBar bar, string text, int ImageIndex )
    {
      m_bar = bar;
      m_strText = text;
      m_iImageIndex = ImageIndex;
    }

    public OutlookBarItem( OutlookBar bar, string text, int imageIndex, object tag )
    {
      m_bar = bar;
      m_strText = text;
      m_iImageIndex = imageIndex;
      m_tag = tag;
    }

    public OutlookBarItem( )
    {
      m_bar = null;
      // To support designer
      m_iImageIndex = -1;
    }
    #endregion

    #region Overrides
    protected virtual void OnImageIndexChanged()
    {
      RaiseImageIndexChangedEvent();
    }
    
    protected virtual void OnImageListChanged()
    {
      RaiseImageListChangedEvent();
    }
    
    protected virtual void OnTextChanged()
    {
      RaiseTextChangedEvent();
    }
    
    protected virtual void OnToolTipChanged()
    {
      RaiseToolTipChangedEvent();
    }
    
    protected virtual void OnTagChanged()
    {
      RaiseTagChangedEvent();
    }
    
    #endregion

    #region Methods 
    protected void RaiseChangedEvent()
    {
      if( Changed != null )
      {
        Changed( this, EventArgs.Empty );
      }
    }

    protected void RaiseImageIndexChangedEvent()
    {
      if( ImageIndexChanged != null )
      {
        ImageIndexChanged( this, EventArgs.Empty );
      }
      
      RaiseChangedEvent();
    }
    protected void RaiseImageListChangedEvent()
    {
      if( ImageListChanged != null )
      {
        ImageListChanged( this, EventArgs.Empty );
      }
      
      RaiseChangedEvent();
    }
    
    protected void RaiseTextChangedEvent()
    {
      if( TextChanged != null )
      {
        TextChanged( this, EventArgs.Empty );
      }
      
      RaiseChangedEvent();
    }
    
    protected void RaiseToolTipChangedEvent()
    {
      if( ToolTipChanged != null )
      {
        ToolTipChanged( this, EventArgs.Empty );
      }
      
      RaiseChangedEvent();
    }
    
    protected void RaiseTagChangedEvent()
    {
      if( TagChanged != null )
      {
        TagChanged( this, EventArgs.Empty );
      }
      
      RaiseChangedEvent();
    }
    
    #endregion
    
    #region Properties
    [DefaultValue(-1), Category( "Appearance" )]
    [Editor("System.Windows.Forms.Design.ImageIndexEditor, System.Design, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))]
    [TypeConverter("System.Windows.Forms.ImageIndexConverter")]
    public int        ImageIndex
    {
      get 
      { 
        return m_iImageIndex; 
      }
      set 
      { 
        if( value != m_iImageIndex )
        {
          m_iImageIndex = value; 
          OnImageIndexChanged();
        }
      }
    }

    [ DefaultValue( null ), Category( "Appearance" )]
    public ImageList  ImageList
    {
      get
      {
        return m_imgList;
      }
      set
      {
        if( value != m_imgList )
        {
          m_imgList = value;
          OnImageListChanged();
        }
      }
    }
    
    [ DefaultValue(""), Category( "Appearance" ), Description( "GET/SET text to display" )]
    public string     Text
    {
      get 
      { 
        return m_strText; 
      }
      set 
      { 
        if( value != m_strText )
        {
          m_strText = value; 
          OnTextChanged();
        }
      }
    }

    [DefaultValue(""), Category( "Appearance" ), Description( "GET/SET item tooltip" )]
    public string     ToolTip
    {
      get
      {
        return m_strToolTip;
      }
      set
      {
        if( value != m_strToolTip )
        {
          m_strToolTip = value;
          OnToolTipChanged();
        }
      }
    }
    
    [ DefaultValue( null ), Category( "Data" ), Description( "User defined data asociated with item" ) ]
    public object     Tag
    {
      get 
      { 
        return m_tag; 
      }
      set 
      { 
        if( value != m_tag )
        {
          m_tag = value; 
          OnTagChanged();
        }
      }
    }
    
    [DefaultValue(false), Category( "Appearance" ), Description( "GET/SET item checked state" )]
    public bool       Checked 
    {
      get
      {
        return m_checked;
      }
      set
      {
        if ( value != m_checked ) 
        {
          m_checked = value;
          
          if ( m_bar != null ) 
            m_bar.Invalidate();
        }
      }
    }
    #endregion
  }
}

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
CEO ArtfulBits Inc.
Ukraine Ukraine
Name:Kucherenko Oleksandr

Born:September 20, 1979

Platforms: Win32, Linux; - well known and MS-DOS; Win16; OS/2 - old time not touched;

Hardware: IBM PC

Programming Languages: Assembler (for Intel 80386); Borland C/C++; Borland Pascal; Object Pascal; Borland C++Builder; Delphi; Perl; Java; Visual C++; Visual J++; UML; XML/XSL; C#; VB.NET; T-SQL; PL/SQL; and etc.

Development Environments: MS Visual Studio 2001-2008; MS Visual C++; Borland Delphi; Borland C++Builder; C/C++ any; Rational Rose; GDPro; Together and etc.

Libraries: STL, ATL, WTL, MFC, NuMega Driver Works, VCL; .NET 1.0, 1.1, 2.0, 3.5; and etc.

Technologies: Client/Server; COM; DirectX; DirectX Media; BDE; HTML/DHTML; ActiveX; Java Servlets; DCOM; COM+; ADO; CORBA; .NET; Windows Forms; GDI/GDI+; and etc.

Application Skills: Databases - design and maintain, support, programming; GUI Design; System Programming, Security; Business Software Development. Win/Web Services development and etc.

Comments and Discussions