private void DrawGraph(bool selected) { if (Graph == null) { return; } foreach (var node in Graph.Nodes.Where(x => selected == Selector.IsSelected(x))) { TinyGUI.DrawNode(node, selected, Graph.HasInEdge(node), Graph.HasOutEdge(node)); } foreach (var edge in Graph.Edges.Where(x => selected == Selector.IsSelected(x))) { var @out = TinyGUI.GetOutRect(Graph.GetNode(edge.Out)); var @in = TinyGUI.GetInRect(Graph.GetNode(edge.In)); if (TinyGUI.DrawEdge(@out, @in, selected)) { Selector.AddSingle(edge); } } }
private bool ProcessMouseDown(Event @event) { if (@event.button == 1) { //Clean up selection on right mouse click _selector.Clean(); // _newEdge = EditingEdge.Empty; return(true); } if (@event.button != 0) { return(false); } var node = _graph.GetNodeUnder(Zoomed(CurrentPosition), _selector); if (node == default) { _selector.Clean(); MultiSelectionOn = true; return(false); } //Try Select node or edge on left mouse click var outRect = TinyGUI.GetOutRect(node); NewEdge = outRect.Contains(Zoomed(CurrentPosition)); if (NewEdge) { StartPosition = outRect.center / ZoomOffset; } _selector.AddSingle(node); return(true); }