예제 #1
0
        private void SubmitBtn_Click(object sender, RoutedEventArgs e)
        {
            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);
                }
            }
        }
예제 #2
0
        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));
            }
        }
예제 #3
0
        private void HighscoreOnlineList_Loaded(object sender, RoutedEventArgs e)
        {
            ListBox List = sender as ListBox;

            if (List == null)
                return;

            String postData = string.Format("api_key={0}&game_id={1}&order_by=score&order=desc&limit=100&response=XML",
                ScoreResult.SCOREOID_KEY, ScoreResult.SCOREOID_GAMEID);

            String uri = "https://www.scoreoid.com/api/getBestScores";

            ScoreRequests postOfflineScore = new ScoreRequests();
            postOfflineScore.RequestSuccessful += new ScoreEventHandler(ScoreOnlineHandler);
            postOfflineScore.ProcessRequest(uri, postData);
        }