Esempio n. 1
0
        private int[,] GetSudokuGrid(Sudoku sudoku, bool includeReadonlyNumbers)
        {
            var sudokuArray = sudoku.CreateEmptySudokuArray();
            var intList     = sudoku.CreateListOfAllIntegers();

            for (int x = 0; x < CurrentSudoku.fieldsPerRowAmount; x++)
            {
                for (int y = 0; y < CurrentSudoku.fieldsPerRowAmount; y++)
                {
                    try
                    {
                        string s = "0";
                        if (includeReadonlyNumbers || !dgv_Sudoku[x, y].ReadOnly)
                        {
                            s = dgv_Sudoku[x, y].Value.ToString();
                        }

                        var v = Convert.ToInt32(s);
                        if (intList.Contains(v))
                        {
                            sudokuArray[x, y] = v;
                        }
                    }
                    catch
                    {
                    }
                }
            }
            return(sudokuArray);
        }