示例#1
0
文件: Graph.cs 项目: despin89/repo
        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);
                }
            }
        }
示例#2
0
 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);
 }
示例#3
0
 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();
 }