public override CommandResult Invoke(Guid group, int id, object inputArg, ref object outputArg) { if (MenuCommandService != null) { POINTS[] position = (POINTS[])inputArg; CommandID menuCommand = new CommandID(_cmdSetGuid, (int)_menuId); MenuCommandService.ShowContextMenu(menuCommand, position[0].x, position[0].y); return(CommandResult.Executed); } return(CommandResult.NotSupported); }
private void OnShowContextMenu(object sender, ShowContextMenuEventArgs e) { if (MenuCommandService != null) { OnBeforeShowContextMenu(); var explorerContextMenu = GetContextMenuCommandID(); var p = _elementHost.PointToScreen(new Point((int)e.Point.X, (int)e.Point.Y)); try { MenuCommandService.ShowContextMenu(explorerContextMenu, p.X, p.Y); } catch (COMException ex) { // do not rethrow exception as this causes VS crash Debug.Fail("Caught exception of type " + ex.GetType().FullName + " with message " + ex.Message + ". Stack Trace: " + ex.StackTrace); } } }