コード例 #1
0
 private void NodeModel_ConnectorAdded(Graph.Connectors.ConnectorModel obj)
 {
     // If the mouse does not leave the node after the connnector is added,
     // try to show the preview bubble without new mouse enter event.
     if (IsMouseOver)
     {
         Dispatcher.BeginInvoke(new Action(TryShowPreviewBubbles), DispatcherPriority.Loaded);
     }
 }
コード例 #2
0
        private void PlacePinsOnWires(NodeModel startNode,
                                      NodeModel watchNodeModel,
                                      ConnectorModel connector,
                                      IEnumerable <Point> connectorPinLocations,
                                      List <ModelBase> allCreatedModels,
                                      List <ModelBase> allDeletedModels)
        {
            // Collect ports & connectors of newly connected nodes
            // so that old pins (that need to remain) can be transferred over correctly.
            PortModel startNodePort = startNode.OutPorts.FirstOrDefault(p => p.GUID == connector.Start.GUID);
            PortModel watchNodePort = watchNodeModel.OutPorts[0];

            Graph.Connectors.ConnectorModel[] connectors = new Graph.Connectors.ConnectorModel[2];

            connectors[0] = startNodePort.Connectors.FirstOrDefault(c => c.End.Owner.GUID == watchNodeModel.GUID && c.GUID != connector.GUID);
            connectors[1] = watchNodePort.Connectors.FirstOrDefault(c => c.Start.Owner.GUID == watchNodeModel.GUID && c.GUID != connector.GUID);

            if (connectors.Any(c => c is null))
            {
                return;
            }

            allCreatedModels.AddRange(connectors);
            allDeletedModels.Add(connector);

            if (connectorPinLocations.Count() < 1)
            {
                return;
            }

            // Place each pin where required on the newly connected connectors.
            foreach (var connectorPinLocation in connectorPinLocations)
            {
                int wireIndex = ConnectorSegmentIndex(CurrentPosition, connectorPinLocation);
                ViewModel.PinConnectorPlacementFromWatchNode(connectors, wireIndex, connectorPinLocation, allCreatedModels);
            }
        }