Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
ToolBarItemCollection.cs
Package: ProgressBar_src.rar [view]
Upload User: nnpulika
Upload Date: 2013-02-15
Package Size: 597k
Code Size: 4k
Category:
StatusBar
Development Platform:
C#
- using System;
- using System.Diagnostics;
- using System.Collections;
- using System.Windows.Forms;
- using UtilityLibrary.CommandBars;
- namespace UtilityLibrary.Collections
- {
- /// <summary>
- /// Summary description for ToolbarButtonCollection.
- /// </summary>
- public class ToolBarItemCollection : System.Collections.CollectionBase, IEnumerable
- {
- #region Events
- public event EventHandler Changed;
- #endregion
- #region Class Variable
- ToolBarEx parentToolBar = null;
- #endregion
- #region Constructors
- public ToolBarItemCollection(ToolBarEx parent)
- {
- parentToolBar = parent;
- }
- public ToolBarItemCollection()
- {
- }
- #endregion
- #region Methods
- public void Add(ToolBarItem item)
- {
- if ( parentToolBar != null && parentToolBar.PlaceHolderAdded == true )
- parentToolBar.RemovePlaceHolderToolBarItem();
- InnerList.Add(item);
- RaiseChanged();
- }
- public void AddRange(ToolBarItem[] InnerList)
- {
- if ( parentToolBar != null && parentToolBar.PlaceHolderAdded == true )
- parentToolBar.RemovePlaceHolderToolBarItem();
- foreach (ToolBarItem item in InnerList)
- this.InnerList.Add(item);
- RaiseChanged();
- }
- public void Insert(int index, ToolBarItem item)
- {
- if ( parentToolBar != null && parentToolBar.PlaceHolderAdded == true )
- parentToolBar.RemovePlaceHolderToolBarItem();
- InnerList.Insert(index, item);
- RaiseChanged();
- }
- public void Remove(ToolBarItem item)
- {
- // Remove the item from the ToolBar first
- int index = IndexOf(item);
- if ( parentToolBar != null )
- parentToolBar.RemoveToolBarItem(index);
- if (!InnerList.Contains(item)) return;
- InnerList.Remove(item);
- RaiseChanged();
- // If we don't have any items left
- if ( InnerList.Count == 0 && parentToolBar.PlaceHolderAdded == false )
- parentToolBar.AddPlaceHolderToolBarItem();
- }
- public new void Clear()
- {
- // Before wiping out all items from
- // the ToolBarItem collection make sure we also
- // delete the items from the toolBar itself
- for ( int i = 0; i < InnerList.Count; i++ )
- {
- if ( parentToolBar != null )
- parentToolBar.RemoveToolBarItem(i);
- }
- // Now from the collection
- InnerList.Clear();
- // Inform listeners to update
- RaiseChanged();
- // We don't have any bands left, add
- // the ToolBar place holder
- if ( InnerList.Count == 0 && parentToolBar.PlaceHolderAdded == false )
- parentToolBar.AddPlaceHolderToolBarItem();
- }
- public bool Contains(ToolBarItem item)
- {
- return InnerList.Contains(item);
- }
- public int IndexOf(ToolBarItem item)
- {
- return InnerList.IndexOf(item);
- }
- public ToolBarItem this[int index]
- {
- get
- {
- return (ToolBarItem)InnerList[index];
- }
- }
- internal ToolBarItem this[Keys shortcut]
- {
- get
- {
- foreach (ToolBarItem item in InnerList)
- if ( (item.Shortcut == shortcut) && (item.Enabled) && (item.Visible) )
- return item;
- return null;
- }
- }
- internal ToolBarItem this[char mnemonic]
- {
- get
- {
- foreach (ToolBarItem item in InnerList)
- {
- string text = item.Text;
- if ( text != string.Empty && text != null )
- {
- for (int i = 0; i < text.Length; i++)
- {
- if ((text[i] == '&') && (i + 1 < text.Length) && (text[i + 1] != '&'))
- if (mnemonic == Char.ToUpper(text[i + 1]))
- return item;
- }
- }
- }
- return null;
- }
- }
- #endregion
- #region Implementation
- void RaiseChanged()
- {
- if (Changed != null) Changed(this, null);
- }
- #endregion
- }
- }