コード例 #1
0
ファイル: frmOutOfTime.cs プロジェクト: MadManGaz/homewrk
        // Clicking no will save the user score to a CSV, and then return to the main menu.
        private void btnNo_Click(object sender, EventArgs e)
        {
            if (txtInitials.Text != "")
            {
                List <Score> scoreList = ScoreCSV.LoadFile();
                scoreList.Add(new Score(txtInitials.Text.ToUpper(), game.Score));
                ScoreCSV.SaveFile(scoreList);

                frmMainMenu MainMenu = new frmMainMenu();
                MainMenu.Show();
                Hide();
            }

            else
            {
                MessageBox.Show("Please enter your initials");
                txtInitials.Clear();
            }
        }
コード例 #2
0
ファイル: frmOutOfTime.cs プロジェクト: MadManGaz/homewrk
        // If yes is clicked the user score will be saved and the game will be restarted.
        private void btnYes_Click(object sender, EventArgs e)
        {
            if (txtInitials.Text != "")
            {
                List <Score> scoreList = ScoreCSV.LoadFile();
                scoreList.Add(new Score(txtInitials.Text.ToUpper(), game.Score));
                ScoreCSV.SaveFile(scoreList);

                // Resets variables in frmGame object to default and starts timer
                game.Score         = 0;
                game.lblScore.Text = "0";
                game.Counter       = 30;
                game.Show();
                game.LoadNewQuestion();
                game.tmrCountdown.Start();
                this.Hide();
            }

            else
            {
                MessageBox.Show("Please enter your initials");
                txtInitials.Clear();
            }
        }