//the method adds a figure to the FigureList class, and draws the desired figure (Rectangle) private void button2_Click(object sender, EventArgs e) { figlist.figarray.Add("Rec"); using (grx = Graphics.FromImage(bmp)) { grx.DrawRectangle(Pens.Black, figlist.GetRectangle(Convert.ToInt32(textBox8.Text), Convert.ToInt32(textBox7.Text), Convert.ToInt32(textBox6.Text), Convert.ToInt32(textBox5.Text))); } pictureBox1.Image = bmp; }