Example #1
0
        private void InitCells(SudokuGrid grid)
        {
            CurrentCell         = new SudokuCell(FirstCellRowPosition, FirstCellColPosition);
            CurrentCellRowIndex = 0;
            CurrentCellColIndex = 0;

            const int SudokuDim = SudokuGrid.SudokuDimension;

            cells = new SudokuCell[SudokuDim, SudokuDim];
            int       currWindowRowPos = GameWindow.FirstCellRowPosition;
            int       currWindowColPos = GameWindow.FirstCellColPosition;
            const int RowIncrement     = GameWindow.CellPositionRowIncrements;
            const int ColIncrement     = GameWindow.CellPositionColIncrements;

            for (int row = 0; row < SudokuDim; row++)
            {
                for (int col = 0; col < SudokuDim; col++)
                {
                    cells[row, col]   = new SudokuCell(grid[row, col], grid.IsEditable(row, col), currWindowRowPos, currWindowColPos);
                    currWindowColPos += ColIncrement;
                }
                currWindowColPos  = GameWindow.FirstCellColPosition;
                currWindowRowPos += RowIncrement;
            }

            menuCells = new MenuCell[MenuItemLabels.Length];
            for (int item = 0; item < menuCells.Length; item++)
            {
                menuCells[item] = new MenuCell(MenuItemsCellRowPosition, MenuItemsCellColPositions[item], MenuItemLabels[item]);
            }
            RedrawCells();
        }
Example #2
0
        private void NewGame(SudokuGrid.Difficulty difficulty)
        {
            grid = SudokuGenerator.Generate(difficulty);

            for (int row = 0; row < 9; row++)
            {
                for (int col = 0; col < 9; col++)
                {
                    cells[row, col].RefreshValues(grid[row, col], grid.IsEditable(row, col));
                }
            }
            RefreshCellValues();
        }
        private void NewGame(SudokuGrid.Difficulty difficulty)
        {
            grid = SudokuGenerator.Generate(difficulty);

            for (int row = 0; row < 9; row++)
            {
                for (int col = 0; col < 9; col++)
                {
                    cells[row, col].RefreshValues(grid[row, col], grid.IsEditable(row, col));
                }
            }
            RefreshCellValues();
        }
        private void InitCells(SudokuGrid grid)
        {
            //Initialize and set highlighted cell.
            CurrentCell = new SudokuCell(FirstCellRowPosition, FirstCellColPosition);
            CurrentCellRowIndex = 0;
            CurrentCellColIndex = 0;

            //Initialize other number fields.
            const int SudokuDim = SudokuGrid.SudokuDimension;
            cells = new SudokuCell[SudokuDim,SudokuDim];
            int currWindowRowPos = GameWindow.FirstCellRowPosition;
            int currWindowColPos = GameWindow.FirstCellColPosition;
            const int RowIncrement = GameWindow.CellPositionRowIncrements;
            const int ColIncrement = GameWindow.CellPositionColIncrements;

            for (int row = 0; row < SudokuDim; row++)
            {
                for (int col = 0; col < SudokuDim; col++)
                {
                    cells[row, col] = new SudokuCell(grid[row, col], grid.IsEditable(row, col), currWindowRowPos, currWindowColPos);
                    currWindowColPos += ColIncrement;
                }
                currWindowColPos = GameWindow.FirstCellColPosition;
                currWindowRowPos += RowIncrement;
            }

            //Initialize menu items
            menuCells = new MenuCell[MenuItemLabels.Length];
            for (int item = 0; item < menuCells.Length; item++)
            {
                menuCells[item] = new MenuCell(MenuItemsCellRowPosition, MenuItemsCellColPositions[item], MenuItemLabels[item]);
            }
            RedrawCells();
        }