Beispiel #1
0
        /// <summary>
        /// Notify item progress minimum has been changed
        /// </summary>
        /// <param name="item">target item</param>
        internal int OnProgressItemMinimumChanged(TrayMenuProgressItem item)
        {
            ToolStripProgressBar targetStrip = Find(item) as ToolStripProgressBar;

            if (null != targetStrip)
            {
                try
                {
                    targetStrip.Minimum = item.Minimum;
                }
                catch
                {
                    ;
                }
            }
            return(targetStrip.Minimum);
        }
        /// <summary>
        /// Notify item progress value has been changed
        /// </summary>
        /// <param name="item">target item</param>
        internal int OnProgressItemValueChanged(TrayMenuProgressItem item)
        {
            ToolStripProgressBar targetStrip = Find(item) as ToolStripProgressBar;

            if (null != targetStrip)
            {
                try
                {
                    targetStrip.Value = item.Value;
                }
                catch
                {
                    ;
                }
            }
            return(targetStrip.Value);
        }
Beispiel #3
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);
        }