예제 #1
0
 void DrawNode(IDrawer drawer, Node node, float x, float y)
 {
     drawer.DrawNode(x - drawer.Diametr / 2, y - drawer.Diametr / 2);
     drawer.DrawName(node.Name, x, y);
     drawer.DrawOrder(node.Value, x, y);
     if (node.NodesCount > 0)
     {
         int   count = GenerationCount(node.Gen + 1);
         float x_new = 0;
         float x_add = drawer.XMargin;
         try
         {
             x_add = GenLastXPairs[node.Gen + 1];
         }
         catch { }
         int nodeCount = 0;
         if (node.LeftNode != null)
         {
             x_new = x_add + (drawer.CanvasWidth / count) * nodeCount;
             drawer.DrawEdge(x, x_new, y, y + drawer.Distance);
             DrawNode(drawer, node.LeftNode, x_new, y + drawer.Distance);
             nodeCount++;
         }
         if (node.RightNode != null)
         {
             x_new = x_add + (drawer.CanvasWidth / count) * nodeCount;
             drawer.DrawEdge(x, x_new, y, y + drawer.Distance);
             DrawNode(drawer, node.RightNode, x_new, y + drawer.Distance);
         }
         try
         {
             GenLastXPairs.Add(node.Gen + 1, x_new + (drawer.CanvasWidth / count));
         }
         catch
         {
             GenLastXPairs[node.Gen + 1] = x_new + (drawer.CanvasWidth / count);
         }
     }
 }