Beispiel #1
0
        /// <summary>
        /// Flips the brush tiles
        /// </summary>
        /// <param name="direction">The direction to flip the tile array</param>
        public void Flip(FlipDirectionType direction)
        {
            // Get array dimensions
            int width  = _tiles.GetLength(0);
            int height = _tiles.GetLength(1);

            // Create new tile array
            GMareTile[,] tiles = new GMareTile[width, height];

            // Do action based on direction
            switch (direction)
            {
            // Flip horizontally
            case FlipDirectionType.Horizontal:
                for (int x = 0; x < width; x++)
                {
                    for (int y = 0; y < height; y++)
                    {
                        tiles[x, y]          = _tiles[(width - 1) - x, y].Clone();
                        tiles[x, y].FlipMode = tiles[x, y].FlipMode;
                        tiles[x, y].Flip(FlipDirectionType.Horizontal);
                    }
                }

                break;

            // Flip vertically
            case FlipDirectionType.Vertical:
                for (int x = 0; x < width; x++)
                {
                    for (int y = 0; y < height; y++)
                    {
                        tiles[x, y]          = _tiles[x, (height - 1) - y].Clone();
                        tiles[x, y].FlipMode = tiles[x, y].FlipMode;
                        tiles[x, y].Flip(FlipDirectionType.Vertical);
                    }
                }

                break;
            }

            // Dereference old tiles
            _tiles = null;

            // Reference new one
            _tiles = tiles;
        }
Beispiel #2
0
        /// <summary>
        /// Flips brushes or selections
        /// </summary>
        public void Flip(FlipDirectionType direction)
        {
            // If the room is empty, return
            if (App.Room == null)
            {
                return;
            }

            // If not editing the layers, return
            if (EditMode == EditType.Layers)
            {
                // Do action based on key
                switch (ToolMode)
                {
                case ToolType.Brush:
                    // Do action based on key data
                    switch (direction)
                    {
                    case FlipDirectionType.Horizontal: pnlRoom.mnuBrushFlipHorizontally_Click(this, EventArgs.Empty); Invalidate(); break;

                    case FlipDirectionType.Vertical: pnlRoom.mnuBrushFlipVertically_Click(this, EventArgs.Empty); Invalidate(); break;
                    }
                    break;

                case ToolType.Bucket:
                    // Do action based on key data
                    switch (direction)
                    {
                    case FlipDirectionType.Horizontal: pnlRoom.mnuBrushFlipHorizontally_Click(this, EventArgs.Empty); Invalidate(); break;

                    case FlipDirectionType.Vertical: pnlRoom.mnuBrushFlipVertically_Click(this, EventArgs.Empty); Invalidate(); break;
                    }
                    break;

                case ToolType.Selection:
                    // Do action based on key data
                    switch (direction)
                    {
                    case FlipDirectionType.Horizontal: pnlRoom.mnuSelectionFlipX_Click(this, EventArgs.Empty); Invalidate(); break;

                    case FlipDirectionType.Vertical: pnlRoom.mnuSelectionFlipY_Click(this, EventArgs.Empty); Invalidate(); break;
                    }
                    break;
                }
            }
        }