Пример #1
0
        public void DrawEdges(Rect canvasAreaInWindow)
        {
            if (_draggingPathPointIndex == -1)
            {
                _hoveringEdge = null;
            }

            for (var i = 0; i < Graph.GetNodeCount(); i++)
            {
                Node node = Graph.GetNodeAt(i);


                for (var iu = 0; iu < node.Sockets.Count; iu++)
                {
                    AbstractSocket socket = node.Sockets[iu];
                    if (socket.IsInput() && socket.IsConnected())                     // draw only input sockets to avoid double drawing of edges
                    {
                        InputSocket inputSocket = (InputSocket)socket;
                        if (CanvasOverlapsWindow(inputSocket.Edge.Bounds, canvasAreaInWindow))
                        {
                            bool highlight = _selectedNodes.Contains(node) ||
                                             _selectedNodes.Contains(inputSocket.Edge.Output.Parent);
                            int  segmentIndex = inputSocket.Edge.IntersectsPathSegment(Event.current.mousePosition);
                            bool hover        = segmentIndex > -1;
                            node.GUIDrawEdge(inputSocket, highlight, hover);
                            if (hover && _draggingPathPointIndex == -1)
                            {
                                HandleEdgeHover(inputSocket.Edge, segmentIndex);
                                _hoveringEdge = inputSocket.Edge;
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        public void UnLink(AbstractSocket socket)
        {
            if (socket == null || !socket.IsConnected())
            {
                return;
            }


            if (socket.IsInput())
            {
                InputSocket inputSocket = (InputSocket)socket;
                if (inputSocket.Edge != null)
                {
                    UnLink(inputSocket, inputSocket.Edge.Output);
                }
            }

            if (socket.IsOutput())
            {
                OutputSocket outputSocket = (OutputSocket)socket;
                Edge[]       edgeCopy     = new Edge[outputSocket.Edges.Count];
                outputSocket.Edges.CopyTo(edgeCopy);
                for (int index = 0; index < edgeCopy.Length; index++)
                {
                    var edge = edgeCopy[index];
                    UnLink(edge.Input, outputSocket);
                }
            }
        }
Пример #3
0
 private void HandleSocketDrag(AbstractSocket dragSource)
 {
     if (dragSource != null)
     {
         if (dragSource.IsInput() && dragSource.IsConnected())
         {
             _dragSourceSocket = ((InputSocket)dragSource).Edge.GetOtherSocket(dragSource);
             _currentCanvas.Graph.UnLink((InputSocket)dragSource, (OutputSocket)_dragSourceSocket);
         }
         if (dragSource.IsOutput())
         {
             _dragSourceSocket = dragSource;
         }
         Event.current.Use();
     }
     Repaint();
 }