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

Pretty IE Toolbar in C#

, 9 Sep 2008 CPOL
The article describes the work principles and ways of use of IEToolbarEngine. This is a toolbar for Internet Explorer, which has a reusable architecture.
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace IEToolbarEngine
{
    internal class LinkListItem: BaseToolbarItem
    {

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="engine">Toolbar engine</param>
        internal LinkListItem(IEToolbarEngine engine, 
            string caption,  
            string hint, 
            KeyValuePair<string, string>[] links, System.Drawing.Image img)
            : base(engine, img)
        {
            this.Create(caption, hint, links);   
        }

        public override ToolbarItemType TypeID
        {
            get { return ToolbarItemType.LinkList; }
        }

        public void Create (string buttonText,
            string buttonTooltip,            
            KeyValuePair<string,string> [] links)
        {

            this.linkListButton = new System.Windows.Forms.ToolStripSplitButton ();

            this.linkListButton.Image = this.Image;            
            this.linkListButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.linkListButton.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
            this.linkListButton.Text = buttonText;
            this.linkListButton.ToolTipText = buttonTooltip;

            this.linkListButton.ButtonClick += new EventHandler (linkListButton_Click);

            foreach (KeyValuePair <string,string> link in links)
            {
                if (string.IsNullOrEmpty (link.Key))
                {
                    this.linkListButton.DropDownItems.Add (new System.Windows.Forms.ToolStripSeparator ());
                }
                else
                {
                    System.Windows.Forms.ToolStripItem menuItem = this.linkListButton.DropDownItems.Add (link.Key);
                    menuItem.Tag = link.Value;                    
                    menuItem.Click += new EventHandler (menuItem_Click);
                }
            }


            items.Add (this.linkListButton);
            engine.Toolbar.Items.AddRange (this.items.ToArray ());
        }

        void linkListButton_Click (object sender, EventArgs e)
        {
            this.linkListButton.DropDown.Visible = true;
        }

        void menuItem_Click (object sender, EventArgs e)
        {
            System.Windows.Forms.ToolStripMenuItem menuItem = sender as System.Windows.Forms.ToolStripMenuItem;
            this.engine.SmartNavigate (menuItem.Tag.ToString ());
        }


        private System.Windows.Forms.ToolStripSplitButton linkListButton; 
    }
}

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

Alexandr Golovanov
Web Developer
Russian Federation Russian Federation
Alexandr Golovanov is a .NET developer at KB_Soft Group, an offshore software development company located in Russia, Novosibirsk. Here he has worked
on various .NET projects.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.1411028.1 | Last Updated 9 Sep 2008
Article Copyright 2008 by Alexandr Golovanov
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid