Exemplo n.º 1
0
 public BinaryTreeItem(T Value, BinaryTreeItem <T> parent = null, BinaryTreeItem <T> left = null, BinaryTreeItem <T> right = null)
 {
     this.Value  = Value;
     this.parent = parent;
     this.left   = left;
     this.right  = right;
 }
Exemplo n.º 2
0
        private void DrawBranchers(Graphics gr, BinaryTreeItem <int> node)
        {
            if (node.left != null)
            {
                Pen myPen = new Pen(Color.Black, 1);
                gr.DrawLine(myPen,
                            _distance * _listValues.IndexOf(node.Value) + 20,
                            _level_depht * _level_height + 20,
                            _distance * _listValues.IndexOf(node.left.Value) + 20,
                            (_level_depht + 1) * _level_height + 20
                            );
            }

            if (node.right != null)
            {
                Pen p = new Pen(Color.Black, 1);
                gr.DrawLine(p,
                            _distance * _listValues.IndexOf(node.Value) + 20,
                            _level_depht * _level_height + 20,
                            _distance * _listValues.IndexOf(node.right.Value) + 20,
                            (_level_depht + 1) * _level_height + 20
                            );
            }

            gr.FillEllipse(
                new SolidBrush(colorR),
                (_distance * _listValues.IndexOf(node.Value) + 5),
                (_level_depht) * _level_height + 5,
                30, 30
                );

            gr.DrawString(
                node.Value.ToString(),
                this.Font,
                new SolidBrush(Color.White),
                (_distance * _listValues.IndexOf(node.Value) + 20F) - gr.MeasureString(node.Value.ToString(), this.Font).Width / 2F,
                (_level_depht * _level_height + 20) - (int)gr.MeasureString(node.Value.ToString(), this.Font).Height / 2
                );
        }