private void button5_Click(object sender, EventArgs e) { MyCellBox myCellBox = new MyCellBox(this, 100, 100); SudokuSolver sudokuSolver = new SudokuSolver(); SudokuGrid mySudoku = myCellBox.CurrentGrid(); if (mySudoku.IsValid()) { int difficulty = sudokuSolver.RateDifficulty(mySudoku); infoBox.Text = $"Current sudoku is {difficulty} stars"; if (difficulty == 6) { infoBox.Text = "Current sudoku was solved with brute force"; } } else { infoBox.Text = "Current Sudoku is invalid"; } }
public Form1() { InitializeComponent(); var sudokuSolver = new SudokuSolver(); //initialize cells for (var i = 0; i < 9; i++) { for (var j = 0; j < 9; j++) { var newCell = new MyCellBox(this, i, j); newCell.Width = 30; newCell.Height = 30; newCell.Left = 100 + j * 33; newCell.Top = 100 + i * 33; this.Controls.Add(newCell); } } //initialize displays for (var i = 0; i < 9; i++) { var newCell = new MyDisplayBox(this); newCell.Width = 20; newCell.Height = 30; newCell.Left = 100 + i * 33 + 5; newCell.Top = 67 + 5; this.Controls.Add(newCell); newCell.Text = "" + (i + 1); String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var newCell2 = new MyDisplayBox(this); newCell2.Width = 20; newCell2.Height = 30; newCell2.Top = 100 + i * 33; newCell2.Left = 67 + 5; this.Controls.Add(newCell2); newCell2.Text = alphabet.Substring(i, 1); } this.Height = 550; var newButton = new Button(); this.Controls.Add(newButton); newButton.Text = "helloWorld"; infoBox = new TextBox(); this.Controls.Add(infoBox); infoBox.ReadOnly = true; infoBox.TabStop = false; infoBox.Left = 100; infoBox.Width = 400; this.Controls.Add(HintDisplay); HintDisplay.Left = this.Width - 200; HintDisplay.Width = 180; }