public void QueryPossibleConnections(SelectionMenu menu, DiagramViewModel diagramViewModel, ConnectorViewModel startConnector, Vector2 mousePosition) { if (startConnector.ConnectorForType == typeof(ElementNode)) { menu.Items.Clear(); var vm = InvertGraphEditor.CurrentDiagramViewModel; var category = new SelectionMenuCategory() { Title = "Connect" }; menu.AddItem(category); menu.AddItem(new SelectionMenuItem("Connect", "Create View Node and Connect to : Element", () => { ViewNode viewNode = new ViewNode(); viewNode.Name = String.Format("{0}View", vm.Title); vm.AddNode(viewNode, vm.LastMouseEvent.LastMousePosition); diagramViewModel.GraphData.AddConnection(startConnector.ConnectorFor.DataObject as IConnectable, viewNode.ElementInputSlot); }), category); ElementNode elementNode = (ElementNode)startConnector.ConnectorFor.InputConnector.DataObject; if (elementNode.BaseNode != null) { ViewNode firstBaseViewNode = diagramViewModel.GraphData.Repository.All <ViewNode>() .FirstOrDefault(graphViewNode => { return(graphViewNode.Element == elementNode.BaseNode); }); if (firstBaseViewNode != null) { menu.AddItem(new SelectionMenuItem("Connect", "Create Inherited View Node and Connect to : Element", () => { ViewNode viewNode = new ViewNode(); viewNode.Name = String.Format("{0}View", vm.Title); vm.AddNode(viewNode, vm.LastMouseEvent.LastMousePosition); diagramViewModel.GraphData.AddConnection(startConnector.ConnectorFor.DataObject as IConnectable, viewNode.ElementInputSlot); diagramViewModel.GraphData.AddConnection(firstBaseViewNode, viewNode); IFilterItem viewNodeFilterItem = diagramViewModel.GraphData.CurrentFilter.FilterItems.First(item => item.Node == viewNode); diagramViewModel.GraphData.CurrentFilter.ShowInFilter(firstBaseViewNode, viewNodeFilterItem.Position - new Vector2(250, 0)); }), category); } } } }
public void QueryPossibleConnections(SelectionMenu menu, DiagramViewModel diagramViewModel, ConnectorViewModel startConnector, Vector2 mousePosition) { if (startConnector.ConnectorForType.FullName == typeof(ElementNode).FullName) { menu.Items.Clear(); var vm = InvertGraphEditor.CurrentDiagramViewModel; var category = new SelectionMenuCategory() { Title = "Connect" }; menu.AddItem(category); menu.AddItem(new SelectionMenuItem("Connect", "Create View Node and Connect to : Element", () => { ViewNode viewNode = new ViewNode(); vm.AddNode(viewNode, vm.LastMouseEvent.LastMousePosition); diagramViewModel.GraphData.AddConnection(startConnector.ConnectorFor.DataObject as IConnectable, viewNode.ElementInputSlot); }), category); } }