/// <summary> /// Initializes a new instance of the <see cref="VisualTreeNode"/> class. /// </summary> /// <param name="actualNode">The actual node.</param> public VisualTreeNode(Node actualNode) { this.node = actualNode; this.OutgoingSplits = new VisualSplit[2]; this.viewbox = new Viewbox(); VisualSplit leftSplit = new VisualSplit(this.node.OutgoingSplit); this.OutgoingSplits[0] = leftSplit; VisualSplit rightSplit = new VisualSplit(this.node.OutgoingSplit); this.OutgoingSplits[1] = rightSplit; }
/// <summary> /// Draws the node. /// </summary> /// <param name="node">The node.</param> /// <param name="left">The left.</param> /// <param name="top">The top.</param> /// <param name="divisor">The divisor.</param> private void DrawNode(VisualTreeNode node, double left, double top, double divisor) { node.Left = left; node.Top = top; // Draw Node this.canvas.Children.Add(node.Visualize()); // Recursion for left side if (node.node.LeftNode != null) { VisualSplit leftSplit = node.OutgoingSplits[0]; leftSplit.LeftFrom = left; leftSplit.TopFrom = top; leftSplit.LeftTo = left - left / divisor; leftSplit.TopTo = top + 100; this.canvas.Children.Add(leftSplit.GetLine()); this.canvas.Children.Add(leftSplit.Visualize()); VisualTreeNode leftNode = new VisualTreeNode(node.node.LeftNode); this.DrawNode(leftNode, left - left / divisor, top + 100, divisor * 2); } // Recursion for right side if (node.node.RightNode != null) { VisualSplit rightSplit = node.OutgoingSplits[1]; rightSplit.LeftFrom = left; rightSplit.TopFrom = top; rightSplit.LeftTo = left + left / divisor; rightSplit.TopTo = top + 100; this.canvas.Children.Add(rightSplit.GetLine()); this.canvas.Children.Add(rightSplit.Visualize()); VisualTreeNode rightNode = new VisualTreeNode(node.node.RightNode); this.DrawNode(rightNode, left + left / divisor, top + 100, divisor * 2); } }