AddContextMenu() { m_appMenu = new ContextMenuExtension(); m_appMenu.Title = "MgdDbg"; m_appMenu.MenuItems.Add(new AppContextMenuItem("Snoop Entities...", "MgdDbgSnoopEnts")); m_appMenu.MenuItems.Add(new AppContextMenuItem("Snoop Entities (nested)...", "MgdDbgSnoopNEnts")); m_appMenu.MenuItems.Add(new AppContextMenuItem("Snoop (by Handle)...", "MgdDbgSnoopByHandle")); m_appMenu.MenuItems.Add(new AppContextMenuItem("Snoop Database...", "MgdDbgSnoopDb")); m_appMenu.MenuItems.Add(new AppContextMenuItem("Snoop Editor...", "MgdDbgSnoopEd")); m_appMenu.MenuItems.Add(new MenuItem("")); // separator m_appMenu.MenuItems.Add(new AppContextMenuItem("Events...", "MgdDbgEvents")); m_appMenu.MenuItems.Add(new MenuItem("")); // separator m_appMenu.MenuItems.Add(new AppContextMenuItem("Test Framework...", "MgdDbgTests")); foreach (MenuItem mnuItem in m_appMenu.MenuItems) { AppContextMenuItem appContextMnuItem = mnuItem as AppContextMenuItem; if (appContextMnuItem != null) { appContextMnuItem.Click += new EventHandler(ExecuteCommand); } } Application.AddDefaultContextMenuExtension(m_appMenu); }
ExecuteCommand(Object o, EventArgs e) { AppContextMenuItem mnuItem = (AppContextMenuItem)o; string fullCmdLine = string.Format("_{0}\n", mnuItem.CommandName); Application.DocumentManager.MdiActiveDocument.SendStringToExecute(fullCmdLine, false, false, true); }