private void ShowContextMenu(ButtonItem cm) { cm.Popup(MousePosition); }
/// <summary> /// /// </summary> /// <param name="group"></param> /// <param name="location"></param> /// <param name="temporaryColleagueParam"></param> /// <param name="sequencer"></param> public void ShowContextMenu(ChoiceGroup group, Point location, TemporaryColleagueParameter temporaryColleagueParam, MessageSequencer sequencer) { // Store optional parameter values. m_temporaryColleagueParam = temporaryColleagueParam; // Nulls are just fine. m_sequencer = sequencer; // Nulls are just fine. ButtonItem b = new ButtonItem(); b.PopupType = DevComponents.DotNetBar.ePopupType.Menu; //ContextMenu menu = new ContextMenu(); b.Tag = group; group.ReferenceWidget = b; b.SubItems.Add(new ButtonItem("just to make popup happen")); Manager.RegisterPopup(b); // This will be populated when this event fires, just to make it parallel to how menubar menus work. b.PopupOpen += new DevComponents.DotNetBar.DotNetBarManager.PopupOpenEventHandler(menu_PopupOpen); // It's too early to remove the temporary colleague, even in these event handlers, // since the Mediator hasn't invoked anything on it yet. // b.PopupClose += new EventHandler(OnContextMenuClose); // b.PopupFinalized += new EventHandler(b_PopupFinalized); // 'b' is not modal, so if we have either a temporaryColleagueParam, // or a sequecner, or both, we need to preprocess them, before showing the menu. // We also need to do some post-processing with them, after the menu closes. // That is done in the OnContextMenuClose handler. if (m_temporaryColleagueParam != null) m_temporaryColleagueParam.Mediator.AddTemporaryColleague(m_temporaryColleagueParam.TemporaryColleague); m_sequencerIsPaused = false; //if (m_sequencer != null) // m_sequencerIsPaused = m_sequencer.PauseMessageQueueing(); b.Popup(location.X, location.Y); }
/// <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); }