//Suggest solution for current cell public void SuggestCell() { if (SudokuChecker.SudokuSolver(SudokuTempSolution, 0, 0)) { if (SudokuMatrix[CurrentRow, CurrentColumn] != SudokuTempSolution[CurrentRow, CurrentColumn]) { string SuggestNumber = SudokuTempSolution[CurrentRow, CurrentColumn].ToString(); AddInstructorText("You should fill " + SuggestNumber + " in the cell [" + (CurrentColumn + 1).ToString() + ":" + (CurrentRow + 1).ToString() + "]"); } else { AddInstructorText("You have filled the right number"); } } else { AddInstructorText("Cannot suggest due to invalid value existed"); } }
//Solve the game if player give up public void SolveGame() { if (SudokuChecker.SudokuSolver(SudokuTempSolution, 0, 0)) { MessageBox.Show(" Resolve successful \n Timer will be reseted \n Please start a new game", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); SudokuTimer.Stop(); hour = 0; minute = 0; second = 0; TimeCounter.Text = string.Format("{0}:{1}:{2}", hour.ToString().PadLeft(2, '0'), minute.ToString().PadLeft(2, '0'), second.ToString().PadLeft(2, '0')); TriggerButton.Enabled = false; SuggestButton.Enabled = false; ValidateButton.Enabled = false; SolveButton.Enabled = false; Copy(SudokuTempSolution, SudokuMatrix); ShowMatrix(); } else { MessageBox.Show(" Cannot solve due to rule violation \n Please check again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }