Exemplo n.º 1
0
 int NullCount(TEdge[] Input, out int Pos)
 {
     int Count = 0;
       Pos = 0;
       for (int i = 0; i < Input.Length; i++)
     if (Input[i].edge_NameNode == null)
     {
       Pos = i;
       Count++;
     }
       return Count;
 }
Exemplo n.º 2
0
 void DrawName(TEdge Road, Brush brush)
 {
     int First, Second;
       MyFont = new Font("Courier New", (float)(I2 / (x2p - x1p)), FontStyle.Bold);
       FindMaxVectorCoords(Road.edge_Points, out First, out Second);
       double x1 = Road.edge_Points[First].edge_x,
     x2 = Road.edge_Points[Second].edge_x,
     y1 = Road.edge_Points[First].edge_y,
     y2 = Road.edge_Points[Second].edge_y;
       double Angle = Math.Atan((y2 - y1) / (x2 - x1))/ 3.14 * 180;
       int X = II(x1);
       int Y = JJ(y1);
       using (Graphics g = Graphics.FromImage(bitmap))
       {
     g.TranslateTransform(X, Y);
     g.RotateTransform((int)Angle);
     g.DrawString(Road.edge_NameEdge, MyFont, brush, 0, 0);
     g.RotateTransform((int)-Angle);
     g.TranslateTransform(-X, -Y);
       }
 }
Exemplo n.º 3
0
        void DrawEdge(TEdge Road)
        {
            using (Graphics g = Graphics.FromImage(bitmap))
              {
            Color MyColor = Road.edge_NameEdge == SelectEdge.edge_NameEdge ? Color.Red : Road.edge_Level == 0 ? Color.Silver : Road.edge_Level == 1 ? Color.Black : Color.Orange;
            Pen MyPen = new Pen(MyColor);

            int Length = Road.edge_Points.Count;
            for (int i = 1; i < Length; i++)
            {
              g.DrawLine(MyPen, new Point(II(Road.edge_Points[i - 1].edge_x), JJ(Road.edge_Points[i - 1].edge_y)),
                   new Point(II(Road.edge_Points[i].edge_x), JJ(Road.edge_Points[i].edge_y)));
              DrawAdditionalEdges(MyColor, Road.edge_Points[i - 1].edge_x, Road.edge_Points[i - 1].edge_y,
              Road.edge_Points[i].edge_x, Road.edge_Points[i].edge_y, Road.edge_Rows - 1);
            }
              }
        }
Exemplo n.º 4
0
 //Черная магия с удалением связей
 public TEdge[] EdgeArrDeleted(TNode Node, string NeedToDelete)
 {
     TEdge[] Out = null;
       if (Node.node_Edge != null && Node.node_Edge.Length != 1)
       {
     Out = new TEdge[Node.node_Edge.Length - 1];
     int Length = Node.node_Edge.Length, Position = 0;
     for (int i = 0; i < Length; i++)
       if (Node.node_Edge[i].edge_NameNode != NeedToDelete)
     Out[Position++] = Node.node_Edge[i];
     int Pos = 0;
     while (NullCount(Out, out Pos) != 0)
       Out[Position++] = Node.node_Edge[Pos];
       }
       return Out;
 }
Exemplo n.º 5
0
 //======================================================================  Примитивные операции с узлами и ребрами
 public void AddEdge(int Level, int Count, out string Error)
 {
     Error = "";
       SetEdge(SelectNode, SelectNodeBeg, Level, Count);
       CurrentLine = new TEdge();
 }
Exemplo n.º 6
0
        public void DeleteNode()
        {
            int n = -1;
              bool ok = false;
              int Ln = Nodes.Length;
              while ((n < Ln - 1) && !ok)
            ok = Nodes[++n] == SelectNode;

              if (SelectNode.Edge != null)
              {
            Ln = SelectNode.Edge.Length;
            for (int i = 0; i < Ln; i++)
            {
              int NumNode = ReturnNumber(SelectNode.Edge[i].nameNode);
              int LN = Nodes[NumNode].Edge.Length;
              TEdge[] New = new TEdge[LN - 1];
              for (int k = 0; k < LN; k++)
            if (ReturnNumber(Nodes[NumNode].Edge[k].nameNode) == n)
            {
              Nodes[NumNode].Edge[k] = new TEdge();
              break;
            }
              int count = 0;
              for (int l = 0; l < LN; l++)
            if (Nodes[NumNode].Edge[l].nameNode != null)
            {
              New[count] = Nodes[NumNode].Edge[l];
              count++;
            }
              Nodes[NumNode].Edge = New;
            }
              }
              Nodes[n] = null;
              SelectNode = null;
              Ln = Nodes.Length;
              TNode[] NewArr = new TNode[Ln - 1];
              int Num = 0;
              for (int i = 0; i < Ln; i++)
            if (Nodes[i] != null)
              NewArr[Num++] = Nodes[i];
              Nodes = NewArr;
        }