public PokemonEvoViewModel(string language, PokemonModel selectedPokemon, BindableCollection <PokemonModel> pokeList, IEventAggregator events) { _language = language; _pokeList = pokeList; _events = events; SelectedPokemon = selectedPokemon; EvolutionHeader = EvolutionLanguage.GetEvolutionHeader(_language); LoadPokemonEvolutions(); }
private async void LoadPokemonEvoInfos() { Pokemon pokemonInfo; EvolutionChain evoChain = await pokeClient.GetResourceAsync <EvolutionChain>(evoId); EvoOneList.Clear(); PokeImageBasis = null; PokeImageEvoOne = null; PokeImageEvoTwo = null; try { BasisHeader = EvolutionLanguage.GetBasisHeader(_language); PokemonSpecies pokemonBasis = await pokeClient.GetResourceAsync <PokemonSpecies>(evoChain.Chain.Species.Name); var tempBasis = _pokeList.First(x => x.PokeNameOriginal == pokemonBasis.Name).PokeName; PokemonBasisName = tempBasis; pokemonInfo = await pokeClient.GetResourceAsync <Pokemon>(pokemonBasis.Id); PokeImageBasis = await LoadPokemonEvoPic(pokemonInfo); } catch { PokemonBasisName = ""; } try { // Some Pokemons have more then one first evolution! // So we load allways in a List for (int i = 0; i < evoChain.Chain.EvolvesTo.Count; i++) { PokemonSpecies pokemonEvoOne = await pokeClient.GetResourceAsync <PokemonSpecies>(evoChain.Chain.EvolvesTo[i].Species.Name); var tempEvoOne = _pokeList.First(x => x.PokeNameOriginal == pokemonEvoOne.Name).PokeName; PokemonEvoOneName = tempEvoOne; pokemonInfo = await pokeClient.GetResourceAsync <Pokemon>(pokemonEvoOne.Id); PokeImageEvoOne = await LoadPokemonEvoPic(pokemonInfo); EvoOneList.Add(new EvolutionModel { Name = PokemonEvoOneName, EvoImage = PokeImageEvoOne } ); } if (EvoOneList.Count > 0) { EvoOneHeader = EvolutionLanguage.GetEvoOneHeader(_language); } } catch { PokemonEvoOneName = ""; } try { PokemonSpecies pokemonEvoTwo = await pokeClient.GetResourceAsync <PokemonSpecies>(evoChain.Chain.EvolvesTo[0].EvolvesTo[0].Species.Name); var tempEvoTwo = _pokeList.First(x => x.PokeNameOriginal == pokemonEvoTwo.Name).PokeName; EvoTwoHeader = EvolutionLanguage.GetEvoTwoHeader(_language); PokemonEvoTwoName = tempEvoTwo; pokemonInfo = await pokeClient.GetResourceAsync <Pokemon>(pokemonEvoTwo.Id); PokeImageEvoTwo = await LoadPokemonEvoPic(pokemonInfo); } catch { PokemonEvoTwoName = ""; } NotifyOfPropertyChange(() => BasisHeader); NotifyOfPropertyChange(() => PokemonBasisName); NotifyOfPropertyChange(() => PokeImageBasis); NotifyOfPropertyChange(() => EvoOneHeader); NotifyOfPropertyChange(() => EvoTwoHeader); NotifyOfPropertyChange(() => PokemonEvoTwoName); NotifyOfPropertyChange(() => PokeImageEvoTwo); ShowEvoOne(); CompareSelectedPokemon(); }