示例#1
0
        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);
                }
            }
        }
示例#2
0
        private void button5_Click(object sender, EventArgs e)
        {
            polygon p = new polygon
            {
                x         = 50,
                y         = 50,
                x2        = 34,
                y2        = 23,
                x3        = 45,
                y3        = 54,
                x4        = 56,
                y4        = 65,
                x5        = 67,
                y5        = 76,
                thickness = 1,
                color     = Color.SandyBrown,
                fillcolor = Color.BlueViolet,
            };

            propertyGrid1.SelectedObject = p;
            shapes.Add(p);
            Refresh();
        }