- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- using UtilityLibrary.Menus;
- namespace UtilityLibrary.Collections
- {
- public class MenuCommandCollection : CollectionWithEvents
- {
- #region Class Variables
- protected string extraText;
- protected Font extraFont;
- protected Color extraTextColor;
- protected Brush extraTextBrush;
- protected Color extraBackColor;
- protected Brush extraBackBrush;
- #endregion
- #region Constructors
- public MenuCommandCollection()
- {
- // Define defaults for internal state
- extraText = "";
- extraFont = SystemInformation.MenuFont;
- extraTextColor = SystemColors.ActiveCaptionText;
- extraTextBrush = null;
- extraBackColor = SystemColors.ActiveCaption;
- extraBackBrush = null;
- }
- #endregion
- #region Properties
- public bool VisibleItems()
- {
- foreach(MenuCommand mc in base.List)
- {
- // Is the item visible?
- if (mc.Visible)
- {
- // And its not a separator...
- if (mc.Text != "-")
- {
- // Then should return 'true' except when we are a sub menu item ourself
- // in which case there might not be any visible children which means that
- // this item would not be visible either.
- if ((mc.MenuCommands.Count > 0) && (!mc.MenuCommands.VisibleItems()))
- continue;
- return true;
- }
- }
- }
- return false;
- }
- public string ExtraText
- {
- get { return extraText; }
- set { extraText = value; }
- }
- public Font ExtraFont
- {
- get { return extraFont; }
- set { extraFont = value; }
- }
- public Color ExtraTextColor
- {
- get { return extraTextColor; }
- set { extraTextColor = value; }
- }
- public Brush ExtraTextBrush
- {
- get { return extraTextBrush; }
- set { extraTextBrush = value; }
- }
- public Color ExtraBackColor
- {
- get { return extraBackColor; }
- set { extraBackColor = value; }
- }
- public Brush ExtraBackBrush
- {
- get { return extraBackBrush; }
- set { extraBackBrush = value; }
- }
- public MenuCommand this[int index]
- {
- // Use base class to process actual collection operation
- get { return (base.List[index] as MenuCommand); }
- }
- public MenuCommand this[string text]
- {
- get
- {
- // Search for a MenuCommand with a matching title
- foreach(MenuCommand mc in base.List)
- if (mc.Text == text)
- return mc;
- return null;
- }
- }
- #endregion
- #region Methods
- public MenuCommand Add(MenuCommand _value)
- {
- // Use base class to process actual collection operation
- base.List.Add(_value as object);
- return _value;
- }
- public void AddRange(MenuCommand[] values)
- {
- // Use existing method to add each array entry
- foreach(MenuCommand page in values)
- Add(page);
- }
- public void Remove(MenuCommand value)
- {
- // Use base class to process actual collection operation
- base.List.Remove(value as object);
- }
- public void Insert(int index, MenuCommand value)
- {
- // Use base class to process actual collection operation
- base.List.Insert(index, value as object);
- }
- public bool Contains(MenuCommand value)
- {
- // Use base class to process actual collection operation
- return base.List.Contains(value as object);
- }
- public int IndexOf(MenuCommand value)
- {
- // Find the 0 based index of the requested entry
- return base.List.IndexOf(value);
- }
- #endregion
- }
- }