private void btnback_Click(object sender, EventArgs e) { DialogResult YesOrNo = new DialogResult(); YesOrNo = MessageBox.Show("Do you want to exit?", "Are you sure to exit?", MessageBoxButtons.YesNo); if (YesOrNo == DialogResult.Yes) { Story1Ans stans1 = new Story1Ans(); stans1.Show(); this.Close(); } }
private void SwitchPictureBox(object sender, EventArgs e) { pictureBox1.Visible = false; if (lblTimeElapsed.Text == "00:00:00") { timer.Start(); } int inPictureBoxIndex = PuzzleBox.Controls.IndexOf(sender as Control); if (NullIndex != inPictureBoxIndex) { List <int> mixs = new List <int>(new int[] { ((inPictureBoxIndex % 3 == 0) ? -1 : inPictureBoxIndex - 1), inPictureBoxIndex - 3, (inPictureBoxIndex % 3 == 2) ? -1 : inPictureBoxIndex + 1, inPictureBoxIndex + 3 }); if (mixs.Contains(NullIndex)) { ((PictureBox)PuzzleBox.Controls[NullIndex]).Image = ((PictureBox)PuzzleBox.Controls[inPictureBoxIndex]).Image; ((PictureBox)PuzzleBox.Controls[inPictureBoxIndex]).Image = PictureList[9]; NullIndex = inPictureBoxIndex; if (CheckWin()) { timer.Stop(); (PuzzleBox.Controls[8] as PictureBox).Image = PictureList[8]; MessageBox.Show("Congratulations...\nTime Elapsed : " + timer.Elapsed.ToString().Remove(8)); lblTimeElapsed.Text = "00:00:00"; timer.Reset(); Shuffle(); Story1Ans stans1 = new Story1Ans(); stans1.Owner = this; stans1.Show(this); this.Hide(); } } } }