/// <summary> /// Removes an item from the Quick Access Toolbar. /// </summary> /// <param name="item">Reference to the item that is already part of Quick Access Toolbar.</param> public void RemoveItemFromQuickAccessToolbar(BaseItem item) { RibbonCustomizeEventArgs rc = new RibbonCustomizeEventArgs(item, null); OnBeforeRemoveItemFromQuickAccessToolbar(rc); if (!rc.Cancel) { this.QuickToolbarItems.Remove(item); //item.Parent.SubItems.Remove(item); this.RecalcLayout(); m_QatLayoutChanged = true; } }
/// <summary> /// Displays popup customize context menu for given customization object. /// </summary> /// <param name="o">Object that should be customized, usually an instance of BaseItem.</param> /// <param name="isTabStrip">Indicates whether customize menu is displayed over metro tab strip</param> internal virtual void ShowCustomizeContextMenu(object o, bool isTabStrip) { if (o == null || !_UseCustomizeDialog) return; _TabStrip.ClosePopup(SYS_CUSTOMIZE_POPUP_MENU); ButtonItem cont = new ButtonItem(SYS_CUSTOMIZE_POPUP_MENU); cont.Style = eDotNetBarStyle.StyleManagerControlled; cont.SetOwner(_TabStrip); if ((CanCustomizeItem(o as BaseItem)) && !_UseExternalCustomization) { if (o is BaseItem && this.QuickToolbarItems.Contains((BaseItem)o)) { ButtonItem b = new ButtonItem(SysQatRemoveFromItemName); b.Text = this.SystemText.QatRemoveItemText; b.Click += new System.EventHandler(CustomizeRemoveFromQuickAccessToolbar); b.Tag = o; cont.SubItems.Add(b); } else { BaseItem itemToCustomize = o as BaseItem; ButtonItem b = new ButtonItem(SysQatAddToItemName); b.Text = this.SystemText.QatAddItemText; b.Click += new System.EventHandler(CustomizeAddToQuickAccessToolbar); b.Tag = o; cont.SubItems.Add(b); if (itemToCustomize != null && this.QuickToolbarItems.Contains(itemToCustomize.Name)) b.Enabled = false; if (itemToCustomize != null && BaseItem.IsOnPopup(itemToCustomize) && itemToCustomize.Parent != null) { Control c = itemToCustomize.ContainerControl as Control; if (c != null) c.VisibleChanged += new EventHandler(CustomizePopupItemParentVisibleChange); } } } if (_UseCustomizeDialog) { ButtonItem b = new ButtonItem(SysQatCustomizeItemName); b.Text = this.SystemText.QatCustomizeText; b.BeginGroup = true; b.Click += new EventHandler(CustomizeQuickAccessToolbarDialog); cont.SubItems.Add(b); } RibbonCustomizeEventArgs e = new RibbonCustomizeEventArgs(o, cont); OnBeforeCustomizeMenuPopup(e); if (e.Cancel) { cont.Dispose(); return; } ((IOwnerMenuSupport)_TabStrip).RegisterPopup(cont); cont.Popup(Control.MousePosition); }
/// <summary> /// Raises the BeforeCustomizeMenuPopup event. /// </summary> /// <param name="e">Event arguments</param> protected virtual void OnBeforeCustomizeMenuPopup(RibbonCustomizeEventArgs e) { if (BeforeCustomizeMenuPopup != null) BeforeCustomizeMenuPopup(this, e); }
protected virtual void OnBeforeRemoveItemFromQuickAccessToolbar(RibbonCustomizeEventArgs e) { if (BeforeRemoveItemFromQuickAccessToolbar != null) BeforeRemoveItemFromQuickAccessToolbar(this, e); }
/// <summary> /// Adds an instance of base type BaseItem to the Quick Access Toolbar. Note that this method creates /// new instance of the item or an representation of the item being added and adds that to the Quick Access Toolbar. /// </summary> /// <param name="originalItem">Reference to the item to add, must be an BaseItem type.</param> public void AddItemToQuickAccessToolbar(object originalItem) { BaseItem copy = GetQatItemCopy(originalItem); if (copy != null) { RibbonCustomizeEventArgs re = new RibbonCustomizeEventArgs(copy, null); OnBeforeAddItemToQuickAccessToolbar(re); if (!re.Cancel) { this.QuickToolbarItems.Add(copy); this.RecalcLayout(); m_QatLayoutChanged = true; } } }