private Boolean AddNewPlace(CityMapProxy city) { var tmp = BindingContext as MasterDetailPage1MasterViewModel; tmp.MenuItems.Add(city); return(true); }
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"); } }
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); } }
public void SetCity(CityMapProxy city) { Load(city); }
public static string ToJson(this CityMapProxy self) => JsonConvert.SerializeObject(self, Settings);
private async void Dissmiss(CityMapProxy city) { Callback(city); await Navigation.PopModalAsync(); }
private bool FilterByName(CityMapProxy city) { return(city.Name.ToLower().Contains(SearchCity.Text.ToLower())); }