Beispiel #1
0
        /// <summary>
        /// Change T type for Style, save history, invalidate canvas.
        /// </summary>
        /// <typeparam name="T"> The T type property. </typeparam>
        /// <param name="set"> The sets of T. </param>
        /// <param name="type"> The history type. </param>
        /// <param name="getUndo"> The gets of history undo T. </param>
        /// <param name="setUndo"> The sets of history undo T. </param>
        public void StyleChanged <T>(Action <IStyle, Transformer> set, HistoryType type, Func <IStyle, T> getUndo, Action <IStyle, T> setUndo)
        {
            // History
            LayersPropertyHistory history = new LayersPropertyHistory(type);

            // Selection
            this.SetValueWithChildrenOnlyGroup((layerage) =>
            {
                ILayer layer = layerage.Self;

                var previous        = getUndo(layer.Style);
                history.UndoAction += () =>
                {
                    // Refactoring
                    layer.IsRefactoringRender     = true;
                    layer.IsRefactoringIconRender = true;
                    setUndo(layer.Style, previous);
                };

                // Refactoring
                layer.IsRefactoringRender     = true;
                layer.IsRefactoringIconRender = true;
                layerage.RefactoringParentsRender();
                layerage.RefactoringParentsIconRender();
                set(layer.Style, layer.Transform.Transformer);
                this.StandardStyleLayer = layer;
            });

            // History
            this.HistoryPush(history);

            this.Invalidate(); // Invalidate
        }
        public void MethodSelectedNone()
        {
            //History
            LayersPropertyHistory history = new LayersPropertyHistory("Set select mode");

            //Selection
            this.SetValue((layerage) =>
            {
                ILayer layer = layerage.Self;

                if (layer.IsSelected == true)
                {
                    //History
                    var previous        = layer.IsSelected;
                    history.UndoAction += () =>
                    {
                        layer.IsSelected = previous;
                    };

                    layer.IsSelected = false;
                }
            });

            //History
            this.HistoryPush(history);

            this.SetModeNone(); //Selection
            LayerageCollection.ArrangeLayersBackground(this.LayerageCollection);
            this.Invalidate();  //Invalidate
        }
        public void MethodSelectedSubtract(Layerage selectedLayerage)
        {
            ILayer selectedLayer = selectedLayerage.Self;

            //History
            LayersPropertyHistory history = new LayersPropertyHistory("Set select mode");

            if (selectedLayerage.Self.IsSelected == true)
            {
                //History
                var previous = selectedLayer.IsSelected;
                history.UndoAction += () =>
                {
                    selectedLayer.IsSelected = previous;
                };

                selectedLayer.IsSelected = false;
            }

            //History
            this.HistoryPush(history);

            this.SetMode(this.LayerageCollection); //Selection
            LayerageCollection.ArrangeLayersBackground(this.LayerageCollection);
            this.Invalidate();                     //Invalidate
        }
Beispiel #4
0
        private void RectChooseComplete(Vector2 canvasStartingPoint, Vector2 canvasPoint)
        {
            this.TransformerRect = new TransformerRect(canvasStartingPoint, canvasPoint);

            //History
            LayersPropertyHistory history = new LayersPropertyHistory("Set nodes is checked");

            //Selection
            this.SelectionViewModel.SetValue((layerage) =>
            {
                ILayer layer = layerage.Self;

                if (layer.Type == LayerType.Curve)
                {
                    layer.Nodes.BoxChoose(this.TransformerRect);

                    //History
                    var previous        = layer.Nodes.NodesStartingClone().ToList();
                    history.UndoAction += () =>
                    {
                        //Refactoring
                        layer.IsRefactoringTransformer = true;
                        layer.IsRefactoringRender      = true;
                        layer.IsRefactoringIconRender  = true;
                        layer.Nodes.NodesReplace(previous);
                    };
                }
            });

            //History
            this.ViewModel.HistoryPush(history);
        }
