public void Refresh() { var g = panel1.CreateGraphics(); g.Clear(panel1.BackColor); foreach (var item in shapes) { if (item is rectangle) { rectangle r = (rectangle)item; r.Draw(g); } else if (item is circle) { circle c = (circle)item; c.Draw(g); } else if (item is ellipse) { ellipse e = (ellipse)item; e.Draw(g); } else if (item is line) { line l = (line)item; l.Draw(g); } else if (item is polygon) { polygon p = (polygon)item; p.Draw(g); } } }
private void button3_Click(object sender, EventArgs e) { ellipse el = new ellipse { x = 40, y = 30, r1 = 45, r2 = 89, thickness = 1, color = Color.SteelBlue, fillcolor = Color.Red, }; propertyGrid1.SelectedObject = el; shapes.Add(el); Refresh(); }