void timer_Tick(object sender, EventArgs e)
 {
     if (i < tableStack.Count)
     {
         SudokuStatus status = (SudokuStatus)tableStack[i];
         sudoku = status.getTable();
         i++;
         panel1.Refresh();
     }
     else
     {
         timer.Stop();
     }
 }
Beispiel #2
0
        public void writeToFile(ArrayList stack, int id)
        {
            string path = @"res\threads\thread#" + id.ToString() + ".txt";

            for (int x = 0; x < stack.Count; x++)
            {
                SudokuStatus status = (SudokuStatus)stack[x];
                int[,] sudoku = status.getTable();

                String[] lines = new String[9];

                for (int i = 0; i < 9; i++)
                {
                    char[] charLine = new char[9];

                    for (int j = 0; j < 9; j++)
                    {
                        if (sudoku[i, j] == 0)
                        {
                            charLine[j] = '*';
                        }
                        else
                        {
                            charLine[j] = (char)(sudoku[i, j] + 48);
                        }
                    }

                    lines[i] = new string(charLine);
                }

                lines[8] += Environment.NewLine;

                if (!File.Exists(path))
                {
                    File.WriteAllLines(path, lines);
                }
                else
                {
                    File.AppendAllLines(path, lines);
                }
            }
        }