Beispiel #5
0
        public void ILayerChangeCompleted <T>(Action <ILayer> set, HistoryType type, Func <ILayer, T> getUndo, Action <ILayer, T> setUndo)
        {
            // History
            LayersPropertyHistory history = new LayersPropertyHistory(type);

            // Selection
            this.SetValue((layerage) =>
            {
                ILayer layer = layerage.Self;

                var previous        = getUndo(layer);
                history.UndoAction += () =>
                {
                    // Refactoring
                    layer.IsRefactoringRender     = true;
                    layer.IsRefactoringIconRender = true;
                    setUndo(layer, previous);
                };

                // Refactoring
                layer.IsRefactoringRender     = true;
                layer.IsRefactoringIconRender = true;
                layerage.RefactoringParentsRender();
                layerage.RefactoringParentsIconRender();
                set(layer);
            });

            // History
            this.HistoryPush(history);

            this.Invalidate(); // Invalidate
        }
        private void CropComplete()
        {
            ILayer layer = this.Layerage.Self;

            // History
            LayersPropertyHistory history = new LayersPropertyHistory(HistoryType.LayersProperty_SetTransform_CropTransformer);

            // History
            var previous = layer.Transform.StartingCropTransformer;

            history.UndoAction += () =>
            {
                // Refactoring
                layer.IsRefactoringRender       = true;
                layer.IsRefactoringIconRender   = true;
                layer.Transform.CropTransformer = previous;
            };

            // History
            this.ViewModel.HistoryPush(history);

            // Refactoring
            layer.IsRefactoringRender     = true;
            layer.IsRefactoringIconRender = true;
            this.Layerage.RefactoringParentsRender();
            this.Layerage.RefactoringParentsIconRender();
        }
        public void Clicke(Vector2 point)
        {
            Matrix3x2 matrix = this.ViewModel.CanvasTransformer.GetMatrix();

            //History
            LayersPropertyHistory history = new LayersPropertyHistory("Set nodes is checked");

            //Selection
            this.SelectionViewModel.SetValue((layerage) =>
            {
                ILayer layer = layerage.Self;

                if (layer.Type == LayerType.Curve)
                {
                    layer.Nodes.CacheTransform();
                    layer.Nodes.SelectionOnlyOne(point, matrix);

                    //History
                    var previous        = layer.Nodes.NodesStartingClone().ToList();
                    history.UndoAction += () =>
                    {
                        //Refactoring
                        layer.Nodes.NodesReplace(previous);
                    };
                }
            });

            //History
            this.ViewModel.HistoryPush(history);

            this.ViewModel.Invalidate();//Invalidate
        }
        private async void ShowRenameDialog()
        {
            string placeholderText = this.SelectionViewModel.LayerName;
            string name            = await this.ShowRenameDialogTask(placeholderText);

            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            // History
            LayersPropertyHistory history = new LayersPropertyHistory(HistoryType.LayersProperty_SetName);

            // Selection
            this.SelectionViewModel.LayerName = name;
            this.SelectionViewModel.SetValue((layerage) =>
            {
                ILayer layer = layerage.Self;

                if (layer.Name != name)
                {
                    // History
                    var previous        = layer.Name;
                    history.UndoAction += () =>
                    {
                        layer.Name = previous;
                    };

                    layer.Name = name;
                }
            });

            // History
            this.ViewModel.HistoryPush(history);
        }
        /// <summary>
        /// Change T type for TAdjustment, save history, invalidate canvas.
        /// </summary>
        /// <typeparam name="T"> The T type property. </typeparam>
        /// <typeparam name="TAdjustment"> The T type layer. </typeparam>
        /// <param name="index"> The adjustment index. </param>
        /// <param name="set"> The sets of T. </param>
        /// <param name="historyTitle"> The history title. </param>
        /// <param name="getHistory"> The gets of history T. </param>
        /// <param name="setHistory"> The sets of history T. </param>
        public void TAdjustmentChanged <T, TAdjustment>
        (
            int index,
            Action <TAdjustment> set,
            string historyTitle, Func <TAdjustment, T> getHistory, Action <TAdjustment, T> setHistory
        )
            where TAdjustment : IAdjustment
        {
            if (this.SelectionLayerage is Layerage layerage)
            {
                ILayer layer = layerage.Self;

                if (index < 0)
                {
                    return;
                }
                if (index > layer.Filter.Adjustments.Count - 1)
                {
                    return;
                }
                if (layer.Filter.Adjustments[index] is TAdjustment adjustment)
                {
                    //History
                    LayersPropertyHistory history = new LayersPropertyHistory(historyTitle);

                    var previous  = layer.Filter.Adjustments.IndexOf(adjustment);
                    var previous1 = getHistory(adjustment);
                    history.UndoAction += () =>
                    {
                        if (previous < 0)
                        {
                            return;
                        }
                        if (previous > layer.Filter.Adjustments.Count - 1)
                        {
                            return;
                        }
                        if (layer.Filter.Adjustments[previous] is TAdjustment previousAdjustment)
                        {
                            //Refactoring
                            layer.IsRefactoringTransformer = true;
                            layer.IsRefactoringRender      = true;
                            setHistory(previousAdjustment, previous1);
                        }
                    };

                    //Refactoring
                    layer.IsRefactoringTransformer = true;
                    layer.IsRefactoringRender      = true;
                    layerage.RefactoringParentsRender();
                    layerage.RefactoringParentsIconRender();
                    set(adjustment);

                    //History
                    this.HistoryPush(history);

                    this.Invalidate(InvalidateMode.HD);//Invalidate
                }
            }
        }
