Ejemplo n.º 1
0
        private void Selection()
        {
            App.Model.isCanUndo = false;//关闭撤销

            Layer l = App.Model.Layers[App.Model.Index];

            //画布:输入源图、形状,输出带形状的源图
            CanvasRenderTarget crt = new CanvasRenderTarget(App.Model.VirtualControl, App.Model.Width, App.Model.Height);

            using (CanvasDrawingSession ds = crt.CreateDrawingSession())
            {
                ds.DrawImage(l.CanvasRenderTarget);
                CanvasComposite compositeMode = CanvasComposite.DestinationIn;//差模式
                ds.DrawImage(App.Model.MaskRenderTarget, 0, 0, l.CanvasRenderTarget.Bounds, 1, CanvasImageInterpolation.Linear, compositeMode);
            }

            //新建层
            Layer ll = new Layer {
                Visual = true, Opacity = l.Opacity, CanvasRenderTarget = crt, BlendIndex = l.BlendIndex
            };

            if (App.Model.isLowView)
            {
                ll.LowView();
            }
            else
            {
                ll.SquareView();
            }

            //Undo:撤销
            Undo undo = new Undo();

            undo.AddInstantiation(App.Model.Index);
            App.UndoAdd(undo);

            App.Model.Layers.Insert(App.Model.Index, ll);
            ll.SetWriteableBitmap(App.Model.VirtualControl); //刷新缩略图

            App.Model.isReRender = true;                     //重新渲染
            App.Model.Refresh++;                             //画布刷新
            App.Model.LayersCount = App.Model.Layers.Count;  //Undo:撤销

            App.Model.isCanUndo = true;                      //打开撤销
        }
Ejemplo n.º 2
0
        public static void Apply()
        {
            App.Model.isCanUndo = false;//关闭撤销

            var index = App.Model.Index;

            if (App.Model.Index < 0)
            {
                App.Model.Index = 0;                     //图层索引
            }
            //新建渲染目标=>层
            CanvasRenderTarget crt = new CanvasRenderTarget(App.Model.VirtualControl, App.Model.Width, App.Model.Height);

            using (CanvasDrawingSession ds = crt.CreateDrawingSession())
            {
                ds.FillGeometry(App.Model.SecondCanvasGeometry, App.Setting.TextX, App.Setting.TextY, App.Model.TextColor);
            }
            Layer l = new Layer {
                Visual = true, Opacity = 100, CanvasRenderTarget = crt,
            };

            if (App.Model.isLowView)
            {
                l.LowView();
            }
            else
            {
                l.SquareView();
            }
            l.SetWriteableBitmap(App.Model.VirtualControl);//刷新缩略图

            //Undo:撤销
            Undo undo = new Undo();

            undo.AddInstantiation(index);
            App.UndoAdd(undo);

            App.Model.Layers.Insert(index, l);
            App.Model.Index = index;

            App.Model.LayersCount = App.Model.Layers.Count; //更新图层数量以供判断集合撤销
            App.Model.isCanUndo   = true;                   //打开撤销
        }
Ejemplo n.º 3
0
        public static void Duplicate()
        {
            App.Model.isCanUndo = false;//关闭撤销

            Layer l = App.Model.Layers[App.Model.Index];

            //复制渲染目标
            CanvasRenderTarget crt = new CanvasRenderTarget(App.Model.VirtualControl, App.Model.Width, App.Model.Height);

            using (var ds = crt.CreateDrawingSession())
            {
                ds.DrawImage(l.CanvasRenderTarget);
            }
            Layer ll = new Layer {
                Visual = true, Opacity = l.Opacity, CanvasRenderTarget = crt, BlendIndex = l.BlendIndex,
            };

            if (App.Model.isLowView)
            {
                ll.LowView();
            }
            else
            {
                ll.SquareView();
            }

            //Undo:撤销
            Undo undo = new Undo();

            undo.AddInstantiation(App.Model.Index);
            App.UndoAdd(undo);

            App.Model.Layers.Insert(App.Model.Index, ll);
            ll.SetWriteableBitmap(App.Model.VirtualControl);//刷新缩略图


            App.Model.isReRender = true;                    //重新渲染
            App.Model.Refresh++;                            //画布刷新

            App.Model.LayersCount = App.Model.Layers.Count; //更新图层数量以供判断集合撤销
            App.Model.isCanUndo   = true;                   //打开撤销
        }
Ejemplo n.º 4
0
        public static void Apply()
        {
            App.Model.isCanUndo = false;//关闭撤销

            var index = App.Model.Index;

            //新建渲染目标=>层
            CanvasRenderTarget crt = new CanvasRenderTarget(App.Model.VirtualControl, App.Model.Width, App.Model.Height);

            using (CanvasDrawingSession ds = crt.CreateDrawingSession())
            {
                ds.DrawImage(App.Model.SecondCanvasImage);
            }
            Layer l = new Layer {
                Visual = true, Opacity = 100, CanvasRenderTarget = crt,
            };

            if (App.Model.isLowView)
            {
                l.LowView();
            }
            else
            {
                l.SquareView();
            }
            l.SetWriteableBitmap(App.Model.VirtualControl);//刷新缩略图

            //Undo:撤销
            Undo undo = new Undo();

            undo.AddInstantiation(index);
            App.UndoAdd(undo);

            App.Model.Layers.Insert(index, l);
            App.Model.Index = index;

            App.Model.isCanUndo = true;//打开撤销
        }
Ejemplo n.º 5
0
        public static void Blank()
        {
            App.Model.isCanUndo = false;//关闭撤销
            int index = App.Model.Index;

            //新建渲染目标=>层
            CanvasRenderTarget crt = new CanvasRenderTarget(App.Model.VirtualControl, App.Model.Width, App.Model.Height);
            Layer l = new Layer {
                Visual = true, Opacity = 100, CanvasRenderTarget = crt,
            };

            if (App.Model.isLowView)
            {
                l.LowView();
            }
            else
            {
                l.SquareView();
            }

            //Undo:撤销
            Undo undo = new Undo();

            undo.AddInstantiation(App.Model.Index);
            App.UndoAdd(undo);

            App.Model.Layers.Insert(App.Model.Index, l);
            l.SetWriteableBitmap(App.Model.VirtualControl);//刷新缩略图
            App.Model.Index = index + 1;

            App.Model.isReRender = true;                    //重新渲染
            App.Model.Refresh++;                            //画布刷新

            App.Model.LayersCount = App.Model.Layers.Count; //更新图层数量以供判断集合撤销
            App.Model.isCanUndo   = true;                   //打开撤销
        }