示例#1
0
        private void ShowBackSprite()
        {
            PokemonDetails selectedPokemonDetails = new PokemonDetails();
            PokemonResults p = (PokemonResults)lstPokemon.SelectedItem;

            using (var client = new HttpClient())
            {
                if (p is null)
                {
                    return;
                }

                else
                {
                    string pokemonJSON = client.GetStringAsync(p.url).Result;
                    var    result      = client.GetAsync(p.url).Result;
                    selectedPokemonDetails = JsonConvert.DeserializeObject <PokemonDetails>(pokemonJSON);

                    if (selectedPokemonDetails.sprites.back_default is null)
                    {
                        txtBackSpriteError.Text = "No back sprite found for this Pokemon.";
                    }

                    else
                    {
                        imgPokemon.Source = new BitmapImage(new Uri(selectedPokemonDetails.sprites.back_default));
                    }
                }
            }
        }
示例#2
0
        private void lstPokemon_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            btnFlipCount            = 0;
            txtBackSpriteError.Text = "";
            PokemonDetails selectedPokemonDetails = new PokemonDetails();
            PokemonResults p = (PokemonResults)lstPokemon.SelectedItem;

            txtName.Text = p.name.ToUpper();

            using (var client = new HttpClient())
            {
                string pokemonJSON = client.GetStringAsync(p.url).Result;
                selectedPokemonDetails = JsonConvert.DeserializeObject <PokemonDetails>(pokemonJSON);
            }

            txtHeight.Text    = (selectedPokemonDetails.height * 10).ToString("N0") + " cm";
            txtWeight.Text    = (selectedPokemonDetails.weight / 10).ToString("N0") + " kg";
            imgPokemon.Source = new BitmapImage(new Uri(selectedPokemonDetails.sprites.front_default));
        }
示例#3
0
        private void ShowFrontSprite()
        {
            PokemonDetails selectedPokemonDetails = new PokemonDetails();
            PokemonResults p = (PokemonResults)lstPokemon.SelectedItem;

            using (var client = new HttpClient())
            {
                if (p is null)
                {
                    return;
                }

                else
                {
                    string pokemonJSON = client.GetStringAsync(p.url).Result;

                    selectedPokemonDetails = JsonConvert.DeserializeObject <PokemonDetails>(pokemonJSON);

                    imgPokemon.Source = new BitmapImage(new Uri(selectedPokemonDetails.sprites.front_default));
                }
            }
        }