Exemple #1
0
        // Method to be called when the game is completed
        // Asks the player for their name and then asks if they would like to play again
        public void OnWin()
        {
            timer1.Stop();
            string name;

            do
            {
                name = Interaction.InputBox("Please enter your name", "You have successfully completed the board!", "", -1, -1);
            } while (name == "");

            string       filePath = Path.GetFullPath("scores.txt");
            FileInfo     f        = new FileInfo(filePath);
            StreamWriter w;

            if (File.Exists(filePath))
            {
                w = File.AppendText(filePath);
            }
            else
            {
                w = f.CreateText();
            }
            w.WriteLine(passedtime.ToString());
            w.WriteLine(name);
            w.Close();
            scores temp = new scores();

            temp.Close();

            DialogResult dialogResult = MessageBox.Show("Would you like to play again?", "Game Completed!", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                mnu.NewGame(diff);
            }
            else if (dialogResult == DialogResult.No)
            {
                mnu.Show();
            }
            closing = true;
            this.Close();
            closing = false;
        }
Exemple #2
0
        // Display the leader board
        private void LeadBtn_Click(object sender, EventArgs e)
        {
            scores leader = new scores();

            leader.Show();
        }