private void RestartGame() // The user selected to start a new game form the dropbox { this.gameTimer.Stop(); bool openingFormClosed1; GameSizeAndBombs newGame = new GameSizeAndBombs(); using (OpeningForm openingForm = new OpeningForm()) // Get the size and number of bombs of the game from the opening form { openingForm.Location = this.Location; if (openingForm.ShowDialog() == DialogResult.OK) { newGame.Size = openingForm.SelectedMode.Size; newGame.NumberOfBombs = openingForm.SelectedMode.NumberOfBombs; openingFormClosed1 = false; } else // The use didn not submit the opening form { openingFormClosed1 = true; this.gameTimer.Start(); } } if (openingFormClosed1) { return; } else { Form1 newForm = new Form1(newGame); newForm.Location = this.Location; newForm.Show(); this.Dispose(); } }
public Form1() // Create a new game (used for first game) { using (OpeningForm openingForm = new OpeningForm()) // Get the size and number of bombs of the game from the opening form { if (openingForm.ShowDialog() == DialogResult.OK) { this.size = openingForm.SelectedMode.Size; this.numberOfBombs = openingForm.SelectedMode.NumberOfBombs; this.openingFormClosed = false; } else { openingFormClosed = true; } } InitializeForm(); }