예제 #1
0
 private void bStartClick(object sender, EventArgs e)
 {
     bStart.Enabled = false;
     bPause.Enabled = true;
     bPause.Visible = true;
     isFinished     = false;
     RunHeuristics(listBox1.Items.Count == 0);
     if (!isFinished)
     {
         if (View.Board.IsSolved())
         {
             MessageBox.Show("Solved!");
             LogHeuristic("Solved!\n");
             isFinished = true;
             View.Refresh();
         }
         else
         {
             MessageBox.Show("Can not further be solved using these heuristics...");
             LogHeuristic("\nCan not further be solved using these heuristics...");
             if (MessageBox.Show("Save state?", "Verify", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 TekBoardParser parser = new TekBoardParser();
                 parser.Export(View.Board, "test.tx");
             }
             isFinished = true;
         }
     }
     bStart.Enabled = true;
 }
예제 #2
0
        public bool SaveToFile(string FileName)
        {
            if (_view.Board == null)
            {
                return(false);
            }
            TekBoardParser tbp = new TekBoardParser();

            tbp.Export(_view.Board, FileName);
            return(true);
        }
예제 #3
0
        public bool LoadFromFile(string FileName)
        {
            TekBoardParser tbp   = new TekBoardParser();
            TekBoard       board = null;

            try
            {
                board = tbp.Import(FileName);
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message);
                return(false);
            }
            if (board != null)
            {
                SetBoard(board);
                return(true);
            }
            else
            {
                return(false);
            }
        }