コード例 #1
0
        private void cboPokemon_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Pokemon SelectedPokemon = (Pokemon)cboPokemon.SelectedItem;


            //PokemonStatsAPI PokemonSapi;
            using (var client = new HttpClient())
            {
                string SelectedPokemonURL = SelectedPokemon.url;;

                string json = client.GetStringAsync(SelectedPokemonURL).Result;

                PokemonSapi = JsonConvert.DeserializeObject <PokemonStatsAPI>(json);
            }

            //PokemonStatsAPI selectedCharacter = (PokemonStatsAPI)cboPokemon.SelectedItem;

            Uri         uri     = new Uri(PokemonSapi.sprites.front_default);
            BitmapImage picture = new BitmapImage(uri);

            imagePokemon.Source = picture;

            txtHeight.Text = $"{Convert.ToString(PokemonSapi.Height)} Feet";
            txtWeight.Text = $"{Convert.ToString(PokemonSapi.Weight)} Pounds";
            //lblPokemonName.Content = $"{PokemonNameAPI.results.name}";
        }
コード例 #2
0
        private void txtChangeView_Click(object sender, RoutedEventArgs e)
        {
            if (txtChangeView.IsEnabled == true)
            {
                Pokemon SelectedPokemon = (Pokemon)cboPokemon.SelectedItem;

                using (var client = new HttpClient())
                {
                    string SelectedPokemonURL = SelectedPokemon.url;;

                    string json = client.GetStringAsync(SelectedPokemonURL).Result;

                    PokemonSapi = JsonConvert.DeserializeObject <PokemonStatsAPI>(json);
                }

                Uri         uri     = new Uri(PokemonSapi.sprites.back_default);
                BitmapImage picture = new BitmapImage(uri);

                imagePokemon.Source = picture;

                txtChangeView.IsEnabled = false;
            }
            else
            {
                Pokemon SelectedPokemon = (Pokemon)cboPokemon.SelectedItem;

                using (var client = new HttpClient())
                {
                    string SelectedPokemonURL = SelectedPokemon.url;;

                    string json = client.GetStringAsync(SelectedPokemonURL).Result;

                    PokemonSapi = JsonConvert.DeserializeObject <PokemonStatsAPI>(json);
                }

                Uri         uri     = new Uri(PokemonSapi.sprites.front_default);
                BitmapImage picture = new BitmapImage(uri);

                imagePokemon.Source = picture;

                txtChangeView.IsEnabled = true;
            }

            //Pokemon SelectedPokemon = (Pokemon)cboPokemon.SelectedItem;

            //using (var client = new HttpClient())
            //{
            //    string SelectedPokemonURL = SelectedPokemon.url; ;

            //    string json = client.GetStringAsync(SelectedPokemonURL).Result;

            //    PokemonSapi = JsonConvert.DeserializeObject<PokemonStatsAPI>(json);
            //}

            //Uri uri = new Uri(PokemonSapi.sprites.back_default);
            //BitmapImage picture = new BitmapImage(uri);

            //imagePokemon.Source = picture;
        }