public void create(TextBox[,] txtar, ComboBox cmb_level, int variation, SudokuManager objGrid, Label lblPencilMark) { sudokugrid obj = new sudokugrid(); var = variation; setPuzzle(); obj.generate(txtar, save, cmb_level, variation, objGrid, lblPencilMark); }
public void generate(TextBox[,] txtar, int[,] ans, ComboBox cmb_level, int variation, SudokuManager objGrid, Label lblPencilMark) { for (int i = 4000; i <= 15000; i = i + 4000) System.Console.Beep(i, 100); lblPencilMark.Visible = false; objGrid.changeGrid(txtar, variation); switch (variation) { case 0: swap(ans); break; case 1: swapx(ans); break; case 2: swapC(ans); break; case 3: swap4(ans); break; } int diff = difficulty(cmb_level); Random number; int seed; seed = DateTime.Now.Millisecond; number = new Random(seed); int r, s; for (int i = 0; i < diff; i++) { r = number.Next(0, 9); s = number.Next(0, 9); txtar[r, s].Text = ans[r, s].ToString(); txtar[r, s].ReadOnly = true; txtar[r, s].ForeColor = System.Drawing.Color.DarkBlue; } lblPencilMark.Text = ""; }
public void load(TextBox[,] txtar, int[,] save, SudokuManager objGrid) { fs = new FileStream(Directory.GetCurrentDirectory() + "\\Save.txt", FileMode.Open, FileAccess.Read); sr = new StreamReader(fs); objGrid.changeGrid(txtar, int.Parse(sr.ReadLine())); String s; for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { s = sr.ReadLine(); if (!s.Equals("0")) { txtar[i, j].Text = s; if (sr.ReadLine().Equals("1")) { txtar[i, j].ForeColor = System.Drawing.Color.DarkBlue; txtar[i, j].ReadOnly = true; } } else sr.ReadLine(); } } for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { save[i, j] = int.Parse(sr.ReadLine()); } } sr.Close(); fs.Close(); }
public void loadgrid(TextBox[,] txtar, SudokuManager objGrid) { Storage obj = new Storage(); obj.load(txtar, save, objGrid); }