Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            lan = new LAN();

            groupBoxRegime.Controls.Add(radioButtonAddConnection);
            groupBoxRegime.Controls.Add(radioButtonDeleteConnection);
            groupBoxRegime.Controls.Add(radioButtonAddVertex);
            groupBoxRegime.Controls.Add(radioButtonDeleteVertex);
            groupBoxRegime.Controls.Add(radioButtonMoveVertex);

            groupBoxVertexType.Controls.Add(radioButtonComputer);
            groupBoxVertexType.Controls.Add(radioButtonPrinter);
            groupBoxVertexType.Controls.Add(radioButtonRouter);
            groupBoxVertexType.Controls.Add(radioButtonForAngle);
            radioButtonForAngle.Checked = true;

            groupBoxConnectionType.Controls.Add(radioButtonWall);
            groupBoxConnectionType.Controls.Add(radioButtonCable);
            radioButtonWall.Checked = true;

            g         = pictureBox1.CreateGraphics();
            rectangle = pictureBox1.ClientRectangle;
            rectangle.Width--;
            rectangle.Height--;
        }
Пример #2
0
        public static void Draw(Graphics g, LAN lan)
        {
            foreach (Vertex vertex in lan.Vertexes)
            {
                if (vertex != null)
                {
                    vertex.IsDrawn = false;
                }
            }

            foreach (Vertex x in lan.Vertexes)
            {
                if (x != null)
                {
                    Draw(g, x, lan); // передаем один из узлов
                }
            }
        }
Пример #3
0
 private static void DrawVertex(Graphics g, Vertex vertex, LAN lan)
 {
     if (vertex.Type == "PRINTER")
     {
         g.DrawImage(printerImage, new Point(vertex.X - 25, vertex.Y - 25));
         if (vertex == lan.ToMove)
         {
             g.DrawEllipse(movePen, vertex.X - 25, vertex.Y - 25, 50, 50);
         }
     }
     if (vertex.Type == "COMPUTER")
     {
         g.DrawImage(computerImage, new Point(vertex.X - 25, vertex.Y - 25));
         if (vertex == lan.ToMove)
         {
             g.DrawEllipse(movePen, vertex.X - 25, vertex.Y - 25, 60, 60);
         }
     }
     if (vertex.Type == "ROUTER")
     {
         g.DrawImage(routerImage, new Point(vertex.X - 25, vertex.Y - 25));
         if (vertex == lan.ToMove)
         {
             g.DrawEllipse(movePen, vertex.X - 30, vertex.Y - 30, 60, 60);
         }
     }
     if (vertex.Type == "FOR_ANGLE")
     {
         if (vertex == lan.ToMove)
         {
             g.FillEllipse(moveBrush, vertex.X - 10, vertex.Y - 10, 20, 20);
             g.DrawEllipse(movePen, vertex.X - 10, vertex.Y - 10, 20, 20);
         }
         else
         {
             g.FillEllipse(angleBrush, vertex.X - 10, vertex.Y - 10, 20, 20);
             g.DrawEllipse(anglePen, vertex.X - 10, vertex.Y - 10, 20, 20);
         }
     }
 }
Пример #4
0
        private static void Draw(Graphics g, Vertex vertex, LAN lan)
        {
            if (vertex.IsDrawn)
            {
                return;
            }
            if (vertex.MyConnections != null)
            {
                foreach (MyConnection connection in vertex.MyConnections)
                {
                    if (connection != null)
                    {
                        if (vertex == connection.RightVertex)
                        {
                            if (connection.LeftVertex != null)
                            {
                                if (!connection.LeftVertex.IsDrawn)
                                {
                                    DrawConnection(g, vertex, connection.LeftVertex, connection);
                                }
                            }
                        }

                        if (vertex == connection.LeftVertex)
                        {
                            if (connection.RightVertex != null)
                            {
                                if (!connection.RightVertex.IsDrawn)
                                {
                                    DrawConnection(g, vertex, connection.RightVertex, connection);
                                }
                            }
                        }
                    }
                }
            }

            DrawVertex(g, vertex, lan);
            vertex.IsDrawn = true;
        }