Esempio n. 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            SearchCityClass searchCityClass = new SearchCityClass(TextBoxForSearch.Text.ToString());

            result = searchCityClass.JsonParse <RootObject>();
            var result1 = searchCityClass.JsonParse <RootObject1>();

            if (result.response.results != null)
            {
                ResultSearchActiveCity.Items.Clear();
                foreach (var i in result.response.results)
                {
                    ResultSearchActiveCity.Items.Add(new Label()
                    {
                        Content = i.city + " " + i.country_name + " " + i.state
                    });
                }
            }
            else if (result1.current_observation != null)
            {
                ListWithCity.Insert(0, result1.current_observation.display_location.city + " " + result1.current_observation.display_location.country_iso3166);
                AddMoreCityWind.Close();
            }
            else
            {
                ResultSearchActiveCity.Items.Clear();
                ResultSearchActiveCity.Items.Add(new Label()
                {
                    Content = "Not Found"
                });
            }

            ActiveCity.ListWithCity = ListWithCity;
        }
Esempio n. 2
0
        private void GridViewColumn_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var itemselect = ((sender as  ListView).SelectedItem as Label).Content.ToString();

            foreach (var i in result.response.results)
            {
                if (i.city.Contains(itemselect.Split(' ').First()) &&
                    i.country_name.Contains(itemselect.Split(' ').Take(2).Last()) &&
                    i.state.Contains(itemselect.Split(' ').Take(3).Last()))
                {
                    ListWithCity.Insert(0, i.city + " " + i.country_iso3166);
                }
            }
            AddMoreCityWind.Close();
        }