private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e) { StrikeValue.Text = Gameplay.MaxInRow.ToString(); ScoreValue.Text = Gameplay.Points.ToString(); if (Gameplay.Status != Gameplay.STATUS_FINISHED) NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); IsolatedStorageSettings.ApplicationSettings.TryGetValue("username", out PlayerName); IsolatedStorageSettings.ApplicationSettings.TryGetValue("usercountry", out PlayerCountry); if (PlayerName != null && PlayerCountry != null) { LocalScore = new ScoreResult(Gameplay.Points, PlayerName, PlayerCountry); LocalScore.SaveLocal(); } }
private void SubmitScoreBtn_Click(object sender, RoutedEventArgs e) { var PlayerName = PlayerNameText.Text; Country PlayerCountry = null; if (CountryList.SelectedItem != null) { var SelectedCountryText = (CountryList.SelectedItem as Grid).Children.OfType<TextBlock>().FirstOrDefault(); if (SelectedCountryText != null) PlayerCountry = ( from country in Country.CountryList where country.Name == SelectedCountryText.Text select country ).FirstOrDefault(); } if (PlayerName == null || PlayerName == "") { MessageBox.Show("You need to enter your username."); } else { ScoreResult LocalScore = new ScoreResult(Gameplay.Points, PlayerName, PlayerCountry); LocalScore.SaveLocal(); if (!submitPending) { submitPending = true; if (PlayerName == null || PlayerCountry == null) NavigationService.Navigate(new Uri("/ScoreSubmit.xaml", UriKind.Relative)); else { string uri, postData; LocalScore.SaveOnline(out uri, out postData); ScoreRequests scoreOnline = new ScoreRequests(); scoreOnline.RequestSuccessful += new ScoreEventHandler(scoreOnlineSuccess); scoreOnline.RequestFailed += new ScoreEventHandler(scoreOnlineFail); scoreOnline.ProcessRequest(uri, postData); } } IsolatedStorageSettings.ApplicationSettings["username"] = PlayerName; IsolatedStorageSettings.ApplicationSettings["usercountry"] = PlayerCountry; IsolatedStorageSettings.ApplicationSettings.Save(); NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); } }