コード例 #1
0
 protected virtual void OnBeforeRemoveItemFromQuickAccessToolbar(RibbonCustomizeEventArgs e)
 {
     if (BeforeRemoveItemFromQuickAccessToolbar != null)
         BeforeRemoveItemFromQuickAccessToolbar(this, e);
 }
コード例 #2
0
 /// <summary>
 /// Raises the BeforeCustomizeMenuPopup event.
 /// </summary>
 /// <param name="e">Event arguments</param>
 protected virtual void OnBeforeCustomizeMenuPopup(RibbonCustomizeEventArgs e)
 {
     if (BeforeCustomizeMenuPopup != null)
         BeforeCustomizeMenuPopup(this, e);
 }
コード例 #3
0
        /// <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;
            }
        }
コード例 #4
0
 /// <summary>
 /// Adds an instance of base type BaseItem or RibbonBar 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 or RibbonBar 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;
         }
     }
 }
コード例 #5
0
        /// <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="ribbonStrip">Indicates whether customize menu is displayed over ribbon strip</param>
        internal virtual void ShowCustomizeContextMenu(object o, bool ribbonStrip)
        {
            if (o == null || !m_UseCustomizeDialog)
                return;

            m_RibbonStrip.ClosePopup(SYS_CUSTOMIZE_POPUP_MENU);

            ButtonItem cont = new ButtonItem(SYS_CUSTOMIZE_POPUP_MENU);
            cont.Style = eDotNetBarStyle.Office2007;
            cont.SetOwner(m_RibbonStrip);

            if ((CanCustomizeItem(o as BaseItem) || o is RibbonBar) && !m_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) ||
                        o is RibbonBar && this.QuickToolbarItems.Contains(GetQATRibbonBarName(o as RibbonBar)))
                        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 (m_UseCustomizeDialog)
            {
                ButtonItem b = new ButtonItem(SysQatCustomizeItemName);
                b.Text = this.SystemText.QatCustomizeText;
                b.BeginGroup = true;
                b.Click += new EventHandler(CustomizeQuickAccessToolbarDialog);
                cont.SubItems.Add(b);
            }

            if (m_EnableQatPlacement && !m_UseExternalCustomization)
            {
                ButtonItem b = new ButtonItem(SysQatPlaceItemName);
                if (m_QatPositionedBelow)
                    b.Text = this.SystemText.QatPlaceAboveRibbonText;
                else
                    b.Text = this.SystemText.QatPlaceBelowRibbonText;
                b.Click += new EventHandler(QuickAccessToolbarChangePlacement);
                cont.SubItems.Add(b);
            }

            if (this.AutoExpand)
            {
                ButtonItem b = new ButtonItem(this.Expanded ? SysMinimizeRibbon : SysMaximizeRibbon, this.Expanded ? this.SystemText.MinimizeRibbonText : this.SystemText.MaximizeRibbonText);
                b.Click += new EventHandler(MinMaxRibbonClick);
                b.BeginGroup = true;
                cont.SubItems.Add(b);
            }

            RibbonCustomizeEventArgs e = new RibbonCustomizeEventArgs(o, cont);
            OnBeforeCustomizeMenuPopup(e);
            if (e.Cancel)
            {
                cont.Dispose();
                return;
            }

            ((IOwnerMenuSupport)m_RibbonStrip).RegisterPopup(cont);
            cont.Popup(Control.MousePosition);
        }