private void triangleButton_Click(object sender, EventArgs e)
 {
     int width;
     int height;
     int x;
     int y;
     Figure triangle;
     while (true)
     {
         width = random.Next(50, 100);
         height = random.Next(50, 100);
         x = random.Next(1, pictureBox1.Width);
         y = random.Next(1, pictureBox1.Height);
         triangle = new Triangle(x, y, width, height);
         if (triangle.IsInRegion(pictureBox1.Width, pictureBox1.Height))
             break;
     }
     triangle.SetStep(random.Next(1, 5), random.Next(1, 5));
     figureList.Add(triangle);
     treeView1.Nodes.Add(triangle.GetType().Name.ToString() + " " + triangle.X + "; " + triangle.Y);
     pictureBox1.Invalidate();
 }