private void TreeNodeClickHandler(object sender, TreeNodeMouseClickEventArgs e) { _tree.SelectedNode = e.Node; if (_controller == null || !(e.Node.Tag is Guid)) { return; } Guid tag = (Guid)e.Node.Tag; if (e.Button == MouseButtons.Right) { ProjectPanelComponent targetComponent = ComponentManager.RegisteredInstances.FirstOrDefault(c => c.ShouldHandle(tag)); if (targetComponent != null) { targetComponent.ShowContextMenu(_commandController, e.Location, tag); return; } // TODO: Remove when fully on components ContextMenuStrip contextMenu = CommandMenuBuilder.BuildContextMenu(_controller.Menu(tag)); _commandController.BindCommandManager(_controller.CommandManager); _commandController.Clear(); _commandController.MapMenuItems(contextMenu.Items); contextMenu.Show(_tree, e.Location); } }
public void ShowContextMenu(UICommandController commandController, Point location, Guid tag) { ContextMenuStrip contextMenu = CommandMenuBuilder.BuildContextMenu(GetCommandMenu(tag)); commandController.BindCommandManager(CommandManager); commandController.Clear(); commandController.MapMenuItems(contextMenu.Items); contextMenu.Show(RootNode.TreeView, location); }