//Enter button to add your name to the high score event handler private void enterScoreBtn_Click(object sender, EventArgs e) { //checks length is at least 3 characters if (NameBox.Text.Length > 2) { string input = NameBox.Text; Console.WriteLine(input); //sets up string to write to file string line = input + "," + score + "\n"; NameBox.Hide(); nameLbl.Hide(); enterScoreBtn.Hide(); //writes to file writeToFile(line); // reads and sorts score board from file readFromFile(); NameNotifLbl.Text = "Leaderboard updated"; NameNotifLbl.Show(); } else { NameNotifLbl.Text = "Name must be at least 3 characters"; NameNotifLbl.Show(); } }
/* * constructor for high score form. */ public HighScore(int score, int gameMode) { InitializeComponent(); NameBox.Hide(); nameLbl.Hide(); enterScoreBtn.Hide(); NameNotifLbl.Hide(); this.score = score; scoreLbl.Text = "SCORE: " + score; this.gameMode = gameMode; }