static NumberFrame GetNumberFrameTemplate(string text) { NumberFrame nf = new NumberFrame(); nf.Font = new Font("Consolas", 14); nf.BorderStyle = BorderStyle.FixedSingle; nf.Width = 40; nf.Height = 40; nf.Text = text; nf.TextAlign = ContentAlignment.MiddleCenter; return(nf); }
private void numberClick(object sender, EventArgs e) { var number = (NumberFrame)sender; if (number.AllowPlayerInput) { //reset Selected.DeFocus(); Selected = number; //new focus number.Focus(); } }
void DisplaySudoku(int[][] sudoku) { for (int r = 0; r < sudoku.Length; r++) { List <NumberFrame> row = new List <NumberFrame>(); for (int c = 0; c < sudoku[r].Length; c++) { //create numberframe NumberFrame nf = GetNumberFrameTemplate(sudoku[r][c] == 0 ? "" : sudoku[r][c].ToString()); nf.Location = new Point((nf.Width * c), (nf.Height * r)); nf.Click += numberClick; this.Controls.Add(nf); row.Add(nf); //create horizontal line if (c == 0) { if (r == 2 || r == 5 || r == 8) { PictureBox line = new PictureBox(); line.BackColor = Color.Black; line.Width = nf.Width * sudoku.Length; line.Height = 4; line.Location = new Point(0, (nf.Height * (r + 1))); this.Controls.Add(line); } } //create vertical line if (r == 0) { if (c == 2 || c == 5) { PictureBox line = new PictureBox(); line.BackColor = Color.Black; line.Width = 4; line.Height = nf.Height * sudoku.Length; line.Location = new Point((nf.Width * (c + 1)), 0); this.Controls.Add(line); } } } framesDisplayed.Add(row); } }