Пример #1
0
 // смещение поддерева
 // ======
 public void Delta(HoTSNode p, int dx, int dy)
 {
     p.x -= dx; p.y -= dy;
       if (p.node_Left != null)
     Delta(p.node_Left, dx, dy);
       if (p.node_Right != null)
     Delta(p.node_Right, dx, dy);
 }
Пример #2
0
 // конструктор
 public HoTSNode(HoTSNode Left, HoTSNode Right, int Data, int x, int y)
 {
     node_Left = Left;
       node_Right = Right;
       node_Data = Data;
       this.x = x;
       this.y = y;
       visit = false;
 }
Пример #3
0
 // поиск по координатам
 public HoTSNode FindNode(HoTSNode p, int x, int y)
 {
     HoTSNode result = null;
       if (p == null)
     return result;
       if (((p.x - x) * (p.x - x) + (p.y - y) * (p.y - y)) < 100)
     result = p;
       else
       {
     result = FindNode(p.node_Left, x, y);
     if (result == null)
       result = FindNode(p.node_Right, x, y);
       }
       return result;
 }
Пример #4
0
 // конструктор
 public HoTSTree(int VW, int VH)
 {
     tree_Top = null;
       tree_Canvas = new Bitmap(VW, VH);
       _Font = new Font("Courier New", 10, FontStyle.Bold);
 }
Пример #5
0
 void HoTSGetNum(HoTSNode p)
 {
     if (p != null)
       {
     if (p.node_Left != null && p.node_Left.node_Data == p.node_Data)
       Result = true;
     else
     if (p.node_Right != null && p.node_Right.node_Data == p.node_Data)
       Result = true;
     else
     {
       HoTSGetNum(p.node_Left);
       HoTSGetNum(p.node_Right);
     }
       }
 }
Пример #6
0
        // рисование дерева
        void DrawNode(HoTSNode p)
        {
            int R = 17;
              if (p.node_Left != null)
            _Graph.DrawLine(_Ren, p.x, p.y, p.node_Left.x, p.node_Left.y);
              if (p.node_Right != null)
            _Graph.DrawLine(_Ren, p.x, p.y, p.node_Right.x, p.node_Right.y);

              if (p.visit)
            _Brush = (SolidBrush)Brushes.Yellow;
              else
            _Brush = (SolidBrush)Brushes.LightYellow;

              _Graph.FillEllipse(_Brush, p.x - R, p.y - R, 2 * R, 2 * R);
              _Graph.DrawEllipse(_Ren, p.x - R, p.y - R, 2 * R, 2 * R);
              string s = Convert.ToString(p.node_Data);
              SizeF size = _Graph.MeasureString(s, _Font);
              _Graph.DrawString(s, _Font, Brushes.Black,
              p.x - size.Width / 2,
              p.y - size.Height / 2);

              if (p.node_Left != null)
            DrawNode(p.node_Left);
              if (p.node_Right != null)
            DrawNode(p.node_Right);
        }
Пример #7
0
 // вставка
 public void HoTSInsert(ref HoTSNode t, int data, int x, int y)
 {
     if (t == null)
     t = new HoTSNode(null, null, data, x, y);
       else
       if (data < Convert.ToInt32(t.node_Data))
     HoTSInsert(ref t.node_Left, data, t.x - 50, t.y + 50);
       else
     HoTSInsert(ref t.node_Right, data, t.x + 50, t.y + 50);
 }
Пример #8
0
 public void HoTSDeSelect(HoTSNode Node)
 {
     if (Node != null)
       {
     HoTSDeSelect(Node.node_Left);
     Node.visit = false;
     HoTSDeSelect(Node.node_Right);
       }
 }