Esempio n. 1
0
        private void button_load_Click(object sender, RoutedEventArgs e)
        {
            board.Hard_Clear(siatka, buffer);
            Load wczytaj = new Load(siatka, buffer, tab);

            wczytaj.Show();
        }
Esempio n. 2
0
        private void button_saved_Click(object sender, RoutedEventArgs e)
        {
            bool valid = true;

            if (button_saved.Content.ToString() == GUIElementsDescriptions.load)
            {
                if (file_Services.load_file(textBox_destination.Text))
                {
                    try
                    {
                        Board.FromFile(sudoku, buffer, file_Services.buffer_text);
                        for (int i = 0; i < 9; i++)
                        {
                            for (int j = 0; j < 9; j++)
                            {
                                if (buffer[i, j] != 0)
                                {
                                    if (!solver.Check(i, j, buffer, buffer[i, j]))
                                    {
                                        valid = false;
                                        Board.Hard_Clear(sudoku, buffer);
                                        System.Windows.MessageBox.Show("Invalid input file");
                                    }
                                }
                            }
                        }
                        if (valid)
                        {
                            solver.Put_in(tab, buffer);
                            tab = solver.Solve(tab, buffer, 0, 0);
                            this.Close();
                        }
                    }
                    catch (Exception c)
                    {
                        System.Windows.MessageBox.Show("Damaged file\n" + c);
                    }
                }
            }
            else if (button_saved.Content.ToString() == GUIElementsDescriptions.save)
            {
                file_Services.save_file(textBox_destination.Text, tab);
                this.Close();
            }
        }