/// <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. // TODO-Linux FWNX-345: Review - don't use TemporaryColleague's // This needs to be done before PopulateNow if (m_temporaryColleagueParam != null) { m_temporaryColleagueParam.Mediator.AddTemporaryColleague(m_temporaryColleagueParam.TemporaryColleague); } // item is used in calling CreateUIForChoiceGroup to attach the choiceGroup // menu items to. It is not added to the shown contextMenu. ToolStripMenuItem item = new ToolStripMenuItem(); item.Tag = group; group.ReferenceWidget = item; group.PopulateNow(); CreateUIForChoiceGroup(group); var contextMenu = new ContextMenuStrip(); foreach (ToolStripMenuItem menuItem in item.DropDown.Items) { contextMenu.Items.Add(menuItem as ToolStripMenuItem); } contextMenu.Show(location); }
/// <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_TemporaryColleagueParameter = temporaryColleagueParam; // Nulls are just fine. // TODO-Linux FWNX-345: Review - don't use TemporaryColleague's // This needs to be done before PopulateNow if (m_TemporaryColleagueParameter != null) { m_TemporaryColleagueParameter.Mediator.AddTemporaryColleague(m_TemporaryColleagueParameter.TemporaryColleague); } // item is used in calling CreateUIForChoiceGroup to attach the choiceGroup // menu items to. It is not added to the shown contextMenu. ToolStripMenuItem item = new ToolStripMenuItem(); item.AccessibilityObject.Name = group.Id; //item.GetType().Name; item.Tag = group; group.ReferenceWidget = item; group.PopulateNow(); CreateUIForChoiceGroup(group); // NOTE: we intentionally leave contextMenu undisposed. If we dispose it after // contextMenu.Show then the mouse clicks on the menu items don't get handled. // We would have to add an Application.DoEvents() after the Show (which might // causes other problems), or implement IDisposable. var contextMenu = new ContextMenuStrip(); contextMenu.AccessibilityObject.Name = group.Id; // Without building this collection first, somehow we modify the Items collection while // iterating. var items = new System.Collections.Generic.List <ToolStripItem>(); foreach (var menuItem in item.DropDown.Items) { if (menuItem is ToolStripMenuItem) { items.Add(menuItem as ToolStripMenuItem); } else if (menuItem is ToolStripButton) { items.Add(menuItem as ToolStripButton); } else if (menuItem is ToolStripSeparator) { items.Add(menuItem as ToolStripSeparator); } } foreach (var menuItem in items) { contextMenu.Items.Add(menuItem); } MakeAcceleratorsVisible(contextMenu); contextMenu.Show(location); }
//from IUIMenuAdapter // public ContextMenu MakeContextMenu (ChoiceGroup group) // { // CommandBarContextMenu menu= new CommandBarContextMenu(); // menu.Tag = group; // group.ReferenceWidget = menu; // menu.Popup += new System.EventHandler(group.OnDisplay); // // return (ContextMenu)menu; // } public void ShowContextMenu(ChoiceGroup group, Point location, TemporaryColleagueParameter temporaryColleagueParam, MessageSequencer sequencer) { using (CommandBarContextMenu menu = new CommandBarContextMenu()) { menu.Tag = group; group.ReferenceWidget = menu; menu.Popup += new System.EventHandler(group.OnDisplay); // Pre-menu process two optional paremeters. if (temporaryColleagueParam != null) { temporaryColleagueParam.Mediator.AddColleague(temporaryColleagueParam.TemporaryColleague); } bool resume = false; if (sequencer != null) { resume = sequencer.PauseMessageQueueing(); } // NB: This is *always* modal, as it doesn't return until it closes. menu.Show(null, location); // Post-menu process two optional paremeters.s if (temporaryColleagueParam != null) { IxCoreColleague colleague = temporaryColleagueParam.TemporaryColleague; temporaryColleagueParam.Mediator.RemoveColleague(colleague); if (temporaryColleagueParam.ShouldDispose && colleague is IDisposable) { (colleague as IDisposable).Dispose(); } } if (sequencer != null && resume) { sequencer.ResumeMessageQueueing(); } } }
/// <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> /// Handle a right mouse up, invoking an appropriate context menu. /// </summary> /// <param name="sel"></param> /// <param name="pt"></param> /// <param name="rcSrcRoot"></param> /// <param name="rcDstRoot"></param> /// <returns></returns> protected override bool DoContextMenu(IVwSelection sel, Point pt, Rectangle rcSrcRoot, Rectangle rcDstRoot) { // Allow base method to handle spell check problems, if any. if (base.DoContextMenu(sel, pt, rcSrcRoot, rcDstRoot)) return true; var mainWind = ParentForm as XWindow; if (mainWind == null || sel == null) return false; CmObjectUi ui = null; try { TemporaryColleagueParameter tempColleague = null; IWfiWordform wordform; if (GetSelectedWordform(m_rootb.Selection, out wordform)) { ui = CmObjectUi.MakeUi(Cache, wordform.Hvo); ui.Mediator = m_mediator; tempColleague = new TemporaryColleagueParameter(m_mediator, ui, false); } mainWind.ShowContextMenu("mnuIText-RawText", new Point(Cursor.Position.X, Cursor.Position.Y), tempColleague, null); return true; } finally { if (ui != null) ui.Dispose(); } }
public void ShowContextMenu(ChoiceGroup @group, Point location, TemporaryColleagueParameter temporaryColleagueParam, MessageSequencer sequencer, Action<ContextMenuStrip> adjustMenu) { throw new NotImplementedException(); }
//from IUIMenuAdapter // public ContextMenu MakeContextMenu (ChoiceGroup group) // { // CommandBarContextMenu menu= new CommandBarContextMenu(); // menu.Tag = group; // group.ReferenceWidget = menu; // menu.Popup += new System.EventHandler(group.OnDisplay); // // return (ContextMenu)menu; // } public void ShowContextMenu(ChoiceGroup group, Point location, TemporaryColleagueParameter temporaryColleagueParam, MessageSequencer sequencer) { using (CommandBarContextMenu menu= new CommandBarContextMenu()) { menu.Tag = group; group.ReferenceWidget = menu; menu.Popup += new System.EventHandler(group.OnDisplay); // Pre-menu process two optional paremeters. if (temporaryColleagueParam != null) temporaryColleagueParam.Mediator.AddColleague(temporaryColleagueParam.TemporaryColleague); bool resume = false; if (sequencer != null) resume = sequencer.PauseMessageQueueing(); // NB: This is *always* modal, as it doesn't return until it closes. menu.Show(null, location); // Post-menu process two optional paremeters.s if (temporaryColleagueParam != null) { IxCoreColleague colleague = temporaryColleagueParam.TemporaryColleague; temporaryColleagueParam.Mediator.RemoveColleague(colleague); if (temporaryColleagueParam.ShouldDispose && colleague is IDisposable) (colleague as IDisposable).Dispose(); } if (sequencer != null && resume) sequencer.ResumeMessageQueueing(); } }
public void ShowContextMenu(ChoiceGroup @group, Point location, TemporaryColleagueParameter temporaryColleagueParam, MessageSequencer sequencer, Action <ContextMenuStrip> adjustMenu) { throw new NotImplementedException(); }
/// <summary> /// Get a context menu for the specified menu id, and in addition. /// </summary> /// <param name="menuId"></param> /// <param name="group"></param> /// <param name="actModal">don't return until the popup is closed</param> /// <returns></returns> public void ShowContextMenu(string menuId, Point location, TemporaryColleagueParameter temporaryColleagueParam, MessageSequencer sequencer, Action<ContextMenuStrip> adjustMenu) { CheckDisposed(); ChoiceGroup group = GetChoiceGroupForMenu(menuId); ((IUIMenuAdapter)m_menuBarAdapter).ShowContextMenu(group, location, temporaryColleagueParam, sequencer, adjustMenu); }
/// <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. // TODO-Linux FWNX-345: Review - don't use TemporaryColleague's // This needs to be done before PopulateNow if (m_temporaryColleagueParam != null) m_temporaryColleagueParam.Mediator.AddTemporaryColleague(m_temporaryColleagueParam.TemporaryColleague); // item is used in calling CreateUIForChoiceGroup to attach the choiceGroup // menu items to. It is not added to the shown contextMenu. ToolStripMenuItem item = new ToolStripMenuItem(); item.Tag = group; group.ReferenceWidget = item; group.PopulateNow(); CreateUIForChoiceGroup(group); var contextMenu = new ContextMenuStrip(); foreach(ToolStripMenuItem menuItem in item.DropDown.Items) { contextMenu.Items.Add(menuItem as ToolStripMenuItem); } contextMenu.Show(location); }
/// <summary> /// Make a menu from multiple menu definitions /// </summary> /// <param name="menuIds"></param> /// <param name="location"></param> /// <param name="temporaryColleagueParam"> /// Optional object that holds a Mediator and an XCore colleague /// that is used to simulate the blocking of a modal menu, without it really being modal. /// That is, the menu will add the colleague to the Mediator before it shows, and then remove /// it after it closes. /// </param> /// <param name="sequencer"> /// Optional object that holds a MessageSequencer obejct /// that is used to simulate the blocking of a modal menu, without it really being modal. /// That is, the menu will pause the MsgSeq before it shows, and then resume it /// it after it closes. /// </param> /// <returns></returns> public void ShowContextMenu(string[] menuIds, /*out ChoiceGroup group,*/ Point location, TemporaryColleagueParameter temporaryColleagueParam, MessageSequencer sequencer) { CheckDisposed(); List<XmlNode> nodes = new List<XmlNode>(menuIds.Length); foreach (string m in menuIds) { if (m == null || m == "") continue; // that's ok XmlNode node = GetContextMenuNodeFromMenuId(m); nodes.Add(node); } ChoiceGroup group = new ChoiceGroup(m_mediator, m_menuBarAdapter, nodes, null); ((IUIMenuAdapter)m_menuBarAdapter).ShowContextMenu(group, location, temporaryColleagueParam, sequencer); }
/// <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> /// /// </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) { ShowContextMenu(group, location, temporaryColleagueParam, sequencer, null); }
/// <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_TemporaryColleagueParameter = temporaryColleagueParam; // Nulls are just fine. // TODO-Linux FWNX-345: Review - don't use TemporaryColleague's // This needs to be done before PopulateNow if (m_TemporaryColleagueParameter != null) m_TemporaryColleagueParameter.Mediator.AddTemporaryColleague(m_TemporaryColleagueParameter.TemporaryColleague); // item is used in calling CreateUIForChoiceGroup to attach the choiceGroup // menu items to. It is not added to the shown contextMenu. ToolStripMenuItem item = new ToolStripMenuItem(); item.AccessibilityObject.Name = group.Id; //item.GetType().Name; item.Tag = group; group.ReferenceWidget = item; group.PopulateNow(); CreateUIForChoiceGroup(group); // NOTE: we intentionally leave contextMenu undisposed. If we dispose it after // contextMenu.Show then the mouse clicks on the menu items don't get handled. // We would have to add an Application.DoEvents() after the Show (which might // causes other problems), or implement IDisposable. var contextMenu = new ContextMenuStrip(); contextMenu.AccessibilityObject.Name = group.Id; // Without building this collection first, somehow we modify the Items collection while // iterating. var items = new System.Collections.Generic.List<ToolStripItem>(); foreach (var menuItem in item.DropDown.Items) { if (menuItem is ToolStripMenuItem ) items.Add(menuItem as ToolStripMenuItem); else if ( menuItem is ToolStripButton) items.Add(menuItem as ToolStripButton); else if (menuItem is ToolStripSeparator) items.Add(menuItem as ToolStripSeparator); } foreach (var menuItem in items) { contextMenu.Items.Add(menuItem); } MakeAcceleratorsVisible(contextMenu); contextMenu.Show(location); }
/// <summary> /// Get a context menu for the specified menu id, and in addition. /// </summary> /// <param name="menuId"></param> /// <param name="group"></param> /// <param name="actModal">don't return until the popup is closed</param> /// <returns></returns> public void ShowContextMenu(string menuId, Point location, TemporaryColleagueParameter temporaryColleagueParam, MessageSequencer sequencer) { ShowContextMenu(menuId, location, temporaryColleagueParam, sequencer, null); }
/// <summary> /// Handle a right mouse up, invoking an appropriate context menu. /// </summary> /// <param name="pt"></param> /// <param name="rcSrcRoot"></param> /// <param name="rcDstRoot"></param> /// <returns></returns> protected override bool DoContextMenu(IVwSelection sel, Point pt, Rectangle rcSrcRoot, Rectangle rcDstRoot) { // Allow base method to handle spell check problems, if any. if (base.DoContextMenu(sel, pt, rcSrcRoot, rcDstRoot)) return true; XWindow mainWind = this.ParentForm as XWindow; if (mainWind == null || sel == null) return false; ITsString tssWord; sel.GrowToWord().GetSelectionString(out tssWord, " "); TemporaryColleagueParameter tempColleague = null; if (tssWord != null && !string.IsNullOrEmpty(tssWord.Text)) { // We can have a WfiWordformUi as an additional colleague to handle more menu items. // The temporaray colleague handles adding and removing it. int form = WfiWordform.FindOrCreateWordform(Cache, tssWord, true); CmObjectUi ui = CmObjectUi.MakeUi(Cache, form); ui.Mediator = m_mediator; tempColleague = new TemporaryColleagueParameter(m_mediator, ui, false); } mainWind.ShowContextMenu("mnuIText-RawText", new Point(Cursor.Position.X, Cursor.Position.Y), tempColleague, null); return true; }