示例#1
0
 public bool RestoreSnapshot(string name)
 {
     if (Moves != null)
     {
         Moves.RestoreSnapshot(name);
         _view.Refresh();
         return(true);
     }
     else
     {
         return(false);
     }
 }
        private HeuristicAction TryValue(TekBoard board, TekField field, int value)
        {
            bool            prev   = board.EatExceptions;
            HeuristicAction result = HeuristicAction.haNone;

            try
            {
                board.EatExceptions = false;
                this.Enabled        = false; // make sure FindHeuristic doesnt call this recursively!
                if ((result = _tryValue(field, value)) == HeuristicAction.haNone)
                {
                    temStoredResults.Clear();
                    temMoves.TakeSnapshot(_ssDescription(field));
                    try {
                        do
                        {
                            try
                            {
                                result = _tryHeuristic(heuristics.FindHeuristic(board), board);
                            }
                            catch (ETekFieldInvalid)
                            {
                                result = HeuristicAction.haImpossible;
                            }
                        } while (result == HeuristicAction.haNone);
                    }
                    finally
                    {
                        temMoves.RestoreSnapshot(_ssDescription(field));
                        _ssIndex++;
                    }
                }
            }
            finally
            {
                board.EatExceptions = prev;
                this.Enabled        = true;
                field.Value         = 0; // backtracking
            }
            return(result);
        }