public void OnConnectionDragging(Point currentDragPoint, ConnectionViewModel connection) { // If current drag point is close to an input connector, show its snapped position. var nearbyConnector = FindNearbyInputConnector(currentDragPoint); connection.ToPosition = (nearbyConnector != null) ? nearbyConnector.Position : currentDragPoint; }
public ConnectionViewModel OnConnectionDragStarted(ConnectorViewModel sourceConnector, Point currentDragPoint) { if (!(sourceConnector is OutputConnectorViewModel)) { return(null); } var connection = new ConnectionViewModel((OutputConnectorViewModel)sourceConnector) { ToPosition = currentDragPoint }; Connections.Add(connection); return(connection); }
public void OnConnectionDragCompleted(Point currentDragPoint, ConnectionViewModel newConnection, ConnectorViewModel sourceConnector) { var nearbyConnector = FindNearbyInputConnector(currentDragPoint); if (nearbyConnector == null || sourceConnector.Element == nearbyConnector.Element) { Connections.Remove(newConnection); return; } var existingConnection = nearbyConnector.Connection; if (existingConnection != null) { Connections.Remove(existingConnection); } newConnection.To = nearbyConnector; }