private async void InitPuzzle() { _hasSaved = false; try { _puzzle = new SodukoPuzzle(9, PuzzleCanvas, HintMode.Adjacent); _puzzle.OnCompletedGame += OnGameCompleted; } catch (ArgumentException e) { // Do nothing... string failureMessage = e.Message; } _puzzle.ShowNumberSelector += OnObjectTapped; if (_sii.RestoreState) { if (Serilizer.IsStateSaved()) { LoadData(); } } else { _difficulty = _sii.DesiredDifficulty; if (!_puzzle.InitPuzzle(_difficulty)) { MessageDialog dlg = new MessageDialog("Couldn't init the puzzle!", "Failure"); await dlg.ShowAsync(); } } // The highscore is completely different and is always saved. _gameInfo = Serilizer.GetPersistingSodukoGameInfo(); _expMgr.LoadData(); DisplayHighScore(); SetDifficulty(_difficulty); ShowNumberSelector(); StartTimer(true); HintModeComboBox.SelectedItem = AdjacentComboBoxItem; }
public MainPage() { this.InitializeComponent(); _expMgr.LoadData(); Settings settings = new Settings(); Settings.Restore(); SetFontColor(); bool continueGameEnabled = Serilizer.IsStateSaved(); ContinueButton.Visibility = continueGameEnabled ? Visibility.Visible : Visibility.Collapsed; if (continueGameEnabled) { if (!SetContinueButtonText()) { // Something has gone terribly wrong. } } TimesPlayedData.LoadData(); TimesPlayedData.UpdateUI(TimesPlayedTextBlock); _expMgr.UpdateControls(LevelProgress, CurrentLevel, CurrentExp); }