/*......................... okButton_Click - hide that form and open the home page .........................*/ private void okButton_Click(object sender, EventArgs e) { HomePage returnHome = new HomePage(); returnHome.Show(); this.Hide(); }
/*......................... button1_Click - That method is called when the return button is clicked. It close the current form and open the home page form .........................*/ private void button1_Click(object sender, EventArgs e) { timer.Stop(); HomePage newHomePage = new HomePage(); newHomePage.Show(); this.Hide(); }
/*......................... timer_Tick - that method is called when the form is oppened. It's purpose is to countdown 30 seconds before the game finieshed and * print the current highscore .........................*/ private void timer_Tick(object sender, EventArgs e) { if (timeLeft > 0) { // Display the new time left // by updating the Time Left label. timeLeft = timeLeft - 1; lblTime.Text = timeLeft + " seconds"; } else { // If the user ran out of time, stop the timer, show // a MessageBox, and fill in the answers. timer.Stop(); lblTime.Text = "Time's up!"; DialogResult drReply; drReply = MessageBox.Show("Time's up!. Your score is " + Result + " points. Press 'Yes' to try again and 'No' to close the game.", "Sorry!", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (drReply == DialogResult.Yes) { this.Refresh(); timeLeft = 30; timer.Start(); Result = 0; lblScore.Text = "0"; lblResult.Text = "what kind of food it is"; restart(); } else if (drReply == DialogResult.No) //quit game and return to homepage { HomePage newHomePage = new HomePage(); newHomePage.Show(); this.Hide(); } } }
/*......................... btnLogOut_Click - close this form and open the HomePage form .........................*/ private void btnLogOut_Click(object sender, EventArgs e) { HomePage newHomePage = new HomePage(); newHomePage.Show(); this.Hide(); }