コード例 #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 button4_Click(object sender, EventArgs e)
        {
            line l = new line
            {
                x     = 67,
                y     = 30,
                x2    = 12,
                y2    = 21,
                color = Color.Black,
            };

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