示例#1
0
文件: Form1.cs 项目: Aigerimmsadir/d
        private void button1_Click(object sender, EventArgs e)
        {
            Graphics g  = pictureBox1.CreateGraphics();
            MyShape  ms = new MyShape(new RectangleF(10, 10, 30, 30), Color.Red);

            ms.Draw(g);
        }
示例#2
0
文件: Form1.cs 项目: AiymR/PT_2017
        private void button1_Click(object sender, EventArgs e)
        {
            Random r = new Random();

            Color[] colors = new Color[] { Color.Red, Color.Green, Color.Blue };

            Graphics g = pictureBox1.CreateGraphics();

            for (int i = 0; i < 5; ++i)
            {
                int     x  = r.Next(0, pictureBox1.Width);
                int     y  = r.Next(0, pictureBox1.Height);
                int     ci = r.Next(0, colors.Length);
                MyShape ms = new MyShape(new RectangleF(x, y, 30, 30), colors[ci]);
                ms.Draw(g);
            }
        }