private void BCreateFigure_Click(object sender, RoutedEventArgs e)
        {
            if (ListBoxOfFigures.SelectedItems.Count > 1)
            {
                compFigNameEn = "";
                compFigNameRu = "";
                partFigures   = new List <System.Windows.Shapes.Path>();
                int i = 0;
                foreach (ListBoxItem selectedfig in ListBoxOfFigures.SelectedItems)
                {
                    partFigures.Add(listOfFigures[ListBoxOfFigures.Items.IndexOf(selectedfig)].path);
                    i++;
                }
                WCreateFigure wCreate = new WCreateFigure();
                wCreate.Owner = this;
                wCreate.ShowDialog();

                if (compFigNameRu != "" && compFigNameEn != "")
                {
                    CompositeFigure figureType = (CompositeFigure)Activator.CreateInstance(typeof(CompositeFigure), canvas, color, startPoint, endPoint, partFigures, compFigNameEn, compFigNameRu);
                    compositeFigList.Add(figureType);
                    Button figureButton = new Button();
                    figureButton        = figureType.MakeButton(lang);
                    figureButton.Click += CompFigureButton_Click;
                    ShapesPanel.Children.Add(figureButton);
                }
            }
        }
 private void DrawCompButtons()
 {
     try
     {
         var allFigures = basicFigures.Concat(additionalFigList);
         allFigures = allFigures.Concat(compositeFigList);
         var           a         = allFigures.Select(x => x.GetType()).Distinct();
         XmlSerializer formatter = new XmlSerializer(typeof(Figure[]), a.ToArray());
         using (FileStream fs = new FileStream(compFile, FileMode.OpenOrCreate))
         {
             Figure[] figures = (Figure[])formatter.Deserialize(fs);
             foreach (Figure figure in figures)
             {
                 compositeFigList.Add((CompositeFigure)figure);
                 CompositeFigure figureType = (CompositeFigure)Activator.CreateInstance(typeof(CompositeFigure), canvas, color, startPoint, endPoint, partFigures, compFigNameEn, compFigNameRu);
                 compositeFigList.Add(figureType);
                 Button figureButton = new Button();
                 figureButton        = figureType.MakeButton(lang);
                 figureButton.Click += CompFigureButton_Click;
                 ShapesPanel.Children.Add(figureButton);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }