private void canvas_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (StackControl == null && e.ChangedButton == MouseButton.Left && e.LeftButton == MouseButtonState.Released)
            {
                isDrawing = false;

                SimpleFigures ctrl = (SimpleFigures)DrawingVector2DTool.Render(this,
                                                                               new Thickness(data.PrevPoint.X, data.PrevPoint.Y,
                                                                                             e.GetPosition(canvas).X, e.GetPosition(canvas).Y),
                                                                               (XData)data.Clone(), cmd
                                                                               );

                ctrl.GainFocus   += this.OnGainFocus;
                ctrl.LostFocus   += this.OnLostFocus;
                ctrl.FigurePaste += this.OnFigurePaste;

                ctrl.ContextMenu_Color.Click     += new RoutedEventHandler(cmd.aColor.Action);
                ctrl.ContextMenu_PenWidth.Click  += new RoutedEventHandler(cmd.aWidth.Action);
                ctrl.ContextMenu_ShapeType.Click += new RoutedEventHandler(cmd.aType.Action);

                data.AddPosition(e.GetPosition(canvas));
                if (data.Type == ShapeType.MULTILINE)
                {
                    Line[] lines = this.canvas.Children.OfType <Line>().ToArray();
                    foreach (var item in lines)
                    {
                        this.canvas.Children.Remove(item);
                    }
                    data.Path = new List <Point>();
                }
            }
        }
        private void Canvas_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                isDrawing = false;

                SimpleFigures ctrl = (SimpleFigures)DrawingVector2DTool.Render(this,
                                                                               new Rectangle(data.PrevPoint, new Size(e.X - data.PrevPoint.X, e.Y - data.PrevPoint.Y)), (XData)data.Clone(), cmd);
                ctrl.GainFocus   += this.OnGainFocus;
                ctrl.LostFocus   += this.OnLostFocus;
                ctrl.FigurePaste += this.OnFigurePaste;
                this.Controls[Controls.Count - 1].BringToFront();

                ctrl.ContextMenu_Color.Click     += new EventHandler(cmd.aColor.Action);
                ctrl.ContextMenu_PenWidth.Click  += new EventHandler(cmd.aWidth.Action);
                ctrl.ContextMenu_ShapeType.Click += new EventHandler(cmd.aType.Action);
                ctrl.PropertyPanel = (this.Parent.Parent.Parent.Parent as MiniPaintV).propertyPanel;

                data.AddPosition(e.Location);
                if (data.Type == ShapeType.MULTILINE)
                {
                    g.Clear(this.BackColor);
                    data.Path = new List <PointF>();
                }
            }
        }
        public void OnFigurePaste(object sender, EventArgs e)
        {
            Figure obj     = sender as Figure;
            XData  newData = new XData();

            newData.LineColor = Color.FromArgb(obj.Color[0], obj.Color[1], obj.Color[2], obj.Color[3]);
            newData.LineWidth = obj.PenWidth;
            newData.Type      = obj.ShapeType;
            newData.Path      = obj.Path.ToList();

            SimpleFigures ctrl = (SimpleFigures)DrawingVector2DTool.Render(this,
                                                                           obj.Bounds, newData, cmd);

            ctrl.GainFocus   += this.OnGainFocus;
            ctrl.LostFocus   += this.OnLostFocus;
            ctrl.FigurePaste += this.OnFigurePaste;

            ctrl.ContextMenu_Color.Click     += new RoutedEventHandler(cmd.aColor.Action);
            ctrl.ContextMenu_PenWidth.Click  += new RoutedEventHandler(cmd.aWidth.Action);
            ctrl.ContextMenu_ShapeType.Click += new RoutedEventHandler(cmd.aType.Action);
        }
        public void OnFigurePaste(object sender, EventArgs e)
        {
            Figure obj     = sender as Figure;
            XData  newData = new XData();

            newData.LineColor = Color.FromArgb(obj.Color);
            newData.LineWidth = obj.PenWidth;
            newData.Type      = obj.ShapeType;
            newData.Path      = obj.Path.ToList();

            SimpleFigures ctrl = (SimpleFigures)DrawingVector2DTool.Render(this,
                                                                           new Rectangle(new Point(obj.Bounds.X + 20, obj.Bounds.Y + 20), obj.Bounds.Size), newData, cmd);

            ctrl.GainFocus   += this.OnGainFocus;
            ctrl.LostFocus   += this.OnLostFocus;
            ctrl.FigurePaste += this.OnFigurePaste;
            this.Controls[Controls.Count - 1].BringToFront();

            ctrl.ContextMenu_Color.Click     += new EventHandler(cmd.aColor.Action);
            ctrl.ContextMenu_PenWidth.Click  += new EventHandler(cmd.aWidth.Action);
            ctrl.ContextMenu_ShapeType.Click += new EventHandler(cmd.aType.Action);
            ctrl.PropertyPanel = (this.Parent.Parent.Parent.Parent as MiniPaintV).propertyPanel;
        }