private void ButtonDraw_Click(object sender, EventArgs e) { Graphics gr = pictureBox.CreateGraphics(); Pen pen = new Pen(Color.Red, 3); Random rnd = new Random(); Shape_Point[] shapes = new Shape_Point[20]; for (int i = 0; i < shapes.Length; i++) { int shape = rnd.Next(1, 5); int x = rnd.Next(0, 700); int y = rnd.Next(0, 300); int x1 = rnd.Next(0, 700); int y1 = rnd.Next(0, 300); int rad = rnd.Next(0, 170); int width = rnd.Next(0, 170); switch (shape) { case 1: { shapes[i] = new Point(x, y, pen.Color, Convert.ToByte(pen.Width)); shapes[i].Draw(gr); } break; case 2: { shapes[i] = new Line(x, y, pen.Color, Convert.ToByte(pen.Width), x1, y1); shapes[i].Draw(gr); } break; case 3: { shapes[i] = new Rectangle(x, y, pen.Color, Convert.ToByte(pen.Width), x1, y1); shapes[i].Draw(gr); } break; case 4: { shapes[i] = new Circle(x, y, pen.Color, Convert.ToByte(pen.Width), rad); shapes[i].Draw(gr); } break; case 5: { shapes[i] = new Elipse(x, y, pen.Color, Convert.ToByte(pen.Width), width, rad); shapes[i].Draw(gr); } break; } } }
public Elipse(Elipse elipse) : base(elipse) { Width = elipse.Width; }