private void guessButton_Click(object sender, EventArgs e) { int parsedValue; if (int.TryParse(inputBox.Text, out parsedValue)) { int guess = Convert.ToInt16(inputBox.Text); //TODO add guess to List of guesses on Form1 Form1.guesses.Add(guess); if (guess < rand) { outputLabel.Text = "Too Low!"; } else if (guess > rand) { outputLabel.Text = "Too High!"; } else { outputLabel.Text = "You Got it!"; Refresh(); Thread.Sleep(1000); //TODO close this screen and open a Results Screen (you need to create this) Form f = this.FindForm(); f.Controls.Remove(this); // Create an instance of the SecondScreen ResultScreen rs = new ResultScreen(); rs.Location = new Point((f.Width - rs.Width) / 2, (f.Height - rs.Height) / 2); // Add the User Control to the Form f.Controls.Add(rs); } inputBox.Text = ""; inputBox.Focus(); } // End of int check else { outputLabel.Text = "Please enter an Integer"; inputBox.Text = ""; } }
private void guessButton_Click(object sender, EventArgs e) { int guess = 0; try { //add guess to List of guesses on Form1 guess = Convert.ToInt16(inputBox.Text); Form1.guessList.Add(Convert.ToInt16(inputBox.Text)); } catch { outputLabel.Text = "Please input a number."; } if (guess < rand) { outputLabel.Text = "Too Low!"; } else if (guess > rand) { outputLabel.Text = "Too High!"; } else { outputLabel.Text = "You Got it!"; Refresh(); Thread.Sleep(1000); //close this screen and open a Results Screen (you need to create this) Form f = this.FindForm(); f.Controls.Remove(this); ResultScreen rs = new ResultScreen(); f.Controls.Add(rs); } inputBox.Text = ""; inputBox.Focus(); }
private void guessButton_Click(object sender, EventArgs e) { int guess = Convert.ToInt16(inputBox.Text); //TODO add guess to List of guesses on Form1 //guess.add(guesses); Form1.guesses.Add(guess); if (guess < rand) { outputLabel.Text = "Too Low!"; } else if (guess > rand) { outputLabel.Text = "Too High!"; } else { outputLabel.Text = "You Got it!"; Refresh(); Thread.Sleep(1000); Form f = this.FindForm(); f.Controls.Remove(this); Refresh(); Thread.Sleep(1000); ResultScreen rs = new ResultScreen(); f.Controls.Add(rs); } inputBox.Text = ""; inputBox.Focus(); }
private void guessButton_Click(object sender, EventArgs e) { try { int guess = Convert.ToInt16(inputBox.Text); //TODO add guess to List of guesses on Form1 Form1.guessList.Add(guess); if (guess < rand) { outputLabel.Text = "Too Low!"; } else if (guess > rand) { outputLabel.Text = "Too High!"; } else { outputLabel.Text = "You Got it!"; Refresh(); Thread.Sleep(1000); //TODO close this screen and open a Results Screen (you need to create this) Form f = this.FindForm(); f.Controls.Remove(this); ResultScreen rs = new ResultScreen(); f.Controls.Add(rs); // rs.Location = new Point((f.Width - rs.Width) / 2, (f.Height - rs.Height) / 2); } inputBox.Text = ""; inputBox.Focus(); } catch { } }