public MyBinaryTreeItem(T Value, MyBinaryTreeItem <T> parent = null, MyBinaryTreeItem <T> left = null, MyBinaryTreeItem <T> right = null) { this.Value = Value; this.parent = parent; this.left = left; this.right = right; }
private void DrawBranchers(Graphics gr, MyBinaryTreeItem <int> node) { if (node.left != null) { Pen myPen = new Pen(Color.Black, 1); gr.DrawLine(myPen, _distance * _listValues.IndexOf(node.Value) + 20, _level_depth * _level_height + 20, _distance * _listValues.IndexOf(node.left.Value) + 20, (_level_depth + 1) * _level_height + 20 ); } if (node.right != null) { Pen myPen = new Pen(Color.Black, 1); gr.DrawLine(myPen, _distance * _listValues.IndexOf(node.Value) + 20, _level_depth * _level_height + 20, _distance * _listValues.IndexOf(node.right.Value) + 20, (_level_depth + 1) * _level_height + 20 ); } gr.FillEllipse( new SolidBrush(color), (_distance * _listValues.IndexOf(node.Value) + 5), (_level_depth) * _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_depth * _level_height + 20) - (int)gr.MeasureString(node.Value.ToString(), this.Font).Height / 2 ); }