private async void NavToMoreInfoPage(PokemonItem pokemonItem)
        {
            var navParams = new NavigationParameters();

            navParams.Add("WeatherItemInfo", pokemonItem);
            await _navigationService.NavigateAsync("MoreInfoPage", navParams);
        }
Exemplo n.º 2
0
 public void OnNavigatedTo(NavigationParameters parameters)
 {
     if (parameters.ContainsKey("WeatherItemInfo"))
     {
         PokemonItem = (PokemonItem)parameters["WeatherItemInfo"];
     }
 }
Exemplo n.º 3
0
        static List <PokemonItem> GeneratePokemon(string[] mons)
        {
            List <PokemonItem> pokemons = new List <PokemonItem>();

            //Make Pokemon
            for (int i = 0; i < mons.Length; i++)
            {
                int         buffer = 0;
                PokemonItem pi     = new PokemonItem();
                pi._stats = new PokeStats();

                pi._ID  = mons[i].Substring(0, mons[i].IndexOf(":")).Trim();
                mons[i] = mons[i].Substring(mons[i].IndexOf("\n") + 1);

                string[] stats = mons[i].Split("\n");
                for (int j = 0; j < stats.Length; j++)
                {
                    string   stat      = stats[j].Trim().Replace(",", "");
                    string[] statSplit = stat.Split(":");

                    if (statSplit.Length < 2)
                    {
                        continue;
                    }

                    if (statSplit[0].ToLower().Trim() == "frame")
                    {
                        buffer++;
                        continue;
                    }

                    if (statSplit[0].ToLower().Trim() == "nature")
                    {
                        statSplit[1] = ConvertNature(statSplit[1].ToLower().Trim()).ToString();
                    }
                    else if (statSplit[0].ToLower().Trim() == "pid")
                    {
                        uint pidInt = uint.Parse(statSplit[1], System.Globalization.NumberStyles.HexNumber);
                        statSplit[1] = pidInt.ToString();
                    }

                    pi._stats[j - buffer] = statSplit[1].Trim();
                }

                if (removeDupes)
                {
                    if (!pokemons.Any(x => x._stats._PID == pi._stats._PID))
                    {
                        pokemons.Add(pi);
                    }
                }
                else
                {
                    pokemons.Add(pi);
                }
            }

            return(pokemons);
        }
Exemplo n.º 4
0
        public void TestNavToMoreInfoPageCommandNavigateAsyncWithCorrectParameters()
        {
            PokemonItem weatherItemToPass = new PokemonItem();
            var         expectedNavParams = new NavigationParameters();

            expectedNavParams.Add("WeatherItemInfo", weatherItemToPass);
            navigationServiceMock.Setup(
                ns => ns.NavigateAsync(It.IsAny <string>(),
                                       It.IsAny <NavigationParameters>(),
                                       It.IsAny <bool?>(),
                                       It.IsAny <bool>()));

            mainPageViewModel.NavToMoreInfoPageCommand.Execute(weatherItemToPass);

            navigationServiceMock.Verify(
                ns => ns.NavigateAsync("MoreInfoPage",
                                       expectedNavParams,
                                       false,
                                       true), Times.Once());
        }
        internal async void GetPokemonFromName()
        {
            /* Analytics.TrackEvent("GetWeatherButtonTapped", new Dictionary<string, string> {
             *   { "WeatherLocation", LocationEnteredByUser},
             * });
             */
            HttpClient client   = new HttpClient();
            var        uri      = new Uri(string.Format($"{ApiKeys.PokemonKey}" + LocationEnteredByUser.ToLower()));
            var        response = await client.GetAsync(uri);

            PokemonItem pokemonData = null;

            if (response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync();

                pokemonData = PokemonItem.FromJson(content);
            }
            PokemonCollection.Add(pokemonData);
        }
Exemplo n.º 6
0
 public static string ToJson(this PokemonItem self) => JsonConvert.SerializeObject(self, Converter.Settings);