Private Sub GroupSelectedTiles() ' Check if any of the selected tiles are animated For…
- User
Private Sub GroupSelectedTiles() ' Check if any of the selected tiles are animated For Each tile In selectedTiles If tile.IsAnimated Then MessageBox.Show("Animated tiles cannot be grouped.", "Grouping Not Allowed", MessageBoxButtons.OK, MessageBoxIcon.Information) Return End If Next
' Get the bounds of the selected tiles Dim bounds As Rectangle = GetSelectedTilesBounds() ' Create a new bitmap for the merged image Dim mergedImage As New Bitmap(bounds.Width, bounds.Height, PixelFormat.Format32bppArgb) Using g As Graphics = Graphics.FromImage(mergedImage) g.InterpolationMode = InterpolationMode.NearestNeighbor g.PixelOffsetMode = PixelOffsetMode.Half g.SmoothingMode = SmoothingMode.None g.Clear(Color.Transparent) ' Declare and initialize selectedTilesInOrder Dim selectedTilesInOrder As New List(Of MapTile) ' Populate selectedTilesInOrder with the currently selected tiles For Each tile In selectedTiles selectedTilesInOrder.Add(tile) Next ' Draw each tile onto the merged image For Each tile In selectedTilesInOrder Dim offsetX As Integer = tile.Position.X - bounds.X Dim offsetY As Integer = tile.Position.Y - bounds.Y g.DrawImage(tile.Image, New Rectangle(offsetX, offsetY, tile.Size.Width, tile.Size.Height)) Next End Using ' Create a new grouped tile Dim newTile As New MapTile With { .Image = mergedImage, .Position = New Point(bounds.X, bounds.Y), .Size = mergedImage.Size, .Selected = True, .IsGrouped = True, .OriginalTiles = selectedTilesInOrder ' Store the original tiles for ungrouping } ' Remove the original tiles from the canvas _tiles.RemoveAll(Function(t) t.Selected) ' Add the new grouped tile to the canvas _tiles.Add(newTile) ' Clear the selected tiles list and select the new grouped tile selectedTiles.Clear() selectedTiles.Add(newTile) selectedTile = newTile ' Notify that the canvas has been modified RaiseEvent CanvasModified()End Sub
Severity Code Description Project Project Rank Path File Line Column Category Source Suppression State Tool Error (active) BC30451 'selectedTilesInOrder' is not declared. It may be inaccessible due to its protection level. Bizarria 1 D:\01 - Grags\Visual Studio\Bizarria New\Bizarria\Controls D:\01 - Grags\Visual Studio\Bizarria New\Bizarria\Controls\MapCanvas.vb 1491 30 Compiler IntelliSense
- Assistant