Beispiel #10
0
        public void MethodSelectedAdd(Layerage selectedLayerage)
        {
            ILayer selectedLayer = selectedLayerage.Self;

            // History
            LayersPropertyHistory history = new LayersPropertyHistory(HistoryType.LayersProperty_SetIsSelected);

            if (selectedLayer.IsSelected == false)
            {
                // History
                var previous = selectedLayer.IsSelected;
                history.UndoAction += () =>
                {
                    selectedLayer.IsSelected = previous;
                };

                selectedLayer.IsSelected = true;
            }

            // History
            this.HistoryPush(history);

            this.SetMode();    // Selection
            LayerManager.ArrangeLayersBackground();
            this.Invalidate(); // Invalidate
        }
        private void AddComplete(Vector2 canvasPoint)
        {
            ILayer   layer    = this.CurveLayer;
            Layerage layerage = this.CurveLayerage;

            // Snap
            if (this.IsSnap)
            {
                canvasPoint = this.Snap.Snap(canvasPoint);
                this.Snap.Default();
            }


            // History
            LayersPropertyHistory history = new LayersPropertyHistory(HistoryType.LayersProperty_Set_AddNode);

            // History
            var previous = layer.Nodes.NodesClone().ToList();

            history.UndoAction += () =>
            {
                // Refactoring
                layer.IsRefactoringTransformer = true;
                layer.IsRefactoringRender      = true;
                layer.IsRefactoringIconRender  = true;
                layer.Nodes.NodesReplace(previous);
            };

            // History
            this.ViewModel.HistoryPush(history);



            Node node = new Node
            {
                Point             = canvasPoint,
                LeftControlPoint  = canvasPoint,
                RightControlPoint = canvasPoint,
                IsChecked         = false,
                IsSmooth          = false,
            };

            layer.Nodes.PenAdd(node);


            // Refactoring
            layer.IsRefactoringTransformer = true;
            layer.IsRefactoringRender      = true;
            layer.IsRefactoringIconRender  = true;
            layerage.RefactoringParentsTransformer();
            layerage.RefactoringParentsRender();
            layerage.RefactoringParentsIconRender();

            // Cursor
            CoreCursorExtension.IsManipulationStarted = false;
            CoreCursorExtension.Cross();

            this.ViewModel.Invalidate(InvalidateMode.HD); // Invalidate
        }
