/// <summary> /// Renames the <see cref="TileMap"/> object. /// </summary> public void RenameMap(int id) { var map = GetMap(id); if (map == null) return; using (var dialog = new DialogRename(map.Name)) { var result = dialog.ShowDialog(); if (result != DialogResult.OK) return; if (map.Name == dialog.NewName) return; if (CheckMap(dialog.NewName)) { MessageBox.Show(@"A map with this name already exists.", @"Rename Map"); return; } Console.WriteLine(@"Map {0} renamed to {1}.", map.Name, dialog.NewName); UpdateMap(id, dialog.NewName, map.Width, map.Height, map.TileWidth, map.TileHeight); } }
/// <summary> /// Renames the <see cref="Tileset"/> object. /// </summary> public void RenameTileset(int id) { var tileset = GetTileset(id); if (tileset == null) return; using (var dialog = new DialogRename(tileset.Name)) { var result = dialog.ShowDialog(); if (result != DialogResult.OK) return; if (tileset.Name != dialog.NewName) { if (CheckTileset(dialog.NewName)) { MessageBox.Show(@"A tileset with this name already exists.", @"Rename Tileset"); return; } } UpdateTileset(id, dialog.NewName, tileset.Image, tileset.TileWidth, tileset.TileHeight); } }
/// <summary> /// Renames the <see cref="Project"/> object. /// </summary> public void RenameProject() { if (Project == null) return; using (var dialog = new DialogRename(Project.Name)) { var result = dialog.ShowDialog(); if (result != DialogResult.OK) return; Console.WriteLine(@"Project {0} renamed to {1}", Project.Name, dialog.NewName); UpdateProject(dialog.NewName, Project.Author, Project.Description); } }
/// <summary> /// Renames the currently selected layer. /// </summary> public void RenameLayer() { using (var dialog = new DialogRename(SelectedLayer.Name)) { var result = dialog.ShowDialog(); if (result != DialogResult.OK) return; if (SelectedLayer.Name != dialog.NewName) { if (CheckLayer(dialog.NewName)) { MessageBox.Show(@"A layer with this name already exists.", @"Rename Layer"); return; } } using (UndoRedoArea.Start("Renamed Layer")) { var oldLayer = SelectedLayer.Clone(); SelectedLayer.Name = dialog.NewName; if (LayerChanged != null) LayerChanged.Invoke(this, new LayerChangedEventArgs(oldLayer, SelectedLayer)); UnsavedChanges = true; UndoRedoArea.Commit(); } } }
/// <summary> /// Renames the <see cref="TerrainTile"/> object. /// </summary> public void RenameTerrain(int id) { var terrain = GetTerrain(id); if (terrain == null) return; using (var dialog = new DialogRename(terrain.Name)) { var result = dialog.ShowDialog(); if (result != DialogResult.OK) return; if (terrain.Name.ToLower() != dialog.NewName.ToLower()) { if (CheckTerrain(dialog.NewName)) { MessageBox.Show(@"A terrain tile with this name already exists.", @"Rename Terrain"); return; } } UpdateTerrain(id, dialog.NewName, terrain.Type, terrain.Tileset, terrain.X, terrain.Y, terrain.Width, terrain.Height); } }