예제 #1
0
파일: Print.cs 프로젝트: tazik047/alg_sd
 public Print(AbsTree <C, T> tree)
     : this()
 {
     this.tree = tree;
     creartePos(position, tree);
     drawTree();
 }
예제 #2
0
파일: Print.cs 프로젝트: tazik047/alg_sd
 private int countHeight(AbsTree <C, T> t)
 {
     if (t == null)
     {
         return(0);
     }
     return(countHeight(t.Left) > countHeight(t.Right) ?
            (countHeight(t.Left) + 1) : (countHeight(t.Right) + 1));
 }
예제 #3
0
파일: Print.cs 프로젝트: tazik047/alg_sd
 private void creartePos(Tree <Point> p, AbsTree <C, T> t)
 {
     if (t == null)
     {
         return;
     }
     if (t.Left != null)
     {
         p.Left = new Tree <Point>(new Point());
         creartePos(p.Left, t.Left);
     }
     if (t.Right != null)
     {
         p.Right = new Tree <Point>(new Point());
         creartePos(p.Right, t.Right);
     }
 }
예제 #4
0
파일: Print.cs 프로젝트: tazik047/alg_sd
        private void draw(Graphics g, Tree <Point> poin, AbsTree <C, T> t)
        {
            if (poin == null)
            {
                return;
            }

            Point p         = poin.Value;
            var   colorText = Brushes.Black;

            if (t.color != Color.Transparent)
            {
                if (t.color == Color.Black)
                {
                    colorText = Brushes.White;
                }
                g.FillEllipse(t.color == Color.Red ? Brushes.Red : Brushes.Black, p.X, p.Y, circleSize, circleSize);
            }
            g.DrawEllipse(Pens.Black, p.X, p.Y, circleSize, circleSize);
            int r;

            if (Int32.TryParse(t.Value.ToString(), out r))
            {
                g.DrawString(t.Value.ToString(), Font, colorText, p.X + 1, p.Y + 2);
            }
            else
            {
                StringFormat f = new StringFormat();
                f.FormatFlags = StringFormatFlags.DirectionVertical;
                g.DrawString(t.Value.ToString(), Font, colorText, p.X + 1, p.Y + 2, f);
            }
            if (t.Left != null)
            {
                g.DrawLine(Pens.Black, poin.Value.X + 2, poin.Value.Y + 15, poin.Left.Value.X + 15, poin.Left.Value.Y + 2);
                draw(g, poin.Left, t.Left);
            }
            if (t.Right != null)
            {
                g.DrawLine(Pens.Black, poin.Value.X + 15, poin.Value.Y + 15, poin.Right.Value.X + 2, poin.Right.Value.Y + 2);
                draw(g, poin.Right, t.Right);
            }
        }