private void Deserialize()
        {
            if (!System.IO.File.Exists("figures.txt"))
            {
                MessageBox.Show("Не был найден файл figures.txt", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw new NotImplementedException();
            }
            StreamReader f = new StreamReader("figures.txt");

            figures.list.Clear();
            while (!f.EndOfStream)
            {
                string   s    = f.ReadLine();
                string[] data = s.Split(new char[] { ',' });
                try
                {
                    float  x    = float.Parse(data[1], CultureInfo.InvariantCulture.NumberFormat);
                    float  y    = float.Parse(data[2], CultureInfo.InvariantCulture.NumberFormat);
                    float  w    = float.Parse(data[3], CultureInfo.InvariantCulture.NumberFormat);
                    float  h    = float.Parse(data[4], CultureInfo.InvariantCulture.NumberFormat);
                    Point  a    = new Point((int)x, (int)y);
                    Point  b    = new Point((int)w, (int)h);
                    String type = data[0];
                    switch (type)
                    {
                    case "Rect":
                        Factory = new CreateRect();
                        break;

                    /*case "Oval":
                     *  Factory = new CreateOval();
                     *  break;
                     * case "Line":
                     *  Factory = new CreateLine();
                     *  break;
                     * case "Triangle":
                     *  Factory = new CreateTriangle();
                     *  break;
                     * case "Rhombus":
                     *  Factory = new CreateRhombus();
                     *  break;
                     * case "Star":
                     *  Factory = new CreateStar();
                     *  break;*/
                    default:
                        Factory = null;
                        break;
                    }
                    AbstrFigure figure = Factory.FactoryMethod(a, b);//проверка на null
                    figures.list.Add(figure);
                }
                catch
                {
                }
            }
            f.Close();
        }
 private void OnPanelMousePressed(object sender, MouseEventArgs e)
 {
     if (isToolChosen)
     {
         SearchForFigure(e.Location);
         leftUpVert = e.Location;
         AbstrFigure figure = Factory.FactoryMethod(leftUpVert, leftUpVert);
         this.figures.Add(figure);
         isPressed = true;
     }
     else if ((isSelectionToolChosen) && (figures.Count() > 0))
     {
         Point point = e.Location;
         SearchForFigure(point);
     }
 }