/// <summary> /// Event handler for double-clicking a tile in the tile palette. /// This brings up a properties editor dialog for the tile. /// </summary> void EditTileClicked(object sender, EventArgs e) { int index = tileListView.SelectedIndices[0]; TileContent tileContent = tilePalette[index]; // Create a new TileDialog TileDialog td = new TileDialog(this, tileImagePath, tileContent); // Set the TileDialog's Tile to the selected tile td.Tile = mapViewerControl.Tilemap.TilePalette[index]; if (td.ShowDialog() == DialogResult.OK) { // Swap the tile's name in the tileListView tileListView.Items[index].Text = td.Tile.Name; // Swap the tile's image in the tileImageList tileImageList.Images[index] = Bitmap.FromFile(td.FileName); // Swap the tile in the tilemap's tile palette tilemap.TilePalette[index] = td.Tile; // Swap the tile in the MainForm's tile palette tilePalette[index] = new TileContent(td.FileName) { Name = td.Tile.Name, TileType = td.Tile.TileType }; } }
/// <summary> /// Event handler for new tile menu item click. This brings /// up a tile properties dialog where the user can create a /// new tile /// </summary> void NewTileClicked(Object sender, EventArgs e) { TileDialog td = new TileDialog(this, tileImagePath); if (td.ShowDialog() == DialogResult.OK) { // Add the new tile to the tileListView, and assign it a new image tileListView.Items.Add(td.Tile.Name, tileImageList.Images.Count); // Add the new tile image to the image list tileImageList.Images.Add(Bitmap.FromFile(td.FileName)); // Add the new tile to the tilemap's tile palette tilemap.TilePalette.Add(td.Tile); // Also add it to the mainform's tile palette tilePalette.Add(new TileContent(td.FileName) { Name = td.Tile.Name, TileType = td.Tile.TileType }); // Auto-select the new tile mapViewerControl.SelectedTileIndex = tileListView.Items.Count - 1; tileListView.SelectedIndices.Clear(); tileListView.SelectedIndices.Add(tileListView.Items.Count - 1); } }