private void submitSolutionBtn_Click(object sender, EventArgs e) { if (!inputSolutionTextbox.Text.Equals("") && inputSolutionTextbox.Text != null) { if (isNullOrEmpty(Solution)) { status("STORED", false); } else { status("OVERWRITTEN", false); } Solution = inputSolutionTextbox.Text.ToLower(); GuessObject go2 = new GuessObject(Solution.Count() + " LETTER WORD", null, null); addToListView(go2, false); inputSolutionTextbox.Text = ""; inputSolutionTextbox.Enabled = false; inputSolutionTextbox.BackColor = Color.Gray; guessTextBox.Enabled = true; guessTextBox.BackColor = Color.White; guessTextBox.Focus(); } else { status("Solution Word Cannot be Blank", true); } }
public void addToListView(GuessObject o, bool err) { var row = (DataGridViewRow)guessDataGrid.Rows[0].Clone(); guessDataGrid.Rows.Add(o.Word, o.Letters, o.Positions); if (err) { row.Cells[0].Style.ForeColor = Color.Red; } }
private void submitGuessButton_Click(object sender, EventArgs e) { int numCorrect = 0; int numCorrectPos = 0; string guess = guessTextBox.Text.ToLower(); if (!guess.Equals("") && guess != null) { guessTextBox.Text = ""; if (guess.Count() != Solution.Count()) { string error = "GUESS MUST BE " + Solution.Count() + " LETTERS"; status(error, true); } else { numCorrect = countNumberCorrect(Solution, guess); numCorrectPos = countNumberCorrectPos(solution, guess); //string result = guessTemp + "\t" + numCorrect + "\t" + numCorrectPos + "\r\n"; GuessObject go = new GuessObject(guess, numCorrect.ToString(), numCorrectPos.ToString()); addToListView(go, false); string msg = "GUESS: " + guess; status(msg, false); if (guess.Equals(Solution)) { var confirm = MessageBox.Show("YOU GOT IT! The word was: " + Solution + ". \n PLAY AGAIN?", "Play again", MessageBoxButtons.YesNo); switch (confirm) { case DialogResult.Yes: clearForm(); break; default: this.Close(); break; } } } } else { status("Guess Cannot be Blank", true); } }