protected void GenerateEdges(TextWriter writer, Tree parent) { if (!Tree.IsLeaf(parent)) { var b1 = BoundsOfNode(parent); float x1 = b1.Center.X; float y1 = b1.Center.Y; foreach (Tree child in Tree.Children(parent)) { var childbounds = BoundsOfNode(child); float x2 = childbounds.Center.X; float y2 = childbounds.BottomLeft.Y; writer.WriteLine(Line("" + x1, "" + y1, "" + x2, "" + y2, "stroke:black; stroke-width:1px;")); GenerateEdges(writer, child); } } }
protected void PaintEdges(Graphics g, Tree parent) { if (!Tree.IsLeaf(parent)) { Pen stroke = new Pen(Colors.Black, 1.0f) { LineCap = PenLineCap.Round, LineJoin = PenLineJoin.Round }; var parentBounds = BoundsOfNode(parent); float x1 = parentBounds.Center.X; float y1 = parentBounds.TopLeft.Y; foreach (Tree child in Tree.Children(parent)) { var childBounds = BoundsOfNode(child); float x2 = childBounds.Center.X; float y2 = childBounds.TopLeft.Y; //if (UseCurvedEdges) //{ // CubicCurve2D c = new CubicCurve2D.Double(); // float ctrlx1 = x1; // float ctrly1 = (y1 + y2) / 2; // float ctrlx2 = x2; // float ctrly2 = y1; // c.setCurve(x1, y1, ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2); // g.DrawArc(stroke,); //} //else //{ System.Console.WriteLine($"{x1},{y1},{x2},{y2}"); g.DrawLine(stroke, x1, y1, x2, y2); //} PaintEdges(g, child); } } }