Beispiel #12
0
        /// <summary>
        /// Reset the <see cref="IAdjustmentPage"/>'s data.
        /// </summary>
        public void Reset()
        {
            this.SourceColor      = Colors.White;
            this.DestinationColor = Colors.Transparent;

            if (this.SelectionViewModel.SelectionLayerage is Layerage layerage)
            {
                ILayer layer = layerage.Self;

                if (layer.Filter.Adjustments[this.Index] is ColorMatchAdjustment adjustment)
                {
                    // History
                    LayersPropertyHistory history = new LayersPropertyHistory(HistoryType.LayersProperty_ResetAdjustment_ColorMatch);

                    var previous  = layer.Filter.Adjustments.IndexOf(adjustment);
                    var previous1 = adjustment.SourceColor;
                    var previous2 = adjustment.DestinationColor;
                    history.UndoAction += () =>
                    {
                        if (previous < 0)
                        {
                            return;
                        }
                        if (previous > layer.Filter.Adjustments.Count - 1)
                        {
                            return;
                        }
                        if (layer.Filter.Adjustments[previous] is ColorMatchAdjustment adjustment2)
                        {
                            // Refactoring
                            layer.IsRefactoringRender     = true;
                            layer.IsRefactoringIconRender = true;
                            adjustment2.SourceColor       = previous1;
                            adjustment2.DestinationColor  = previous2;
                        }
                    };

                    // Refactoring
                    layer.IsRefactoringRender     = true;
                    layer.IsRefactoringIconRender = true;
                    layerage.RefactoringParentsRender();
                    layerage.RefactoringParentsIconRender();
                    adjustment.SourceColor      = Colors.White;
                    adjustment.DestinationColor = Colors.Transparent;

                    // History
                    this.ViewModel.HistoryPush(history);

                    this.ViewModel.Invalidate(); // Invalidate
                }
            }
        }
        private void LayerVisibilityChanged(ILayer layer2)
        {
            Visibility visibility = (layer2.Visibility == Visibility.Visible) ? Visibility.Collapsed : Visibility.Visible;

            if (layer2.IsSelected)
            {
                this.SelectionViewModel.Visibility = visibility;

                this.MethodViewModel.ILayerChanged <Visibility>
                (
                    set: (layer) => layer.Visibility = visibility,

                    type: HistoryType.LayersProperty_SetVisibility,
                    getUndo: (layer) => layer.Visibility,
                    setUndo: (layer, previous) => layer.Visibility = previous
                );
            }
            else
            {
                // History
                LayersPropertyHistory history = new LayersPropertyHistory(HistoryType.LayersProperty_SetVisibility);

                // Selection
                ILayer layer = layer2;

                var previous = layer.Visibility;
                history.UndoAction += () =>
                {
                    // Refactoring
                    layer.IsRefactoringRender     = true;
                    layer.IsRefactoringIconRender = true;
                    layer.Visibility = previous;
                };

                // Refactoring
                layer.IsRefactoringRender     = true;
                layer.IsRefactoringIconRender = true;
                //layerage.RefactoringParentsRender();
                //layerage.RefactoringParentsIconRender();
                layer.Visibility = visibility;

                // History
                this.ViewModel.HistoryPush(history);

                this.ViewModel.Invalidate(); // Invalidate
            }
        }
Beispiel #14
0
        public void MethodSelectedNew(Layerage selectedLayerage)
        {
            ILayer selectedLayer = selectedLayerage.Self;

            // History
            LayersPropertyHistory history = new LayersPropertyHistory(HistoryType.LayersProperty_SetIsSelected);

            if (selectedLayer.IsSelected == false)
            {
                var previous = selectedLayer.IsSelected;
                history.UndoAction += () =>
                {
                    selectedLayer.IsSelected = previous;
                };

                selectedLayer.IsSelected = true;
            }

            // Selection
            this.SetValue((layerage) =>
            {
                ILayer layer = layerage.Self;

                if (layer != selectedLayer)
                {
                    if (layer.IsSelected == true)
                    {
                        // History
                        var previous        = layer.IsSelected;
                        history.UndoAction += () =>
                        {
                            layer.IsSelected = previous;
                        };

                        layer.IsSelected = false;
                    }
                }
            });

            // History
            this.HistoryPush(history);

            this.SetModeSingle(selectedLayerage); // Selection
            LayerManager.ArrangeLayersBackground();
            this.Invalidate();                    // Invalidate
        }
        public void TLayerChangeCompleted <T, TLayer>
        (
            LayerType layerType,
            Action <TLayer> set,

            string historyTitle,
            Func <TLayer, T> getHistory,
            Action <TLayer, T> setHistory
        )
            where TLayer : ILayer
        {
            //History
            LayersPropertyHistory history = new LayersPropertyHistory(historyTitle);

            //Selection
            this.SetValue((layerage) =>
            {
                ILayer layer = layerage.Self;

                if (layer.Type == layerType)
                {
                    TLayer tLayer = (TLayer)layer;

                    var previous        = getHistory(tLayer);
                    history.UndoAction += () =>
                    {
                        //Refactoring
                        layer.IsRefactoringRender     = true;
                        layer.IsRefactoringIconRender = true;
                        setHistory(tLayer, previous);
                    };

                    //Refactoring
                    layer.IsRefactoringRender     = true;
                    layer.IsRefactoringIconRender = true;
                    layerage.RefactoringParentsRender();
                    layerage.RefactoringParentsIconRender();
                    set(tLayer);
                }
            });

            //History
            this.HistoryPush(history);

            this.Invalidate();//Invalidate
        }
