Ejemplo n.º 1
0
        public static void Invert()
        {
            //Undo:撤销
            Undo undo = new Undo();

            undo.MaskInstantiation(App.Model.MaskRenderTarget, App.Model.MaskAnimatedTarget);
            App.UndoAdd(undo);

            CanvasCommandList vcl = new CanvasCommandList(App.Model.VirtualControl);

            using (var ds = vcl.CreateDrawingSession())
            {
                ds.Clear(Colors.White);
            }

            CanvasCommandList acl = new CanvasCommandList(App.Model.AnimatedControl);

            using (var ds = acl.CreateDrawingSession())
            {
                ds.Clear(Colors.White);
            }
            App.Mask(vcl, acl, 4);//反选


            //重新设置描边
            App.Model.isReStroke = true;
            App.Model.isAnimated = true;

            if (App.Model.isMask == true)
            {
                App.Model.isReRender = true; //重新渲染
                App.Model.Refresh++;         //画布刷新
            }
        }
Ejemplo n.º 2
0
        public static void Pixel()
        {
            //Undo:撤销
            Undo undo = new Undo();

            undo.MaskInstantiation(App.Model.MaskRenderTarget, App.Model.MaskAnimatedTarget);
            App.UndoAdd(undo);

            //复制
            CanvasRenderTarget crt = new CanvasRenderTarget(App.Model.AnimatedControl, App.Model.Width, App.Model.Height);

            crt.SetPixelBytes(App.Model.Layers[App.Model.Index].CanvasRenderTarget.GetPixelBytes());

            App.Mask(App.Model.Layers[App.Model.Index].CanvasRenderTarget, crt);

            //重新设置描边
            App.Model.isReStroke = true;
            App.Model.isAnimated = true;

            if (App.Model.isMask == true)
            {
                App.Model.isReRender = true; //重新渲染
                App.Model.Refresh++;         //画布刷新
            }
        }
Ejemplo n.º 3
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; //撤销不可用
            }
        }
Ejemplo n.º 4
0
        public static void Deselect()
        {
            //Undo:撤销
            Undo undo = new Undo();

            undo.MaskInstantiation(App.Model.MaskRenderTarget, App.Model.MaskAnimatedTarget);
            App.UndoAdd(undo);

            App.MaskClear();

            //重新设置描边
            App.Model.isReStroke = true;
            App.Model.isAnimated = true;

            if (App.Model.isMask == true)
            {
                App.Model.isReRender = true; //重新渲染
                App.Model.Refresh++;         //画布刷新
            }
        }
Ejemplo n.º 5
0
        public static void Apply()
        {
            //Undo:撤销
            Undo undo = new Undo();

            undo.MaskInstantiation(App.Model.MaskRenderTarget, App.Model.MaskAnimatedTarget);
            App.UndoAdd(undo);

            //画选区(临时征用底选区渲染目标)
            using (CanvasDrawingSession ds = App.Model.SecondBottomRenderTarget.CreateDrawingSession())
            {
                ds.Clear(Colors.Transparent);
                ds.DrawImage(App.Model.SecondCanvasImage);
            }

            //复制
            CanvasRenderTarget crt = new CanvasRenderTarget(App.Model.AnimatedControl, App.Model.Width, App.Model.Height);

            crt.SetPixelBytes(App.Model.SecondBottomRenderTarget.GetPixelBytes());

            App.Mask(App.Model.SecondBottomRenderTarget, crt);
        }