Beispiel #1
0
        /// <summary>
        /// Saves the Sudoku on display as a .txt file on the 'saves' directory
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_save_Click(object sender, EventArgs e)
        {
            string fileName = SudokuFileHandler.SaveSudoku(Board.ToString(), Board.Dimension);

            MessageBox.Show("Guardado como \"" + fileName + "\" en el directorio \"saves\" del proyecto",
                            "Guardar Killer Sudoku", MessageBoxButtons.OK, MessageBoxIcon.Information);
            btn_save.Enabled = false;
        }
Beispiel #2
0
        /// <summary>
        /// Loads a Sudoku based on a .txt with the appropiate format
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_load_Click(object sender, EventArgs e)
        {
            bool load = true;

            if (btn_reset.Enabled)
            {
                load = false;
                DialogResult dr = MessageBox.Show("Perderá el sudoku generado/cargado actualmente. Desea continuar?",
                                                  "Confirmación - Cargar Sudoku", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (dr == DialogResult.Yes)
                {
                    load = true;
                }
            }

            if (load)
            {
                try
                {
                    Sudoku newBoard = SudokuFileHandler.LoadSudoku();
                    if (newBoard != null)
                    {
                        Board.Dispose();
                        Board          = newBoard;
                        Board.Location = new Point(180, 30);
                        Controls.Add(Board);
                        Refresh();

                        EnableThreadControls(false);
                        sldr_size.Enabled    = false;
                        sldr_size.Value      = Board.Dimension;
                        btn_generate.Enabled = false;
                        btn_generate.Text    = "GENERATED";
                        btn_solve.Enabled    = false;
                        btn_reset.Enabled    = true;
                        btn_reset.Text       = "Clear Board";
                        btn_save.Enabled     = false;

                        if (Watch != null)
                        {
                            Reset_Watch();
                        }
                    }
                }
                catch (Exception exc)
                {
                    DialogResult dr = MessageBox.Show("Error al cargar Sudoku: " + exc.Message,
                                                      "Error - Cargar Sudoku", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }