/// <summary>
        /// Notify an item image has been changed
        /// </summary>
        /// <param name="item">target item</param>
        internal void OnItemImageChanged(TrayMenuItem item)
        {
            ToolStripItem targetStrip = Find(item);

            if (null != targetStrip)
            {
                targetStrip.Image = item.Image;
            }
        }
        /// <summary>
        /// Notify an item back color has been changed
        /// </summary>
        /// <param name="item">target item</param>
        internal void OnItemBackColorChanged(TrayMenuItem item)
        {
            ToolStripItem targetStrip = Find(item);

            if (null != targetStrip)
            {
                targetStrip.BackColor = item.BackColor;
            }
        }
        /// <summary>
        /// Notify an item enabled state has been changed
        /// </summary>
        /// <param name="item">target item</param>
        internal void OnItemEnabledChanged(TrayMenuItem item)
        {
            ToolStripItem targetStrip = Find(item);

            if (null != targetStrip)
            {
                targetStrip.Enabled = item.Enabled;
            }
        }
        /// <summary>
        /// Notify an item tooltip has been changed
        /// </summary>
        /// <param name="item">target item</param>
        internal void OnItemToolTipTextChanged(TrayMenuItem item)
        {
            ToolStripItem targetStrip = Find(item);

            if (null != targetStrip)
            {
                targetStrip.ToolTipText = item.ToolTipText;
            }
        }
        /// <summary>
        /// Notify an item visibility has been changed
        /// </summary>
        /// <param name="item">target item</param>
        internal void OnItemVisibleChanged(TrayMenuItem item)
        {
            ToolStripItem targetStrip = Find(item);

            if (null != targetStrip)
            {
                targetStrip.Visible = item.Visible;
            }
        }
 /// <summary>
 /// Raise the ItemKeyPress event
 /// </summary>
 /// <param name="item">target item</param>
 /// <param name="args">event arguments</param>
 private void RaiseItemKeyPress(TrayMenuItem item, KeyPressEventArgs args)
 {
     if (null != ItemKeyPress)
     {
         TrayMenuItemKeyPressEventArgs wrapperArgs = new TrayMenuItemKeyPressEventArgs(args.KeyChar);
         ItemKeyPress(this, wrapperArgs);
         args.Handled = wrapperArgs.Handled;
     }
 }
        /// <summary>
        /// Notify an item font has been changed
        /// </summary>
        /// <param name="item">target item</param>
        internal void OnItemFontChanged(TrayMenuItem item)
        {
            ToolStripItem targetStrip = Find(item);

            if (null != targetStrip)
            {
                targetStrip.Font = item.Font;
            }
        }
        /// <summary>
        /// Notify an item text align has been changed
        /// </summary>
        /// <param name="item">target item</param>
        internal void OnItemTextAlignChanged(TrayMenuItem item)
        {
            ToolStripItem targetStrip = Find(item);

            if (null != targetStrip)
            {
                targetStrip.TextAlign = item.TextAlign;
            }
        }
Пример #9
0
 /// <summary>
 /// Raise the ItemKeyUp event
 /// </summary>
 /// <param name="item">target item</param>
 /// <param name="args">event arguments</param>
 private void RaiseItemKeyUp(TrayMenuItem item, KeyEventArgs args)
 {
     if (null != ItemKeyUp)
     {
         ToolsKeys keyData   = (ToolsKeys)args.KeyData;
         ToolsKeys keyCode   = (ToolsKeys)args.KeyCode;
         ToolsKeys modifiers = (ToolsKeys)args.Modifiers;
         TrayMenuItemKeyEventArgs wrapperArgs = new TrayMenuItemKeyEventArgs(item, keyData, args.Alt, args.Control, args.Handled, keyCode, args.KeyValue, modifiers, args.Shift, args.SuppressKeyPress);
         ItemKeyUp(this, wrapperArgs);
         args.Handled = wrapperArgs.Handled;
     }
 }
Пример #10
0
 private void StripHost_KeyPress(object sender, KeyPressEventArgs e)
 {
     try
     {
         ToolStripControlHost toolStripItem = sender as ToolStripControlHost;
         TrayMenuItem         menuItem      = toolStripItem.Tag as TrayMenuItem;
         RaiseItemKeyPress(menuItem, e);
     }
     catch (Exception exception)
     {
         NetOffice.Core.Default.Console.WriteException(exception);
     }
 }
Пример #11
0
 private void ToolStripTextBox_TextChanged(object sender, EventArgs e)
 {
     try
     {
         ToolStripTextBox toolStripItem = sender as ToolStripTextBox;
         TrayMenuItem     menuItem      = toolStripItem.Tag as TrayMenuItem;
         RaiseItemTextChanged(menuItem);
     }
     catch (Exception exception)
     {
         NetOffice.Core.Default.Console.WriteException(exception);
     }
 }
Пример #12
0
 private void ToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         ToolStripComboBox toolStripItem = sender as ToolStripComboBox;
         TrayMenuItem      menuItem      = toolStripItem.Tag as TrayMenuItem;
         RaiseItemSelectedObjectChanged(menuItem, toolStripItem.SelectedItem, toolStripItem.SelectedIndex);
     }
     catch (Exception exception)
     {
         NetOffice.Core.Default.Console.WriteException(exception);
     }
 }
Пример #13
0
 public TrayMenuItemKeyEventArgs(TrayMenuItem item, ToolsKeys keyData, bool alt, bool control, bool handled, ToolsKeys keyCode, int keyValue, ToolsKeys modifiers, bool shift, bool suppressKeyPress)
 {
     Item             = item;
     Alt              = alt;
     Control          = control;
     Handled          = handled;
     KeyCode          = keyCode;
     KeyData          = keyData;
     KeyValue         = keyValue;
     Modifiers        = modifiers;
     Shift            = shift;
     SuppressKeyPress = suppressKeyPress;
 }
Пример #14
0
 private void ToolStripItem_CheckedChanged(object sender, EventArgs e)
 {
     try
     {
         ToolStripMenuItem toolStripItem = sender as ToolStripMenuItem;
         TrayMenuItem      menuItem      = toolStripItem.Tag as TrayMenuItem;
         RaiseItemChecked(menuItem, toolStripItem.Checked);
     }
     catch (Exception exception)
     {
         NetOffice.Core.Default.Console.WriteException(exception);
     }
 }
Пример #15
0
 /// <summary>
 /// Notify an item has been removed
 /// </summary>
 /// <param name="parentItem">parent item</param>
 /// <param name="item">removed item</param>
 /// <param name="itemIndex">former item index</param>
 internal void OnItemRemoved(TrayMenuItem parentItem, TrayMenuItem item, int itemIndex)
 {
     if (null != parentItem)
     {
         ToolStripItem parentStrip = Find(parentItem);
         if (null != parentStrip)
         {
             ToolStripItem toolStripItem = Find(item);
             toolStripItem.Click -= ToolStripItem_Click;
             _contextMenu.Items.Remove(toolStripItem);
         }
     }
     else
     {
         ToolStripItem toolStripItem = Find(item);
         toolStripItem.Click -= ToolStripItem_Click;
         _contextMenu.Items.Remove(toolStripItem);
     }
 }
Пример #16
0
 /// <summary>
 /// Recursive find item helper
 /// </summary>
 /// <param name="item">target item</param>
 /// <param name="items">collection to search</param>
 /// <returns>item or null</returns>
 private ToolStripItem Find(TrayMenuItem item, ToolStripItemCollection items)
 {
     foreach (ToolStripItem stripItem in items)
     {
         TrayMenuItem trayItem = stripItem.Tag as TrayMenuItem;
         if (trayItem == item)
         {
             return(stripItem);
         }
         ToolStripDropDownItem dropDownItem = stripItem as ToolStripDropDownItem;
         if (null != dropDownItem)
         {
             ToolStripItem result = Find(item, dropDownItem.DropDownItems);
             if (null != result)
             {
                 return(result);
             }
         }
     }
     return(null);
 }
Пример #17
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="item"></param>
 public TrayMenuItemTextChangedEventArgs(TrayMenuItem item)
 {
     Item = item;
 }
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="item">tray menu item</param>
 /// <param name="selectedObject">current selected item</param>
 /// <param name="selectedIndex">current selected index</param>
 public TrayMenuItemSelectedObjectChangedEventArgs(TrayMenuItem item, object selectedObject, int selectedIndex)
 {
     Item           = item;
     SelectedObject = selectedObject;
     SelectedIndex  = selectedIndex;
 }
Пример #19
0
 /// <summary>
 /// Not Supported
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public override bool Remove(TrayMenuItem item)
 {
     return(false);
 }
Пример #20
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="owner">collection owner</param>
 /// <param name="parent">parent item instance</param>
 internal TrayMenuStubItems(TrayMenu owner, TrayMenuItem parent) : base(owner, parent)
 {
 }
