private void Form_construct_FormClosing(object sender, FormClosingEventArgs e) { DialogResult result = MessageBox.Show("Do you want to leave without saving?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { return; } else if (result == DialogResult.No) { SaveFileDialog save = new SaveFileDialog(); save.Filter = "map files (*.map)|*.map"; if (save.ShowDialog() == DialogResult.OK) { Map.WriteMap(map, save.FileName); } else // Cancle { e.Cancel = true; } } else // Cancel { e.Cancel = true; } }
private void 儲存SToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog save = new SaveFileDialog(); save.Filter = "map files (*.map)|*.map"; if (save.ShowDialog() == DialogResult.OK) { Map.WriteMap(map, save.FileName); } }
private void button_stage1_Click(object sender, EventArgs e) { Object[,] map = Map.ReadMap(Environment.CurrentDirectory + @"\..\..\stage\stage1"); if (!player2) { Form_game form_game = new Form_game(this, map); form_game.Show(); } else { Form_game_2player form_game = new Form_game_2player(this, map); form_game.Show(); } this.Hide(); }
private void 開啟OToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); if (open.ShowDialog() == DialogResult.OK) { try { map = Map.ReadMap(open.FileName); } catch (Exception ex) { MessageBox.Show(ex.Message); } setMap(); } }