public static void drawLinks(Graphics g, Nodes.Node n) { foreach (var kvp in n.getProperties()) { if (kvp.Value.isInput && kvp.Value.input != null) { if (kvp.Value.getType() == NodeProperties.Type.CHANNELS) { g.DrawLine(linkChannels, NodeArtist.getJointPos(kvp.Value.input.node, kvp.Value.input.port, false), NodeArtist.getJointPos(n, kvp.Key, true)); } else if (kvp.Value.getType() == NodeProperties.Type.COLOR) { g.DrawLine(linkColors, NodeArtist.getJointPos(kvp.Value.input.node, kvp.Value.input.port, false), NodeArtist.getJointPos(n, kvp.Key, true)); } else if (kvp.Value.getType() == NodeProperties.Type.VECTORS) { g.DrawLine(linkVectors, NodeArtist.getJointPos(kvp.Value.input.node, kvp.Value.input.port, false), NodeArtist.getJointPos(n, kvp.Key, true)); } else { g.DrawLine(linePen, NodeArtist.getJointPos(kvp.Value.input.node, kvp.Value.input.port, false), NodeArtist.getJointPos(n, kvp.Key, true)); } } } }
private void recalcFocus() { var nodes = project.getNodes(); int left = int.MaxValue, right = int.MinValue, top = int.MaxValue, bottom = int.MinValue; foreach (Node n in nodes) { Rectangle r = NodeArtist.getRect(n); if (r.Left < left) { left = r.Left; } if (r.Right > right) { right = r.Right; } if (r.Top < top) { top = r.Top; } if (r.Bottom > bottom) { bottom = r.Bottom; } } setFocusRect(left, top, right - left + 100, bottom - top + 50); }
private Node.Address hitTest(int x, int y, bool input) { var nodes = project.getNodes(); //x and y are in screen coordinates where // (0, 0) is the top left of the panel ScreenToCanvas(ref x, ref y); string s; Rectangle rect; foreach (Node n in nodes) { rect = NodeArtist.getPaddedRect(n); if (rect.Contains(x, y)) { s = NodeArtist.hitJoint(n, rect, x, y, input); return(new Node.Address(n, s)); } } return(new Node.Address(null, null)); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); var nodes = project.getNodes(); var selectedNodes = project.selectedNodes; Graphics g = e.Graphics; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; foreach (Node n in nodes) { NodeArtist.drawLinks(g, n); } g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default; foreach (Node n in nodes) { NodeArtist.drawGraphNode(g, n, selectedNodes.Contains(n)); } if (bLinking) { g.DrawLine(NodeArtist.linePen, mdown, mdrag); } }