コード例 #1
0
ファイル: Own.xaml.cs プロジェクト: Cemonix/Sudoku-Solver
        /// <summary>
        /// Button witch solves given Sudoku and shows it on Canvas
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SolveButton(object sender, RoutedEventArgs e)
        {
            randomSudokuClass = new Pages.RandomSudoku();
            Classes.Sudoku sudokuClass = new Classes.Sudoku(Extract);
            // Returns solved Sudoku
            int[,] solvedSudoku = await sudokuClass.SudokuMain(notSolvedSudoku);

            this._SolvedSudoku = solvedSudoku;

            if (solvedSudoku == null)
            {
                MessageBox.Show("Sudoku has no solution");
            }
            else
            {
                // Check if Sudoku has been completed because of pressing button more than once
                bool condition = randomSudokuClass.Completed(this._SudokuArray);
                if (condition)
                {
                    MessageBox.Show("Sudoku has been solved");
                }
                else
                {
                    // Display completed Sudoku on Canvas
                    int temp = 0;
                    for (int i = 0; i < 9; i++)
                    {
                        for (int j = 0; j < 9; j++)
                        {
                            Label l = (Label)this._SudokuArray.Children[temp];
                            l.Content = this._SolvedSudoku[i, j].ToString();
                            temp++;
                        }
                    }
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Button that gets user to random generated sudoku page
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Random(object sender, RoutedEventArgs e)
 {
     Pages.RandomSudoku rp = new Pages.RandomSudoku();
     frame.Navigate(rp);
 }