Beispiel #16
0
        private void MoveComplete(Vector2 canvasStartingPoint, Vector2 canvasPoint)
        {
            //Snap
            if (this.IsSnap)
            {
                canvasPoint = this.Snap.Snap(canvasPoint);
                this.Snap.Default();
            }
            Vector2 canvasMove = canvasPoint - canvasStartingPoint;

            //History
            LayersPropertyHistory history = new LayersPropertyHistory("Move nodes");

            //Selection
            this.SelectionViewModel.SetValue((layerage) =>
            {
                ILayer layer = layerage.Self;

                if (layer.Type == LayerType.Curve)
                {
                    //History
                    var previous        = layer.Nodes.NodesStartingClone().ToList();
                    history.UndoAction += () =>
                    {
                        //Refactoring
                        layer.IsRefactoringTransformer = true;
                        layer.IsRefactoringRender      = true;
                        layer.IsRefactoringIconRender  = true;
                        layer.Nodes.NodesReplace(previous);
                    };

                    //Refactoring
                    layer.IsRefactoringTransformer = true;
                    layer.IsRefactoringRender      = true;
                    layer.IsRefactoringIconRender  = true;
                    layerage.RefactoringParentsTransformer();
                    layerage.RefactoringParentsRender();
                    layerage.RefactoringParentsIconRender();
                    layer.Nodes.TransformAddOnlySelected(canvasMove);
                }
            });

            //History
            this.ViewModel.HistoryPush(history);
        }
        public void MethodFillColorChangeCompleted(Color value)
        {
            // History
            LayersPropertyHistory history = new LayersPropertyHistory(HistoryType.LayersProperty_SetStyle_Fill);

            // Selection
            switch (this.FillOrStroke)
            {
            case FillOrStroke.Fill:
                this.Color = value;
                break;
            }

            this.Fill = BrushBase.ColorBrush(value);
            this.SetValueWithChildrenOnlyGroup((layerage) =>
            {
                ILayer layer = layerage.Self;

                // History
                var previous        = layer.Style.StartingFill.Clone();
                history.UndoAction += () =>
                {
                    // Refactoring
                    layer.IsRefactoringRender     = true;
                    layer.IsRefactoringIconRender = true;
                    layer.Style.Fill = previous.Clone();
                };

                // Refactoring
                layer.IsRefactoringRender     = true;
                layer.IsRefactoringIconRender = true;
                layerage.RefactoringParentsRender();
                layerage.RefactoringParentsIconRender();
                layer.Style.Fill = BrushBase.ColorBrush(value);

                this.StandardStyleLayerage = layerage;
            });

            // History
            this.HistoryPush(history);

            this.Invalidate(InvalidateMode.HD); // Invalidate
        }
Beispiel #18
0
        private void MoveSingleNodePointComplete(Vector2 canvasPoint)
        {
            ILayer layer = this.Layerage.Self;

            if (layer.Type == LayerType.Curve)
            {
                Node node = layer.Nodes.SelectedItem;

                //Snap
                if (this.IsSnap)
                {
                    canvasPoint = this.Snap.Snap(canvasPoint);
                    this.Snap.Default();
                }

                //History
                LayersPropertyHistory history = new LayersPropertyHistory("Move node");

                var previous  = layer.Nodes.Index;
                var previous1 = node.Clone();
                history.UndoAction += () =>
                {
                    //Refactoring
                    layer.IsRefactoringTransformer = true;
                    layer.IsRefactoringRender      = true;
                    layer.IsRefactoringIconRender  = true;
                    layer.Nodes[previous]          = previous1;
                };

                //Refactoring
                layer.IsRefactoringTransformer = true;
                layer.IsRefactoringRender      = true;
                layer.IsRefactoringIconRender  = true;
                this.Layerage.RefactoringParentsTransformer();
                this.Layerage.RefactoringParentsRender();
                this.Layerage.RefactoringParentsIconRender();
                Node.Move(canvasPoint, node);

                //History
                this.ViewModel.HistoryPush(history);
            }
        }
        /// <summary>
        /// Change T type for ITextLayer, save history, invalidate canvas.
        /// </summary>
        /// <typeparam name="T"> The T type property. </typeparam>
        /// <param name="set"> The sets of T. </param>
        /// <param name="historyTitle"> The history title. </param>
        /// <param name="getHistory"> The gets of history T. </param>
        /// <param name="setHistory"> The sets of history T. </param>
        public void ITextLayerChanged <T>
        (
            Action <ITextLayer> set,
            string historyTitle, Func <ITextLayer, T> getHistory, Action <ITextLayer, T> setHistory
        )
        {
            //History
            LayersPropertyHistory history = new LayersPropertyHistory(historyTitle);

            //Selection
            this.SetValue((layerage) =>
            {
                ILayer layer = layerage.Self;

                if (layer.Type.IsText())
                {
                    ITextLayer textLayer = (ITextLayer)layer;

                    var previous        = getHistory(textLayer);
                    history.UndoAction += () =>
                    {
                        //Refactoring
                        layer.IsRefactoringRender     = true;
                        layer.IsRefactoringIconRender = true;
                        setHistory(textLayer, previous);
                    };

                    //Refactoring
                    layer.IsRefactoringRender     = true;
                    layer.IsRefactoringIconRender = true;
                    layerage.RefactoringParentsRender();
                    layerage.RefactoringParentsIconRender();
                    set(textLayer);
                }
            });

            //History
            this.HistoryPush(history);

            this.Invalidate();//Invalidate
        }
        public void StyleChangeCompleted <T>
        (
            Action <IStyle> set,

            string historyTitle,
            Func <IStyle, T> getHistory,
            Action <IStyle, T> setHistory
        )
        {
            //History
            LayersPropertyHistory history = new LayersPropertyHistory(historyTitle);

            //Selection
            this.SetValueWithChildrenOnlyGroup((layerage) =>
            {
                ILayer layer = layerage.Self;

                var previous        = getHistory(layer.Style);
                history.UndoAction += () =>
                {
                    //Refactoring
                    layer.IsRefactoringRender     = true;
                    layer.IsRefactoringIconRender = true;
                    setHistory(layer.Style, previous);
                };

                //Refactoring
                layer.IsRefactoringRender     = true;
                layer.IsRefactoringIconRender = true;
                layerage.RefactoringParentsRender();
                layerage.RefactoringParentsIconRender();
                set(layer.Style);
                this.StandStyleLayer = layer;
            });

            //History
            this.HistoryPush(history);

            this.Invalidate();//Invalidate
        }
        public void EffectChangeCompleted <T>
        (
            Action <Effect> set,

            string historyTitle,
            Func <Effect, T> getHistory,
            Action <Effect, T> setHistory
        )
        {
            //History
            LayersPropertyHistory history = new LayersPropertyHistory(historyTitle);

            //Selection
            this.SetValue((layerage) =>
            {
                ILayer layer = layerage.Self;

                var previous        = getHistory(layer.Effect);
                history.UndoAction += () =>
                {
                    //Refactoring
                    layer.IsRefactoringRender     = true;
                    layer.IsRefactoringIconRender = true;
                    setHistory(layer.Effect, previous);
                };

                //Refactoring
                layer.IsRefactoringRender     = true;
                layer.IsRefactoringIconRender = true;
                layerage.RefactoringParentsRender();
                layerage.RefactoringParentsIconRender();
                set(layer.Effect);
            });

            //History
            this.HistoryPush(history);

            this.Invalidate();//Invalidate
        }
        private void CropStarted(ILayer firstLayer)
        {
            firstLayer.Transform.CropTransformer = firstLayer.Transform.Transformer;

            // History
            LayersPropertyHistory history = new LayersPropertyHistory(HistoryType.LayersProperty_SetTransform_IsCrop);

            // History
            var previous = firstLayer.Transform.IsCrop;

            history.UndoAction += () =>
            {
                ILayer firstLayer2 = firstLayer;

                firstLayer2.Transform.IsCrop = previous;
            };

            // History
            this.ViewModel.HistoryPush(history);

            firstLayer.Transform.IsCrop = true;
        }
