예제 #1
0
        private void Undo()
        {
            if (App.Model.UndoIndex + 1 == App.Model.Undos.Count)//如果是第一次撤销
            {
                //根据最后的一个撤销的类型,保留当前的状态为新的撤销类
                Undo undo = new Undo();
                switch (App.Model.Undos.Last().undeoType)
                {
                case UndeoType.Targe:
                    undo.TargeInstantiation(App.Model.Index, App.Model.CurrentRenderTarget);
                    break;

                case UndeoType.Mask:
                    undo.MaskInstantiation(App.Model.MaskRenderTarget, App.Model.MaskAnimatedTarget);
                    break;

                case UndeoType.Index:
                    undo.IndexInstantiation(App.Model.Index);
                    break;

                case UndeoType.Collection:
                    undo.CollectionInstantiation(App.Model.Index, App.Model.Layers);
                    break;
                //case UndeoTyte.LayerAdd :break;
                //case UndeoTyte.LayerRemove :break;

                case UndeoType.Visual:
                    undo.VisualInstantiation(App.Model.Index, App.Model.Layers[App.Model.Index].Visual);
                    break;

                case UndeoType.Opacity:
                    undo.OpacityInstantiation(App.Model.Index, App.Model.Layers[App.Model.Index].Opacity);
                    break;

                case UndeoType.Blend:
                    undo.BlendInstantiation(App.Model.Index, App.Model.Layers[App.Model.Index].BlendIndex);
                    break;

                case UndeoType.Tool:
                    undo.ToolInstantiation(App.Model.Tool);
                    break;

                default: break;
                }
                App.Model.Undos.Add(undo);
            }

            if (App.Model.Undos.Count > 2 && App.Model.UndoIndex >= 0)
            {
                App.Model.Undos[App.Model.UndoIndex].Perform(); //后退
                App.Model.UndoIndex--;                          //撤销索引后退一步

                App.Model.isRedo = true;                        //重做可用
            }
            else
            {
                App.Model.isUndo = false; //撤销不可用
            }
        }