public void UnLink(AbstractSocket socket) { if ((socket == null) || !socket.IsConnected()) { return; } if (socket.IsInput()) { InputSocket inputSocket = (InputSocket)socket; if (inputSocket.Connection != null) { this.UnLink(inputSocket, inputSocket.Connection.Output); } } if (socket.IsOutput()) { OutputSocket outputSocket = (OutputSocket)socket; Connection[] connectionCopy = new Connection[outputSocket.Connections.Count]; outputSocket.Connections.CopyTo(connectionCopy); foreach (Connection edge in connectionCopy) { this.UnLink(edge.Input, outputSocket); } } }
public static Vector2 GetEdgePosition(AbstractSocket socket, Vector2 position) { if (socket.Parent.Collapsed) { float width = NodeEditorConfig.SocketSize; if (socket.IsOutput()) { width = 0; } position.Set(socket.X + width, socket.Parent.WindowRect.y + 8); } else { float width = 0; if (socket.IsOutput()) { width = NodeEditorConfig.SocketSize; } position.Set(socket.X + width, socket.Y + NodeEditorConfig.SocketSize / 2f); } return(position); }
private void HandleSocketDrag(AbstractSocket dragSource) { if (dragSource != null) { if (dragSource.IsInput() && dragSource.IsConnected()) { this._dragSourceSocket = ((InputSocket)dragSource).Connection.GetOtherSocket(dragSource); this._currentCanvas.Graph.UnLink((InputSocket)dragSource, (OutputSocket)this._dragSourceSocket); } if (dragSource.IsOutput()) { this._dragSourceSocket = dragSource; } Event.current.Use(); } this.Repaint(); }