Esempio n. 1
0
        /// <summary>
        /// Notify an item text max length has been changed
        /// </summary>
        /// <param name="item">target item</param>
        internal int OnTextBoxItemMaxLengthChanged(TrayMenuTextboxItem item)
        {
            ToolStripTextBox targetStrip = Find(item) as ToolStripTextBox;

            if (null != targetStrip)
            {
                try
                {
                    targetStrip.MaxLength = item.MaxLength;
                }
                catch
                {
                    ;
                }
                return(targetStrip.MaxLength);
            }
            else
            {
                return(item.MaxLength);
            }
        }
Esempio n. 2
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);
        }