コード例 #1
0
        private async Task ImportPokemonSet(object arg)
        {
            using (var client = new WebClient())
            {
                var json = await client.DownloadStringTaskAsync($"https://api.pokemontcg.io/v1/cards?setCode={SelectedSet.SetCode}&supertype=Pok%C3%A9mon").ConfigureAwait(false);

                var headers = client.ResponseHeaders;

                int cardsFound = int.Parse(headers.Get("Count"));
                int pageSize   = int.Parse(headers.Get("Page-Size"));

                if (cardsFound > pageSize)
                {
                    //TODO
                    MessageBox.Show("There are more cards!!!");
                }
                var pokemons = new List <PokemonViewModel>();
                foreach (var card in JsonConvert.DeserializeObject <JsonPokemonList>(json).Cards)
                {
                    var pokemon = PokemonCreator.CreateCardFromSdkCard(card);

                    var model = new PokemonViewModel(pokemon);
                    model.Card.CardId = NetworkId.Generate();
                    pokemons.Add(model);
                }

                foreach (var pokemon in pokemons.OrderBy(x => x.Card.Name))
                {
                    PokemonCards.Add(pokemon);
                }

                SelectedCard = PokemonCards.First();
            }
        }
コード例 #2
0
 private void DeletePokemon(object obj)
 {
     PokemonCards.Remove((PokemonViewModel)obj);
     UpdatePokemonFilter();
     SelectedCard = PokemonCards.First();
 }