예제 #1
0
        private void createGameFild()
        {
            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    cells[i, j]           = new SudokuCells();
                    cells[i, j].Size      = new Size(40, 40);
                    cells[i, j].Location  = new Point(i * 40, j * 40);
                    cells[i, j].FlatStyle = FlatStyle.Flat;
                    cells[i, j].FlatAppearance.BorderColor = Color.Black;

                    if (((i / 3) + (j / 3)) % 2 == 0)
                    {
                        cells[i, j].BackColor = Color.LightGray;
                    }

                    panel1.Controls.Add(cells[i, j]);
                }
            }
        }
예제 #2
0
        private void PressCell(Object sender, KeyPressEventArgs e)
        {
            SudokuCells cell = (SudokuCells)sender;
            int         cellValue;

            if (cell.IsLocked)
            {
                return;
            }

            if (int.TryParse(e.KeyChar.ToString(), out cellValue))
            {
                if (cellValue == 0)
                {
                    cell.Clear();
                }
                else
                {
                    cell.SetText(cellValue);
                }
                cell.ForeColor = SystemColors.ControlDark;
            }
        }