internal ObjectCollection(TrayMenuDropDownListItem parent)
 {
     if (null == parent)
     {
         throw new ArgumentNullException();
     }
     Parent = parent;
 }
示例#2
0
        /// <summary>
        /// Notify an item dropdown style has been changed
        /// </summary>
        /// <param name="item">target item</param>
        internal void OnDropDownItemStyleChanged(TrayMenuDropDownListItem item)
        {
            ToolStripComboBox targetStrip = Find(item) as ToolStripComboBox;

            if (null != targetStrip)
            {
                targetStrip.DropDownStyle = (ComboBoxStyle)item.DropDownStyle;
            }
        }
示例#3
0
        /// <summary>
        /// Notify a list item data source has been cleared
        /// </summary>
        /// <param name="item">target item</param>
        internal void OnDropDownItem_ListItemsCleared(TrayMenuDropDownListItem item)
        {
            ToolStripComboBox targetStrip = Find(item) as ToolStripComboBox;

            if (null != targetStrip)
            {
                targetStrip.Items.Clear();
            }
        }
示例#4
0
        /// <summary>
        /// Notify a list item data source has a removed item
        /// </summary>
        /// <param name="item">target item</param>
        /// <param name="listItem">removed item</param>
        /// <param name="listItemIndex">removed item former item index</param>
        internal void OnDropDownItem_ListItemRemoved(TrayMenuDropDownListItem item, object listItem, int listItemIndex)
        {
            ToolStripComboBox targetStrip = Find(item) as ToolStripComboBox;

            if (null != targetStrip)
            {
                targetStrip.Items.Remove(listItem);
            }
        }
示例#5
0
        /// <summary>
        /// Notify a list item data source has new item
        /// </summary>
        /// <param name="item">target item</param>
        /// <param name="listItem">new added list item</param>
        internal void OnDropDownItem_ListItemAdded(TrayMenuDropDownListItem item, object listItem)
        {
            ToolStripComboBox targetStrip = Find(item) as ToolStripComboBox;

            if (null != targetStrip)
            {
                targetStrip.Items.Add(listItem);
            }
        }
示例#6
0
        /// <summary>
        /// Notify an item dropdown max length has been changed
        /// </summary>
        /// <param name="item">target item</param>
        internal int OnDropDownItemMaxLengthChanged(TrayMenuDropDownListItem item)
        {
            ToolStripComboBox targetStrip = Find(item) as ToolStripComboBox;

            if (null != targetStrip)
            {
                try
                {
                    targetStrip.MaxLength = item.MaxLength;
                }
                catch
                {
                    ;
                }
                return(targetStrip.MaxLength);
            }
            else
            {
                return(item.MaxLength);
            }
        }
示例#7
0
        /// <summary>
        /// Notify an item dropdown height has been changed
        /// </summary>
        /// <param name="item">target item</param>
        internal int OnDropDownItemDropDownHeightChanged(TrayMenuDropDownListItem item)
        {
            ToolStripComboBox targetStrip = Find(item) as ToolStripComboBox;

            if (null != targetStrip)
            {
                try
                {
                    targetStrip.DropDownHeight = item.DropDownHeight;
                }
                catch
                {
                    ;
                }
                return(targetStrip.DropDownHeight);
            }
            else
            {
                return(item.DropDownHeight);
            }
        }
示例#8
0
        /// <summary>
        /// Add an item to the collection
        /// </summary>
        /// <param name="text">shown item caption</param>
        /// <param name="visible">item visibility</param>
        /// <param name="image">item image</param>
        /// <param name="itemType">new item type</param>
        ///  <param name="control">custom control</param>
        /// <returns>new created item</returns>
        public virtual TrayMenuItem Add(string text, bool visible, Image image, TrayMenuItemType itemType, object control)
        {
            TrayMenuItem item = null;

            switch (itemType)
            {
            case TrayMenuItemType.Item:
                item = new TrayMenuItem(_owner, text, visible);
                break;

            case TrayMenuItemType.Label:
                item = new TrayMenuLabelItem(_owner, text, visible);
                break;

            case TrayMenuItemType.LinkLabel:
                item = new TrayMenuLinkLabelItem(_owner, text, visible);
                break;

            case TrayMenuItemType.Button:
                item = new TrayMenuButtonItem(_owner, text, visible);
                break;

            case TrayMenuItemType.TextBox:
                item = new TrayMenuTextboxItem(_owner, text, visible);
                break;

            case TrayMenuItemType.CheckBox:
                item = new TrayMenuCheckboxItem(_owner, text, visible);
                break;

            case TrayMenuItemType.Progress:
                item = new TrayMenuProgressItem(_owner, text, visible);
                break;

            case TrayMenuItemType.DropDownList:
                item = new TrayMenuDropDownListItem(_owner, text, visible);
                break;

            case TrayMenuItemType.Separator:
                item = new TrayMenuSeparatorItem(_owner, text, visible);
                break;

            case TrayMenuItemType.Custom:
                if (!(control is System.Windows.Forms.Control))
                {
                    throw new ArgumentOutOfRangeException("control");
                }
                item = new TrayMenuCustomItem(_owner, text, visible, control);
                break;

            case TrayMenuItemType.Monitor:
                item = new TrayMenuMonitorItem(_owner, text, visible);
                break;

            case TrayMenuItemType.AutoClose:
                item = new TrayMenuAutoCloseItem(_owner, text, visible);
                break;

            case TrayMenuItemType.Close:
                item = new TrayMenuCloseItem(_owner, text, visible);
                break;

            default:
                throw new ArgumentOutOfRangeException("itemType");
            }

            item.Image = image;
            _items.Add(item);
            RaiseItemAdded(item);
            return(item);
        }