private void saveToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments); saveFileDialog1.Filter = "Map file (*.map)|*.map|All files (*.*)|*.*"; saveFileDialog1.FilterIndex = 1; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { try { Console.WriteLine("Saving map file to: " + saveFileDialog1.FileName); MapWriter.save(map, saveFileDialog1.FileName); Console.WriteLine("Saving finished"); } catch (IOException err) { Console.WriteLine("Saving file failed: " + err.Message); } } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments); openFileDialog1.Filter = "Map file (*.map)|*.map|All files (*.*)|*.*"; openFileDialog1.FilterIndex = 1; if (openFileDialog1.ShowDialog() == DialogResult.OK) { try { Console.WriteLine("Loading map file from: " + openFileDialog1.FileName); this.map = MapWriter.load(openFileDialog1.FileName); this.m_mapPanel.setMap(map); Console.WriteLine("Loading finished"); } catch (IOException err) { Console.WriteLine("Loading file failed: " + err.Message); } } }