/* Exports the map to a png file named by the user. */ private void exportMenuBar_Click(object sender, EventArgs e) { if (exportFileDialog.ShowDialog() == DialogResult.OK) { MapIO.ExportMap(map, exportFileDialog.FileName); } }
// Method for saving a map with a new name. public void SaveAs() { // Prompt the user with a save file dialog box to get the path and file name for the map. if (saveFileDialog.ShowDialog() == DialogResult.OK) { map.SetMapName(saveFileDialog.FileName); MapIO.SaveMap(map); } }
/*************************************************************FILE HANDLING*/ /*************************************************************FILE HANDLING*/ /*************************************************************FILE HANDLING*/ // Regular "Save" method. public void SaveMap() { // Check if this map has a name, meaning it has been saved before. If it hasn't, promt the user to name it using the "SaveAs()" method. if (map.GetMapName() == null) { SaveAs(); } else { MapIO.SaveMap(map); } }
// Method for loading a saved map. private void openMenuBar_Click(object sender, EventArgs e) { // Open the file select diaglog box and check if the user selected "OK" if (selectMapDialog.ShowDialog() == DialogResult.OK) { try { map = MapIO.LoadMap(selectMapDialog.FileName); Refresh(); } catch (Exception ex) { MessageBox.Show("Could not load map: " + selectMapDialog.FileName); Console.WriteLine(ex.ToString()); } } }