Esempio n. 1
0
        //малювання точки за координатами заданого кольору
        private void drawPoint(int X, int Y, SolidBrush brush)
        {
            Graphics g = Graphics.FromHwnd(handle);

            int width = network.get_width(), height = network.get_height();
            int x, y;

            x = X * 1000 / width;
            y = Y * 800 / height;

            Point dPoint = new Point(x, (800 - y));

            dPoint.X -= 5;
            dPoint.Y -= 0;

            RectangleF rect = new RectangleF(dPoint, new Size(10, 10));

            // g.FillRectangle(brush, rect);

            g.FillEllipse(brush, rect);
            g.Dispose();
        }
Esempio n. 2
0
        private void draw()
        {
            Node node;
            int  num = network.get_numNodes();

            if (radioButton_2D.Checked == true)
            {
                int x = 0, y = 0;
                int width = network.get_width(), height = network.get_height();
                for (int i = 0; i < num; i++)
                {
                    node = network.get_Node(i);
                    SolidBrush brush;
                    Graphics   g = Graphics.FromHwnd(pictureBox_scene.Handle);
                    if (node.getType() == 1)
                    {
                        brush = new SolidBrush(Color.Black);
                    }
                    else if (node.getType() == 2)
                    {
                        brush = new SolidBrush(Color.Green);
                    }
                    else
                    {
                        brush = new SolidBrush(Color.Red);
                    }

                    x = node.get_X() * 1000 / width;
                    y = node.get_Y() * 800 / height;

                    Point dPoint = new Point(x, (pictureBox_scene.Height - y));
                    dPoint.X -= 5;
                    dPoint.Y -= 5;

                    RectangleF rect = new RectangleF(dPoint, new Size(10, 10));
                    // g.FillRectangle(brush, rect);

                    g.FillEllipse(brush, rect);
                    g.Dispose();
                }
            }
        }