/// <summary>
        /// Clears the selected tile(s) bitmap(s), not the tile id
        /// </summary>
        private void mnuClear_Click(object sender, EventArgs e)
        {
            // If targets are empty, return
            if (_targets == null)
            {
                return;
            }

            // Panel changed
            PanelChanged();

            // Get tile ids
            int[] tiles = _targets.ToArray();

            // Iterate through tiles
            foreach (int tile in tiles)
            {
                // If the tile is empty, continue
                if (_tiles[tile] == null)
                {
                    continue;
                }

                // Create a blank dummy tile
                Bitmap image = new Bitmap(_tiles[tile].Width, _tiles[tile].Height);
                image.Tag = (int)_tiles[tile].Tag;

                // Clear the tile
                _tiles[tile].Dispose();
                _tiles[tile] = image;
            }

            // Reset selection values
            ResetSelection();

            // Update backbuffer
            UpdateBackBuffer();
        }
        /// <summary>
        /// Swaps tiles from the selection grid
        /// </summary>
        private void SwapTiles(bool ignoreUpdate)
        {
            // If the targets or swaps grids are empty, return
            if (_targets == null || _swaps == null)
            {
                return;
            }

            // Get tile arrays
            int[] targets = _targets.ToArray();
            int[] swaps   = _swaps.ToArray();

            // If the swaps are the same as the targets, return
            if (swaps[0] == targets[0])
            {
                return;
            }

            // Variables for correct swapping order
            int index  = 0;
            int amount = 1;
            int count  = targets.Length;

            // If the swap origin is less than the target origin
            if (swaps[0] < targets[0])
            {
                // Iterate backwards for the proper ordering
                amount = -1;
                count  = -1;
                index  = targets.Length - 1;
            }

            // If not ignoring the update and there are listeners, the panel changed
            if (!ignoreUpdate && PanelChanged != null)
            {
                PanelChanged();
            }

            // Iterate through tiles
            for (int i = index; i != count; i += amount)
            {
                // New bitmaps
                Bitmap target   = null;
                Bitmap swap     = null;
                int    targetId = targets[i];
                int    swapId   = swaps[i];

                // If the tile is not empty, copy it
                if (_tiles[swaps[i]] != null)
                {
                    swap     = (Bitmap)_tiles[swaps[i]].Clone();
                    swap.Tag = (int)_tiles[swaps[i]].Tag;
                    _tiles[swaps[i]].Dispose();
                }

                // If the tile is not empty, copy it
                if (_tiles[targets[i]] != null)
                {
                    target     = (Bitmap)_tiles[targets[i]].Clone();
                    target.Tag = (int)_tiles[targets[i]].Tag;
                    _tiles[targets[i]].Dispose();
                }

                // Swap tiles
                _tiles[targets[i]] = swap;
                _tiles[swaps[i]]   = target;
            }

            // Reset selection
            ResetSelection();

            // Redraw backbuffer
            if (!ignoreUpdate)
            {
                UpdateBackBuffer();
            }
        }