private void CheckForWinner() { foreach (Control control in tableLayoutPanel1.Controls) { Label pictureLabel = control as Label; if (pictureLabel != null) { if (pictureLabel.ForeColor == pictureLabel.BackColor) { return; } } } DialogResult dialogResult = MessageBox.Show("Do you want play again ?", "You won in " + winnerTime + " seconds!!!!", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { howLong.Stop(); this.Hide(); SecondForm newForm = new SecondForm(); newForm.ShowDialog(); this.Close(); } else if (dialogResult == DialogResult.No) { this.Close(); } }
private void ChangeSize_Click(object sender, EventArgs e) { this.Hide(); SecondForm newForm = new SecondForm(); newForm.ShowDialog(); this.Close(); }
/// <summary> /// Picture Click event for game reset. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PictureReset_Click(object sender, EventArgs e) { this.Hide(); SecondForm form = new SecondForm(); form.ShowDialog(); this.Close(); }
/// <summary> /// Check every icon to see if it is matched, by /// comparing its foreground color to its background color. /// If all of the icons are matched, the player wins. /// </summary> private void CheckForWinner() { foreach (Control control in tableLayoutPanel1.Controls) { Label pictureLabel = control as Label; if (pictureLabel != null) { if (pictureLabel.ForeColor == pictureLabel.BackColor) { return; } } } /** * If the loop didn't return. It didin't find * any unmatched icons. * That means the user won.A dialog box will appear. */ DialogResult dialogResult = MessageBox.Show("Your time: " + winnerTime + " seconds\nYour click: " + clickCount.Text + "\nWrong pair:" + wrongPair + "\n\nDo you want play again ?", "You won !!! Congratulations !!!!", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { howLong.Stop(); this.Hide(); SecondForm newForm = new SecondForm(); newForm.ShowDialog(); this.Close(); } else if (dialogResult == DialogResult.No) { this.Close(); } }