public SudokuCell(UIElementCollection panel, int bsize, SudokuBoard sb) { this.sb = sb; this.bsize = bsize; this.children = new List<SudokuCell>(); this.panel = panel; isLeaf = false; int size = bsize * bsize; int bss = size * size; int[] data = new int[bss]; for (var i = 0; i < bss; i++) data[i] = i; for (var i = 0; i < bsize; i++) { for (var j = 0; j < bsize; j++) { var t = new List<int>(); for (var k = i * bsize; k < (i + 1) * bsize; k++) { for (var l = j * bsize; l < (j + 1) * bsize; l++) { t.Add(data[k * size + l]); } } var sc = new SudokuCell(this.panel, t.ToArray(), j, i, bsize, sb); children.Add(sc); } } }
private SudokuCell(UIElementCollection panel, int[] data, int x, int y, int bsize, SudokuBoard sb) { this.sb = sb; this.bsize = bsize; this.panel = panel; this.x = x; this.y = y; if (data.Length > 1) { isLeaf = false; this.children = new List<SudokuCell>(); for (var i = 0; i < bsize; i++) for (var j = 0; j < bsize; j++) { var sc = new SudokuCell(panel, new int[] { data[i * bsize + j] }, j, i, bsize, sb); children.Add(sc); } } else { isLeaf = true; this.index = data[0]; } }