Пример #21
0
        /// <summary>
        /// Notify a new item has been added
        /// </summary>
        /// <param name="parentItem">parent item instance or null</param>
        /// <param name="item">new created item</param>
        internal void OnItemAdded(TrayMenuItem parentItem, TrayMenuItem item)
        {
            ToolStripItem newItem = null;

            switch (item.ItemType)
            {
            case TrayMenuItemType.Item:
                newItem = new ToolStripMenuItem();
                break;

            case TrayMenuItemType.Label:
                newItem = new ToolStripLabel();
                break;

            case TrayMenuItemType.LinkLabel:
                newItem = new ToolStripLabel();
                (newItem as ToolStripLabel).IsLink       = true;
                (newItem as ToolStripLabel).LinkBehavior = LinkBehavior.AlwaysUnderline;
                break;

            case TrayMenuItemType.Button:
                newItem = new ToolStripButton();
                break;

            case TrayMenuItemType.TextBox:
                newItem = new ToolStripTextBox();
                (newItem as ToolStripTextBox).TextChanged += ToolStripTextBox_TextChanged;
                break;

            case TrayMenuItemType.CheckBox:
                newItem = new ToolStripMenuItem();
                (newItem as ToolStripMenuItem).CheckOnClick    = true;
                (newItem as ToolStripMenuItem).CheckedChanged += ToolStripItem_CheckedChanged;
                break;

            case TrayMenuItemType.Progress:
                newItem = new ToolStripProgressBar();
                (item as TrayMenuProgressItem).SetProgressElements((newItem as ToolStripProgressBar).Minimum, (newItem as ToolStripProgressBar).Maximum, (newItem as ToolStripProgressBar).Value, (TrayMenuProgressItem.ProgressBarStyle)(newItem as ToolStripProgressBar).Style);
                break;

            case TrayMenuItemType.DropDownList:
                newItem = new ToolStripComboBox();
                (newItem as ToolStripComboBox).DropDownStyle         = ComboBoxStyle.DropDownList;
                (newItem as ToolStripComboBox).TextChanged          += ToolStripComboBox_TextChanged;
                (newItem as ToolStripComboBox).SelectedIndexChanged += ToolStripComboBox_SelectedIndexChanged;
                (item as TrayMenuDropDownListItem).SetupDropDownElements((newItem as ToolStripComboBox).DropDownHeight);
                break;

            case TrayMenuItemType.Separator:
                newItem = new ToolStripSeparator();
                break;

            case TrayMenuItemType.Custom:
                newItem = new ToolStripControlHost((System.Windows.Forms.Control)(item as TrayMenuCustomItem).Control);
                break;

            case TrayMenuItemType.Monitor:
                TrayMenuMonitorItemControl control = new TrayMenuMonitorItemControl(_addin);
                newItem = new ToolStripControlHost(control);
                (item as TrayMenuMonitorItem).SetMonitorElements(control);
                break;

            case TrayMenuItemType.AutoClose:
                newItem = new ToolStripMenuItem();
                (newItem as ToolStripMenuItem).CheckOnClick    = true;
                (newItem as ToolStripMenuItem).Checked         = AutoClose;
                (newItem as ToolStripMenuItem).CheckedChanged += ToolAutoCloseStripItem_CheckedChanged;
                break;

            case TrayMenuItemType.Close:
                newItem = new ToolStripMenuItem();
                (newItem as ToolStripMenuItem).Click += ToolCloseStripItem_Click;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            newItem.Tag         = item;
            newItem.Text        = item.Text;
            newItem.ToolTipText = item.ToolTipText;
            newItem.Image       = item.Image;
            newItem.BackColor   = item.BackColor;
            newItem.ForeColor   = item.ForeColor;
            newItem.Visible     = item.Visible;
            newItem.Padding     = item.Padding;
            newItem.Enabled     = item.Enabled;
            item.SetupElements(newItem.Font, newItem.TextAlign, newItem.ImageAlign, item.Padding);

            ToolStripControlHost stripHost = newItem as ToolStripControlHost;

            if (null != stripHost)
            {
                stripHost.KeyDown  += StripHost_KeyDown;
                stripHost.KeyPress += StripHost_KeyPress;
                stripHost.KeyUp    += StripHost_KeyUp;
            }

            if (null != parentItem)
            {
                ToolStripDropDownItem parentStrip = Find(parentItem) as ToolStripDropDownItem;
                if (null != parentStrip)
                {
                    parentStrip.DropDownItems.Add(newItem);
                }
            }
            else
            {
                _contextMenu.Items.Add(newItem);
            }

            newItem.Click += ToolStripItem_Click;
        }
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="item">target item</param>
 /// <param name="check">item checked state</param>
 public TrayMenuItemCheckedEventArgs(TrayMenuItem item, bool check) : base(item)
 {
     Checked = check;
 }
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="item">tray menu item</param>
 public TrayMenuItemsEventArgs(TrayMenuItem item)
 {
     Item = item;
 }
Пример #24
0
 /// <summary>
 /// Not Supported
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public override int IndexOf(TrayMenuItem item)
 {
     return(-1);
 }