예제 #1
0
        public PictureLayout CopyLayout(int index)
        {
            watched = false;
            PictureLayout pictureLayout    = Layouts[index];
            PictureLayout newPictureLayout = null;

            if (pictureLayout is StandardLayout standardLayout)
            {
                newPictureLayout = new StandardLayout(standardLayout)
                {
                    Name = string.Format("{0} 复制", standardLayout.Name)
                };
            }
            else if (pictureLayout is PureLayout pureLayout)
            {
                newPictureLayout = new PureLayout(pureLayout)
                {
                    Name = string.Format("{0} 复制", pureLayout.Name)
                };
            }
            Layouts.Insert(index, newPictureLayout);
            watched = true;
            UndoManager.AddUndoData(new CMD_DeleteLayout(newPictureLayout, this, index));
            return(newPictureLayout);
        }
예제 #2
0
 private void Layouts_Changed(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     if (!watched)
     {
         return;
     }
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         UndoManager.AddUndoData(new CMD_MoveLayout(this, e.NewStartingIndex, movePreviousIndex));
         DirectCanvas.UI.Controller.AppController.CurrentController.CanvasReRender();
     }
     else if (e.Action == NotifyCollectionChangedAction.Remove)
     {
         movePreviousIndex = e.OldStartingIndex;
     }
 }
예제 #3
0
        public void DeleteLayout(int index)
        {
            PictureLayout pictureLayout = Layouts[index];

            watched = false;
            if (pictureLayout is StandardLayout standardLayout)
            {
                standardLayout.Deactivate();
            }
            if (PaintAgent.CurrentLayout == pictureLayout)
            {
                PaintAgent.CurrentLayout = null;
            }
            Layouts.RemoveAt(index);
            watched = true;
            UndoManager.AddUndoData(new CMD_RecoverLayout(pictureLayout, this, index));
        }
예제 #4
0
        public PureLayout NewPureLayout(int insertIndex, int RenderBufferNum)
        {
            PureLayout pureLayout = new PureLayout(DeviceResources)
            {
                BlendMode       = DefaultBlendMode,
                RenderBufferNum = RenderBufferNum,
                guid            = System.Guid.NewGuid(),
                Name            = string.Format("图层 {0}", Layouts.Count + 1)
            };

            watched = false;
            Layouts.Insert(insertIndex, pureLayout);
            watched = true;
            UndoManager.AddUndoData(new CMD_DeleteLayout(pureLayout, this, insertIndex));

            return(pureLayout);
        }
예제 #5
0
        public StandardLayout NewStandardLayout(int insertIndex, int RenderBufferNum)
        {
            StandardLayout standardLayout = new StandardLayout(DeviceResources)
            {
                PaintingTexture     = PaintingTexture,
                PaintingTextureTemp = PaintingTextureTemp,
                BlendMode           = DefaultBlendMode,
                RenderBufferNum     = RenderBufferNum,
                guid = System.Guid.NewGuid(),
                Name = string.Format("图层 {0}", Layouts.Count + 1)
            };

            watched = false;
            Layouts.Insert(insertIndex, standardLayout);
            watched = true;
            UndoManager.AddUndoData(new CMD_DeleteLayout(standardLayout, this, insertIndex));

            return(standardLayout);
        }
예제 #6
0
        public bool DrawEnd(Vector2 position, Windows.UI.Input.PointerPoint pointerPoint, out List <Vector2Int> _coveredTiles, out TileRect _tileRect)
        {
            _coveredTiles = null;
            _tileRect     = new TileRect();
            if (CurrentLayout == null || currentBrush == null)
            {
                return(false);
            }
            UpdateBrushData(position, pointerPoint);
            List <Vector2Int> tilesCovered = GetPaintingTiles(drawPrevPos, position, out TileRect coveredRect);

            if (tilesCovered.Count != 0)
            {
                ComputeBrush(currentBrush.cEnd, tilesCovered);
                _coveredTiles = tilesCovered;
                _tileRect     = coveredRect;
            }
            #region generateUndoData
            List <Vector2Int> paintCoveredTiles = new List <Vector2Int>();
            for (int i = 0; i < _mapForUndoCount; i++)
            {
                if (mapForUndo[i])
                {
                    paintCoveredTiles.Add(new Vector2Int()
                    {
                        x = (i % _mapForUndoStride) * 8, y = (i / _mapForUndoStride) * 8
                    });
                }
            }
            if (paintCoveredTiles.Count != 0)
            {
                UndoManager.AddUndoData(new Undo.CMD_TileReplace(CurrentLayout, new TiledTexture(PaintingTextureBackup, paintCoveredTiles), CanvasCase));
            }
            mapForUndo.SetAll(false);
            #endregion
            drawPrevPos = Vector2.Zero;
            PaintingTexture.CopyTo(PaintingTextureBackup);
            return(true);
        }