private Boolean AddNewPlace(CityMapProxy city)
        {
            var tmp = BindingContext as MasterDetailPage1MasterViewModel;

            tmp.MenuItems.Add(city);
            return(true);
        }
예제 #2
0
        private async void Load(CityMapProxy city)
        {
            using (var client = new HttpClient())
            {
                var url      = "http://api.openweathermap.org/data/2.5/weather?id=" + city.Id + "&APPID=8e44fd2ad82d53c04469e467010eb7b3&units=metric&lang=es";
                var jsonText = await client.GetStringAsync(url);

                var data = OpenWeatherMapProxy.FromJson(jsonText);

                Description.Text = data.Weather[0].Description;
                Temperature.Text = data.Main.Temp + "°C";



                //LastUpdate.Text = String.Format("{0:G}", (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddSeconds(data.Dt));
                TemperatureMin.Text = "Min: " + data.Main.TempMin + " °C";
                TemperatureMax.Text = "Max: " + data.Main.TempMax + " °C";
                Temperature.Text    = data.Main.Temp + " °C";
                Pressure.Text       = data.Main.Pressure + " Pascales";
                Humidity.Text       = data.Main.Humidity + " %";


                //Sunrise.Text = String.Format("{0:T}", (new DateTime(1970, 1, 1)).AddSeconds(data.Sys.Sunrise));
                //Sunset.Text = String.Format("{0:T}", (new DateTime(1970, 1, 1)).AddSeconds(data.Sys.Sunset));


                var            iconUrl = "http://openweathermap.org/img/w/" + data.Weather[0].Icon + ".png";
                UriImageSource source  = new UriImageSource();
                source.Uri  = new Uri(iconUrl);
                Logo.Source = source;


                //Logo.Source = ImageSource.FromResource("WeatherApp.Assets.WeatherIcons." + data.Weather[0].Icon + ".png");
            }
        }
예제 #3
0
        private async void Load()
        {
            var    assembly = typeof(AddPlace).GetTypeInfo().Assembly;
            Stream stream   = assembly.GetManifestResourceStream("WeatherApp.city.list.json");

            using (var reader = new StreamReader(stream))
            {
                string json = await reader.ReadToEndAsync();

                allCities = CityMapProxy.FromJsonArray(json);
            }
        }
예제 #4
0
 public void SetCity(CityMapProxy city)
 {
     Load(city);
 }
예제 #5
0
 public static string ToJson(this CityMapProxy self) => JsonConvert.SerializeObject(self, Settings);
예제 #6
0
 private async void Dissmiss(CityMapProxy city)
 {
     Callback(city);
     await Navigation.PopModalAsync();
 }
예제 #7
0
 private bool FilterByName(CityMapProxy city)
 {
     return(city.Name.ToLower().Contains(SearchCity.Text.ToLower()));
 }