public void DoEdges() { // Draw edges on repaint. if (Event.current.type == EventType.Repaint) { Handles.BeginGUI(); var colorOff = Color.white; var colorOn = new Color(0.6f, 0.75f, 1); var i = 0; foreach (var edge in host.graph.edges) { if (edge == _moveEdge) { continue; } bool BlockSelected = host.selection.Contains(edge.fromSlot.node); // edge.fromSlot.node bool ison = edgeSelection.Contains(i) || Event.current.alt; var clr = BlockSelected ? Color.green : (ison ? colorOn : colorOff); string t = ""; if (ison) { t = NodeFactory.GetTypeName(edge.fromSlot.dataType); } DrawEdge(edge, clr, t); i++; } Handles.EndGUI(); } // Terminate dragging operation on mouse button up. if (Event.current.type == EventType.MouseUp && _dragSourceSlot != null) { if (_moveEdge != null) { host.graph.RemoveEdge(_moveEdge); _moveEdge = null; } if (_dropTarget == null) { EndDragging(); Event.current.Use(); } } }
public void DoDraggedEdge() { if (_dragSourceSlot == null) { return; } var eventType = Event.current.GetTypeForControl(0); if (eventType == EventType.Repaint) { // Draw the working edge. var p1 = GetPositionAsFromSlot(_dragSourceSlot); var p2 = _dropTarget != null? GetPositionAsToSlot(_dropTarget) : Event.current.mousePosition; var n = (_dragSourceSlot.node as Block).runtimeInstance; DrawEdge(p1, p2, Color.white, n.name + "." + _dragSourceSlot.title + "[" + NodeFactory.GetTypeName(_dragSourceSlot.dataType) + "]"); } if (eventType == EventType.MouseDrag) { // Discard the last candidate. _dropTarget = null; Event.current.Use(); } }