private void deleteLine_Click(object sender, RoutedEventArgs e)
        {
            shape.RemoveAll(dataLine);
            currentLine = new Line();
            canvas.Children.Add(currentLine);
            shape = new Composite.MainShape(currentLine, coordinateSystem);

            ActivateMergeBecauseOfLines();
            ActivateMorffingButton();
        }
 public MainWindow()
 {
     InitializeComponent();
     coordinateSystem = new CoordinateSystem2DInteractor(canvas.Width, canvas.Height);
     canvas.Children.Add(currentLine);
     shape = new Composite.MainShape(currentLine, coordinateSystem);
     ActivateDoZ();
     MouseMove      += dragElement_MouseMove;
     MouseDown      += pickElement_MouseDown;
     MouseUp        += dropElement_MouseUp;
     KeyDown        += pickFewElements_KeyDown;
     KeyUp          += upKey_KeyUp;
     PreviewMouseUp += upMouse;
     ChangeEnabling(false);
     ActivateMergeBecauseOfLines();
 }
        private void LoadButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "xml files (*.xml)|*.xml";

            if (ofd.ShowDialog() == true)
            {
                id = 0;
                canvas.Children.Clear();
                dataLine.Clear();
                currentLine = new Line();
                canvas.Children.Add(currentLine);
                shape = new MainShape(currentLine, coordinateSystem);

                XmlSerializer formatter = new XmlSerializer(typeof(List <LineData>));

                using (var fs = new FileStream(ofd.FileName, FileMode.Open))
                {
                    dataLine = formatter.Deserialize(fs) as List <LineData>;
                }
            }

            foreach (var d in dataLine)
            {
                var line = new Line()
                {
                    X1 = d.X1,
                    Y1 = d.Y1,
                    X2 = d.X2,
                    Y2 = d.Y2,
                    StrokeThickness = d.StrokeThickness,
                    Stroke          = Brushes.Black,
                    Tag             = id
                };
                canvas.Children.Add(line);
                id++;
            }
        }
        private void pickElement_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (median)
            {
                var line       = shape.GetLastShape() as Line;
                var medianLine = interactor.CreateMedian(e.GetPosition(canvas), line, id);
                canvas.Children.Add(medianLine);
                dataLine.Add(new LineData
                {
                    Id = id,
                    X1 = medianLine.X1,
                    Y1 = medianLine.Y1,
                    Z1 = 0,
                    X2 = medianLine.X2,
                    Y2 = medianLine.Y2,
                    Z2 = 0,
                    StrokeThickness = medianLine.StrokeThickness
                });
                ++id;
                median = false;
            }
            else if (height)
            {
                var line       = shape.GetLastShape() as Line;
                var heightLine = interactor.CreateHeight(e.GetPosition(canvas), line, id);
                canvas.Children.Add(heightLine);
                dataLine.Add(new LineData
                {
                    Id = id,
                    X1 = heightLine.X1,
                    Y1 = heightLine.Y1,
                    Z1 = 0,
                    X2 = heightLine.X2,
                    Y2 = heightLine.Y2,
                    Z2 = 0,
                    StrokeThickness = heightLine.StrokeThickness
                });
                ++id;
                height = false;
            }

            if (localCS)
            {
                var lines = canvas.Children.Cast <FrameworkElement>().Where(x => x.Name == "Axis").ToArray();
                ClearCoordinateSystem(lines);
                var point = e.GetPosition(canvas);
                coordinateSystem.SetOffsetVector(new double[] { point.X, point.Y });
                localCS = false;
                if (enabledCS == true)
                {
                    AddCoordinateSystem();
                }
            }

            if (e.Source is Shape)
            {
                if (!downed)
                {
                    if (!group.ContainsShape(shape))
                    {
                        shape.ClearColor();
                    }
                    currentLine = new Line();
                    canvas.Children.Add(currentLine);
                    shape = new Composite.MainShape(currentLine, coordinateSystem);
                }

                shape.PickAddShape(e.Source as Shape, dataLine);

                ShowCoordinates();
            }

            ActivateMergeBecauseOfLines();
            ActivateMorffingButton();
        }