Beispiel #23
0
        private void MoveSingleNodeControlPointComplete(Vector2 canvasPoint, bool isLeftControlPoint)
        {
            ILayer layer = this.Layerage.Self;

            if (layer.Type == LayerType.Curve)
            {
                Node node = layer.Nodes.SelectedItem;

                //History
                LayersPropertyHistory history = new LayersPropertyHistory("Move node control point");

                var previous  = layer.Nodes.Index;
                var previous1 = node.StartingLeftControlPoint;
                var previous2 = node.StartingRightControlPoint;
                history.UndoAction += () =>
                {
                    Node node2 = layer.Nodes[previous];

                    //Refactoring
                    layer.IsRefactoringTransformer = true;
                    layer.IsRefactoringRender      = true;
                    layer.IsRefactoringIconRender  = true;
                    node2.LeftControlPoint         = previous1;
                    node2.RightControlPoint        = previous2;
                };

                //Refactoring
                layer.IsRefactoringTransformer = true;
                layer.IsRefactoringRender      = true;
                layer.IsRefactoringIconRender  = true;
                this.Layerage.RefactoringParentsTransformer();
                this.Layerage.RefactoringParentsRender();
                this.Layerage.RefactoringParentsIconRender();
                Node.Controller(this.NodePage.PenFlyout.ControlPointMode, this.NodePage.PenFlyout.ControlLengthMode, this.NodePage.PenFlyout.ControlAngleMode, canvasPoint, node, isLeftControlPoint);

                //History
                this.ViewModel.HistoryPush(history);
            }
        }
        public void MethodSelectedNot(Layerage selectedLayerage)
        {
            ILayer selectedLayer = selectedLayerage.Self;

            //History
            LayersPropertyHistory history = new LayersPropertyHistory("Set is selected");

            var previous = selectedLayer.IsSelected;

            history.UndoAction += () =>
            {
                selectedLayer.IsSelected = previous;
            };

            selectedLayer.IsSelected = !selectedLayer.IsSelected;

            //History
            this.HistoryPush(history);

            this.SetMode(this.LayerageCollection);//Selection
            //LayerageCollection.ArrangeLayersBackgroundItemClick(selectedLayerage);
            LayerageCollection.ArrangeLayersBackground(this.LayerageCollection);
            this.Invalidate();//Invalidate
        }
        private void ConstructLayerageCollection()
        {
            if (LayerageCollection.ItemClick == null)
            {
                LayerageCollection.ItemClick += (layer) =>
                {
                    Layerage layerage = this.ViewModel.LayerageCollection.FindFirstLayerage(layer);

                    this.ItemClick(layerage);
                };
            }
            if (LayerageCollection.RightTapped == null)
            {
                LayerageCollection.RightTapped += (layer) =>
                {
                    Layerage layerage = this.ViewModel.LayerageCollection.FindFirstLayerage(layer);

                    this.ShowLayerMenu(layerage);
                };
            }

            if (LayerageCollection.VisibilityChanged == null)
            {
                LayerageCollection.VisibilityChanged += (layer2) =>
                {
                    Visibility visibility = (layer2.Visibility == Visibility.Visible) ? Visibility.Collapsed : Visibility.Visible;

                    if (layer2.IsSelected)
                    {
                        this.SelectionViewModel.Visibility = visibility;

                        this.MethodViewModel.ILayerChanged <Visibility>
                        (
                            set: (layer) => layer.Visibility = visibility,

                            historyTitle: "Set visibility",
                            getHistory: (layer) => layer.Visibility,
                            setHistory: (layer, previous) => layer.Visibility = previous
                        );
                    }
                    else
                    {
                        //History
                        LayersPropertyHistory history = new LayersPropertyHistory("Set visibility");

                        //Selection
                        ILayer layer = layer2;

                        var previous = layer.Visibility;
                        history.UndoAction += () =>
                        {
                            //Refactoring
                            layer.IsRefactoringRender     = true;
                            layer.IsRefactoringIconRender = true;
                            layer.Visibility = previous;
                        };

                        //Refactoring
                        layer.IsRefactoringRender     = true;
                        layer.IsRefactoringIconRender = true;
                        //layerage.RefactoringParentsRender();
                        //layerage.RefactoringParentsIconRender();
                        layer.Visibility = visibility;

                        //History
                        this.ViewModel.HistoryPush(history);

                        this.ViewModel.Invalidate();//Invalidate
                    }
                };
            }
            if (LayerageCollection.IsExpandChanged == null)
            {
                LayerageCollection.IsExpandChanged += (layer) =>
                {
                    layer.IsExpand = !layer.IsExpand;

                    Layerage layerage = this.ViewModel.LayerageCollection.FindFirstLayerage(layer);
                    LayerageCollection.ArrangeLayersVisibility(layerage);
                };
            }
            if (LayerageCollection.IsSelectedChanged == null)
            {
                LayerageCollection.IsSelectedChanged += (layer) =>
                {
                    Layerage layerage = this.ViewModel.LayerageCollection.FindFirstLayerage(layer);
                    this.MethodViewModel.MethodSelectedNot(layerage);//Method
                };
            }

            if (LayerageCollection.DragItemsStarted == null)
            {
                LayerageCollection.DragItemsStarted += (layer, manipulationMode) =>
                {
                    Layerage layerage = this.ViewModel.LayerageCollection.FindFirstLayerage(layer);

                    this.DragSourceLayerage = layerage;

                    if (manipulationMode == ManipulationModes.TranslateY)
                    {
                        this.DragLayerIsSelected = true;
                    }
                    else if (manipulationMode == ManipulationModes.System)
                    {
                        this.DragLayerIsSelected = false;
                    }
                };
            }
            if (LayerageCollection.DragItemsDelta == null)
            {
                LayerageCollection.DragItemsDelta += (layer, overlayMode) =>
                {
                    Layerage layerage = this.ViewModel.LayerageCollection.FindFirstLayerage(layer);

                    this.DragDestinationLayerage = layerage;
                    this.DragLayerOverlayMode    = overlayMode;
                };
            }
            if (LayerageCollection.DragItemsCompleted == null)
            {
                LayerageCollection.DragItemsCompleted += () =>
                {
                    //History
                    LayeragesArrangeHistory history = new LayeragesArrangeHistory("Layers arrange", this.ViewModel.LayerageCollection);
                    this.ViewModel.HistoryPush(history);

                    LayerageCollection.DragComplete(this.ViewModel.LayerageCollection, this.DragDestinationLayerage, this.DragSourceLayerage, this.DragLayerOverlayMode, this.DragLayerIsSelected);

                    this.SelectionViewModel.SetMode(this.ViewModel.LayerageCollection);//Selection
                    LayerageCollection.ArrangeLayers(this.ViewModel.LayerageCollection);
                    LayerageCollection.ArrangeLayersBackground(this.ViewModel.LayerageCollection);
                    this.ViewModel.Invalidate();//Invalidate

                    this.DragSourceLayerage      = null;
                    this.DragDestinationLayerage = null;
                    this.DragLayerIsSelected     = false;
                    this.DragLayerOverlayMode    = OverlayMode.None;
                };
            }
        }