public override object CreateInstance() { if (Platform.IsMac && this.macLabel != null) { this.label = LanguageOption.GetValueBykey(this.macLabel); } if (this.label == null) { this.label = this.Id; } this.label = LanguageOption.GetValueBykey(this.label); this.label = StringParserService.Parse(this.label); if (this.icon != null) { this.icon = CommandCodon.GetStockId(this.Addin, this.icon); } CommandEntrySet commandEntrySet = new CommandEntrySet(this.label, (IconId)this.icon); commandEntrySet.CommandId = (object)this.Id; commandEntrySet.AutoHide = this.autohide; foreach (InstanceExtensionNode childNode in this.ChildNodes) { CommandEntry instance = childNode.CreateInstance() as CommandEntry; if (instance == null) { throw new InvalidOperationException("Invalid ItemSet child: " + (object)childNode); } commandEntrySet.Add(instance); } return((object)commandEntrySet); }
void ShowPopup(Gdk.EventButton evt) { view.FireCompletionContextChanged(); CompletionWindowManager.HideWindow(); ParameterInformationWindowManager.HideWindow(null, view); HideTooltip(); const string menuPath = "/MonoDevelop/SourceEditor2/ContextMenu/Editor"; var ctx = ExtensionContext ?? AddinManager.AddinEngine; CommandEntrySet cset = IdeApp.CommandService.CreateCommandEntrySet(ctx, menuPath); Gtk.Menu menu = IdeApp.CommandService.CreateMenu(cset); var imMenu = CreateInputMethodMenuItem(GettextCatalog.GetString("_Input Methods")); if (imMenu != null) { menu.Append(new SeparatorMenuItem()); menu.Append(imMenu); } menu.Destroyed += delegate { this.QueueDraw(); }; if (evt != null) { GtkWorkarounds.ShowContextMenu(menu, this, evt); } else { var pt = LocationToPoint(this.Caret.Location); GtkWorkarounds.ShowContextMenu(menu, this, new Gdk.Rectangle(pt.X, pt.Y, 1, (int)LineHeight)); } }
static string[] FindMenuPath(CommandEntrySet ces, Command cmd) { string [] FindMenuPathRec(CommandEntrySet s, int depth) { foreach (CommandEntry ce in s) { if (ce.CommandId.Equals(cmd.Id)) { var arr = new string [depth + 1]; arr [depth] = cmd.Text.Replace("_", ""); return(arr); } if (ce is CommandEntrySet set) { var result = FindMenuPathRec(set, depth + 1); if (result != null) { result[depth] = set.Name.Replace("_", ""); return(result); } } } return(null); } return(FindMenuPathRec(ces, 0)); }
public MDMenu(CommandManager manager, CommandEntrySet ces, CommandSource commandSource, object initialCommandTarget, EventHandler closeHandler) { CloseHandler = closeHandler; this.WeakDelegate = this; AutoEnablesItems = false; Title = (ces.Name ?? "").Replace("_", ""); Font = NSFont.MenuFontOfSize(12); foreach (CommandEntry ce in ces) { if (ce.CommandId == Command.Separator) { AddItem(NSMenuItem.SeparatorItem); continue; } if (string.Equals(ce.CommandId as string, servicesID, StringComparison.Ordinal)) { AddItem(new MDServicesMenuItem()); continue; } var subset = ce as CommandEntrySet; if (subset != null) { AddItem(new MDSubMenuItem(manager, subset, commandSource, initialCommandTarget)); continue; } var lce = ce as LinkCommandEntry; if (lce != null) { AddItem(new MDLinkMenuItem(lce)); continue; } Command cmd = manager.GetCommand(ce.CommandId); if (cmd == null) { LoggingService.LogError("MacMenu: '{0}' maps to null command", ce.CommandId); continue; } if (cmd is CustomCommand) { LoggingService.LogWarning("MacMenu: '{0}' is unsupported custom-rendered command' '", ce.CommandId); continue; } var acmd = cmd as ActionCommand; if (acmd == null) { LoggingService.LogWarning("MacMenu: '{0}' has unknown command type '{1}'", cmd.GetType(), ce.CommandId); continue; } AddItem(new MDMenuItem(manager, ce, acmd, commandSource, initialCommandTarget)); } }
public MDSubMenuItem(CommandManager manager, CommandEntrySet ces) { this.ces = ces; this.Submenu = new MDMenu(manager, ces); this.Title = this.Submenu.Title; }
public override object CreateInstance() { if (label == null) { label = Id; } label = StringParserService.Parse(label); if (icon != null) { icon = CommandCodon.GetStockId(Addin, icon); } CommandEntrySet cset = new CommandEntrySet(label, icon); cset.CommandId = Id; cset.AutoHide = autohide; foreach (InstanceExtensionNode e in ChildNodes) { CommandEntry ce = e.CreateInstance() as CommandEntry; if (ce != null) { cset.Add(ce); } else { throw new InvalidOperationException("Invalid ItemSet child: " + e); } } return(cset); }
public static void Recreate(CommandManager manager, CommandEntrySet entrySet) { if (manager == null) { throw new ArgumentException("manager"); } if (MacMainMenu.manager != null) { MacMainMenu.manager.CommandActivating -= OnCommandActivating; } MacMainMenu.manager = manager; MacMainMenu.manager.CommandActivating += OnCommandActivating; if (rootMenu == IntPtr.Zero) { rootMenu = HIToolbox.CreateMenu(idSeq++, GetName(entrySet), 0); AddMenuItems(new HIMenuItem(rootMenu, 0), entrySet); InstallRootMenu(); } else { Destroy(false); AddMenuItems(new HIMenuItem(rootMenu, 0), entrySet); } }
public static void Recreate(CommandManager manager, CommandEntrySet entrySet, HashSet <object> ignoreCommands) { if (manager == null) { throw new ArgumentException("manager"); } if (MacMainMenu.manager != null) { MacMainMenu.manager.CommandActivating -= OnCommandActivating; } MacMainMenu.manager = manager; MacMainMenu.manager.CommandActivating += OnCommandActivating; if (rootMenu == IntPtr.Zero) { rootMenu = HIToolbox.CreateMenu(idSeq++, GetName(entrySet), 0); CreateChildren(rootMenu, entrySet, ignoreCommands); InstallRootMenu(); } else { Destroy(false); CreateChildren(rootMenu, entrySet, ignoreCommands); } }
void OnPopupMenu(object o, EventArgs args) { object commandChain = this; CommandEntrySet opset = new CommandEntrySet(); VersionControlItemList items = GetSelectedItems(); foreach (object ob in AddinManager.GetExtensionNodes("/MonoDevelop/VersionControl/StatusViewCommands")) { if (ob is TypeExtensionNode) { TypeExtensionNode node = (TypeExtensionNode)ob; opset.AddItem(ParseCommandId(node)); VersionControlCommandHandler handler = node.CreateInstance() as VersionControlCommandHandler; if (handler == null) { LoggingService.LogError("Invalid type specified in extension point 'MonoDevelop/VersionControl/StatusViewCommands'. Subclass of 'VersionControlCommandHandler' expected."); continue; } handler.Init(items); CommandRouter rt = new CommandRouter(handler); rt.Next = commandChain; commandChain = rt; } else { opset.AddSeparator(); } } IdeApp.CommandService.ShowContextMenu(opset, commandChain); }
void SetupMenu() { // TODO: Use this? CommandEntrySet appCes = commandManager.CreateCommandEntrySet(appMenuAddinPath); CommandEntrySet ces = commandManager.CreateCommandEntrySet(commandMenuAddinPath); var mainMenu = new Menu { IsMainMenu = true, FocusVisualStyle = null, }; foreach (CommandEntrySet ce in ces) { var item = new TitleMenuItem(commandManager, ce); item.SubmenuClosed += (o, e) => { bool shouldFocusIde = !mainMenu.Items.OfType <MenuItem>().Any(mi => mi.IsSubmenuOpen); if (shouldFocusIde) { IdeApp.Workbench.RootWindow.Present(); } }; mainMenu.Items.Add(item); } titleBar.DockTitle.Children.Add(mainMenu); DockPanel.SetDock(mainMenu, Dock.Left); commandManager = null; commandMenuAddinPath = appMenuAddinPath = null; }
protected override void Run() { var doc = MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument; var view = doc.GetContent <MonoDevelop.SourceEditor.SourceEditorView> (); if (view == null) { LoggingService.LogWarning("ShowFixesHandler could not find a SourceEditorView"); return; } var widget = view.TextEditor; var pt = view.DocumentToScreenLocation(doc.Editor.Caret.Location); var ces = new CommandEntrySet(); ces.AddItem(AnalysisCommands.FixOperations); var menu = MonoDevelop.Ide.IdeApp.CommandService.CreateMenu(ces); menu.Popup(null, null, delegate(Menu mn, out int x, out int y, out bool push_in) { x = pt.X; y = pt.Y; push_in = true; //if the menu would be off the bottom of the screen, "drop" it upwards if (y + mn.Requisition.Height > widget.Screen.Height) { y -= mn.Requisition.Height + (int)widget.LineHeight; } }, 0, Global.CurrentEventTime); }
public override bool SetGlobalMenu(CommandManager commandManager, string commandMenuAddinPath, string appMenuAddinPath) { if (setupFail) { return(false); } try { InitApp(commandManager); CommandEntrySet ces = commandManager.CreateCommandEntrySet(commandMenuAddinPath); MacMainMenu.Recreate(commandManager, ces); CommandEntrySet aes = commandManager.CreateCommandEntrySet(appMenuAddinPath); MacMainMenu.SetAppMenuItems(commandManager, aes); } catch (Exception ex) { try { MacMainMenu.Destroy(true); } catch {} LoggingService.LogError("Could not install global menu", ex); setupFail = true; return(false); } return(true); }
protected override bool OnButtonPressEvent(EventButton evnt) { if (evnt.TriggersContextMenu()) { CommandEntrySet opset = new CommandEntrySet(); opset.AddItem(BlameCommands.ShowDiff); opset.AddItem(BlameCommands.ShowLog); opset.AddItem(Command.Separator); opset.AddItem(BlameCommands.CopyRevision); IdeApp.CommandService.ShowContextMenu(this, evnt, opset, this); return(true); } else { if (evnt.X < leftSpacer) { grabTime = evnt.Time; var status = Gdk.Pointer.Grab(this.GdkWindow, false, EventMask.PointerMotionHintMask | EventMask.Button1MotionMask | EventMask.ButtonReleaseMask | EventMask.EnterNotifyMask | EventMask.LeaveNotifyMask, null, null, grabTime); if (status == GrabStatus.Success) { dragPosition = evnt.X; } } } return(base.OnButtonPressEvent(evnt)); }
protected override bool OnButtonPressEvent(EventButton evnt) { if (evnt.TriggersContextMenu()) { int startLine = widget.Editor.YToLine(widget.Editor.VAdjustment.Value + evnt.Y); menuAnnotation = startLine > 0 && startLine <= annotations.Count ? annotations[startLine - 1] : null; CommandEntrySet opset = new CommandEntrySet(); opset.AddItem(BlameCommands.ShowDiff); opset.AddItem(BlameCommands.ShowLog); opset.AddItem(BlameCommands.ShowBlameBefore); opset.AddItem(Command.Separator); opset.AddItem(BlameCommands.CopyRevision); IdeApp.CommandService.ShowContextMenu(this, evnt, opset, this); return(true); } else { if (evnt.X < leftSpacer) { grabTime = evnt.Time; var status = Gdk.Pointer.Grab(this.GdkWindow, false, EventMask.PointerMotionHintMask | EventMask.Button1MotionMask | EventMask.ButtonReleaseMask | EventMask.EnterNotifyMask | EventMask.LeaveNotifyMask, null, null, grabTime); if (status == GrabStatus.Success) { dragPosition = evnt.X; } } } return(base.OnButtonPressEvent(evnt)); }
internal static void ShowNavigationBarContextMenu() { CommandEntrySet cset = IdeApp.CommandService.CreateCommandEntrySet("/MonoDevelop/SourceEditor2/ContextMenu/NavigationBar"); Gtk.Menu menu = IdeApp.CommandService.CreateMenu(cset); IdeApp.CommandService.ShowContextMenu(menu); }
public MDSubMenuItem(CommandManager manager, CommandEntrySet ces, CommandSource commandSource = CommandSource.MainMenu, object initialCommandTarget = null) { this.ces = ces; this.Submenu = new MDMenu(manager, ces, commandSource, initialCommandTarget); this.Title = this.Submenu.Title; }
public static void Add (this DockItemToolbar toolbar, CommandEntrySet entrySet, Gtk.Widget commandTarget) { CommandDockBar dockBar = new CommandDockBar (toolbar, commandTarget); foreach (CommandEntry entry in entrySet) { dockBar.Add (entry); } }
void OnPopupMenu(object o, PopupMenuArgs args) { CommandEntrySet opset = new CommandEntrySet(); opset.AddItem(EditCommands.Copy); opset.AddItem(EditCommands.SelectAll); IdeApp.CommandService.ShowContextMenu(opset, this); }
void OnPopupMenu(object sender, PopupMenuArgs args) { var contextMenu = new CommandEntrySet(); contextMenu.AddItem(ViewCommands.Open); contextMenu.AddItem(EditCommands.Copy); contextMenu.AddItem(EditCommands.SelectAll); IdeApp.CommandService.ShowContextMenu(contextMenu, this); }
void ShowPopup(Gdk.EventButton evt) { if (!AllowEditingComponents) { return; } CommandEntrySet eset = IdeApp.CommandService.CreateCommandEntrySet("/MonoDevelop/DesignerSupport/ToolboxItemContextMenu"); IdeApp.CommandService.ShowContextMenu(this, evt, eset, this); }
protected virtual void OnPopulatePopup(object sender, PopulatePopupArgs args) { CommandEntrySet cset = IdeApp.CommandService.CreateCommandEntrySet("/MonoDevelop/Database/ContextMenu/SqlEditor"); if (cset.Count > 0) { cset.AddItem(Command.Separator); IdeApp.CommandService.InsertOptions(args.Menu, cset, 0); } }
static ObjectValueTreeView() { // Context menu definition menuSet = new CommandEntrySet(); menuSet.AddItem(DebugCommands.AddWatch); menuSet.AddSeparator(); menuSet.AddItem(EditCommands.Rename); menuSet.AddItem(EditCommands.Delete); }
void ShowPopup() { CommandEntrySet cset = IdeApp.CommandService.CreateCommandEntrySet("/MonoDevelop/VersionControl/DiffView/ContextMenu"); Gtk.Menu menu = IdeApp.CommandService.CreateMenu(cset); menu.Destroyed += delegate { this.QueueDraw(); }; menu.Popup(null, null, new Gtk.MenuPositionFunc(PositionPopupMenu), 0, Gtk.Global.CurrentEventTime); }
void HandleInspectEditorButtonPressEvent(object o, ButtonPressEventArgs args) { if (args.Event.Button != 3) { return; } var menuSet = new CommandEntrySet(); menuSet.AddItem(EditCommands.SelectAll); menuSet.AddItem(EditCommands.Copy); IdeApp.CommandService.ShowContextMenu(menuSet, this); }
protected override void OnPopulatePopup(Menu menu) { HideLanguageItemWindow(); CommandEntrySet cset = IdeApp.CommandService.CreateCommandEntrySet("/MonoDevelop/SourceEditor/ContextMenu/Editor"); if (cset.Count > 0) { cset.AddItem(Command.Separator); IdeApp.CommandService.InsertOptions(menu, cset, 0); } base.OnPopulatePopup(menu); }
void ShowPopup(Gdk.EventButton evt) { view.FireCompletionContextChanged(); CompletionWindowManager.HideWindow(); ParameterInformationWindowManager.HideWindow(null, view); HideTooltip(); if (string.IsNullOrEmpty(menuPath)) { return; } var ctx = view.WorkbenchWindow?.ExtensionContext ?? AddinManager.AddinEngine; CommandEntrySet cset = IdeApp.CommandService.CreateCommandEntrySet(ctx, menuPath); if (Platform.IsMac) { if (evt == null) { int x, y; var pt = LocationToPoint(this.Caret.Location); TranslateCoordinates(Toplevel, pt.X, pt.Y, out x, out y); IdeApp.CommandService.ShowContextMenu(this, x, y, cset, this); } else { IdeApp.CommandService.ShowContextMenu(this, evt, cset, this); } } else { Gtk.Menu menu = IdeApp.CommandService.CreateMenu(cset); var imMenu = CreateInputMethodMenuItem(GettextCatalog.GetString("_Input Methods")); if (imMenu != null) { menu.Append(new SeparatorMenuItem()); menu.Append(imMenu); } menu.Hidden += HandleMenuHidden; if (evt != null) { GtkWorkarounds.ShowContextMenu(menu, this, evt); } else { var pt = LocationToPoint(this.Caret.Location); GtkWorkarounds.ShowContextMenu(menu, this, (int)pt.X, (int)pt.Y); } } }
internal void ShowContextMenu(int x, int y, Annotation annotation) { this.menuAnnotation = annotation; var opset = new CommandEntrySet(); opset.AddItem(BlameCommands.ShowDiff); opset.AddItem(BlameCommands.ShowLog); opset.AddItem(BlameCommands.ShowPreviousBlame); opset.AddItem(BlameCommands.ShowBlameBefore); opset.AddItem(Command.Separator); opset.AddItem(BlameCommands.CopyRevision); IdeApp.CommandService.ShowContextMenu(this, x, y, opset, this); }
void ShowPopup() { HideTooltip(); CommandEntrySet cset = IdeApp.CommandService.CreateCommandEntrySet("/MonoDevelop/SourceEditor2/ContextMenu/Editor"); Gtk.Menu menu = IdeApp.CommandService.CreateMenu(cset); menu.Append(new SeparatorMenuItem()); menu.Append(CreateInputMethodMenuItem(GettextCatalog.GetString("_Input Methods"))); menu.Destroyed += delegate { this.QueueDraw(); }; menu.Popup(null, null, new Gtk.MenuPositionFunc(PositionPopupMenu), 0, Gtk.Global.CurrentEventTime); }
private void GetCommandEntrySet(string addinPath) { DebugPrint($"CommandEntry [{addinPath}] ("); CommandEntrySet cmdSet = new CommandEntrySet(); object[] items = AddinManager.GetExtensionObjects(addinPath, false); foreach (CommandEntry item in items) { DebugPrint("* Got an CommandEntry: " + item.ToString()); cmdSet.Add(item); } //return cmdSet; DebugPrint(") CommandEntry"); }
public override bool SetGlobalMenu(CommandManager commandManager, string commandMenuAddinPath, string appMenuAddinPath) { if (setupFail) { return(false); } try { InitApp(commandManager); NSApplication.SharedApplication.HelpMenu = null; var rootMenu = NSApplication.SharedApplication.MainMenu; if (rootMenu == null) { rootMenu = new NSMenu(); NSApplication.SharedApplication.MainMenu = rootMenu; } else { rootMenu.RemoveAllItems(); } CommandEntrySet appCes = commandManager.CreateCommandEntrySet(appMenuAddinPath); rootMenu.AddItem(new MDSubMenuItem(commandManager, appCes)); CommandEntrySet ces = commandManager.CreateCommandEntrySet(commandMenuAddinPath); foreach (CommandEntry ce in ces) { rootMenu.AddItem(new MDSubMenuItem(commandManager, (CommandEntrySet)ce)); } } catch (Exception ex) { try { var m = NSApplication.SharedApplication.MainMenu; if (m != null) { m.Dispose(); } NSApplication.SharedApplication.MainMenu = null; } catch {} LoggingService.LogError("Could not install global menu", ex); setupFail = true; return(false); } return(true); }