Exemplo n.º 1
0
        private void panel1_MouseClick(object sender, MouseEventArgs e)
        {
            points.Add(e.Location);
            currentPoints = e.Location;
            Rpoints.Add(e.Location);
            panel1.Invalidate();



            foreach (Point pts in points)
            {
                // propertyGrid1.SelectedObject = pts;
                if (listBox1.SelectedIndex == 0)
                {
                    rectangle rectangle = new rectangle();
                    rectangle.startx = pts.X;
                    rectangle.starty = pts.Y;
                    rectangle.width  = 200;
                    rectangle.length = 100;
                    shapes.Add(rectangle);
                }

                //if (listBox1.SelectedIndex == 1)
                //{
                //    circle circle = new circle();
                //}
            }

            foreach (Shape shape in shapes)
            {
                propertyGrid1.SelectedObject = shape;
            }
        }
Exemplo n.º 2
0
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = panel1.CreateGraphics();



            // Rectangle 1
            rectangle rectangle = new rectangle();

            rectangle.color  = randomColor();
            rectangle.startx = 100;
            rectangle.starty = 200;
            rectangle.width  = 200;
            rectangle.length = 100;
            shapes.Add(rectangle);

            //// Rectangle 2
            //rectangle rectangle2 = new rectangle();
            //rectangle2.startx = 50;
            //rectangle2.starty = 100;
            //rectangle2.width = 100;
            //rectangle2.length = 50;
            //shapes.Add(rectangle2);

            rectangle.Draw(g);
            //rectangle2.Draw(g);

            //foreach (Shape s in shapes)
            //{
            //    s.Draw(g);
            //}
        }