private void contextMenuStrip_Opening(object sender, CancelEventArgs e)
 {
     if (showDefaultContextMenu && treeView != null && treeView.ContextMenuStrip != null)
     {
         if (modelTreeController != null && modelTreeController.Project != null)
         {
             // Remove DummyItem
             if (contextMenuStrip.Items.Contains(dummyItem))
             {
                 contextMenuStrip.Items.Remove(dummyItem);
             }
             // Collect all actions provided by the display itself
             WinFormHelpers.BuildContextMenu(contextMenuStrip, GetMenuItemDefs(), modelTreeController.Project, hideMenuItemsIfNotGranted);
         }
     }
 }
        private void ContextMenuStrip_Opening(object sender, CancelEventArgs e)
        {
            if (showDefaultContextMenu && listView != null && listView.ContextMenu == null)
            {
                Point mousePos = listView.PointToClient(Control.MousePosition);
                ListViewHitTestInfo hitTestInfo = ListView.HitTest(mousePos);
                Tool clickedTool = null;
                if (hitTestInfo.Item != null)
                {
                    clickedTool = hitTestInfo.Item.Tag as Tool;
                }

                if (toolSetController == null)
                {
                    throw new ArgumentNullException("ToolSetController");
                }
                WinFormHelpers.BuildContextMenu(presenterPrivateContextMenu, toolSetController.GetMenuItemDefs(clickedTool), toolSetController.Project, hideMenuItemsIfNotGranted);
            }
            e.Cancel = presenterPrivateContextMenu.Items.Count == 0;
        }
Esempio n. 3
0
 /// <override></override>
 public void OpenContextMenu(int x, int y, IEnumerable <MenuItemDef> actions, Project project)
 {
     if (actions == null)
     {
         throw new ArgumentNullException("actions");
     }
     if (project == null)
     {
         throw new ArgumentNullException("project");
     }
     if (showDefaultContextMenu && contextMenuStrip != null)
     {
         contextMenuStrip.SuspendLayout();
         contextMenuStrip.Left = x;
         contextMenuStrip.Top  = y;
         WinFormHelpers.BuildContextMenu(contextMenuStrip, actions, project, hideMenuItemsIfNotGranted);
         contextMenuStrip.Closing += contextMenuStrip_Closing;
         contextMenuStrip.Show(x, y);
         contextMenuStrip.ResumeLayout();
     }
 }