private async Task <WeatherDays> weathersD() { WeatherApi root = await parseJsonObj(); int idcity = root.id; HttpClient web = new HttpClient(); string response = await web.GetStringAsync(" http://api.openweathermap.org/data/2.5/forecast/daily?APPID=" + APPID + "&id=" + idcity + "&cnt=8"); WeatherDays weatherDay = JsonConvert.DeserializeObject <WeatherDays>(response); return(weatherDay); }
private async void chartTemp() { WeatherDays weaDays = await weathersD(); List <ChartDay> chartday = new List <ChartDay>(); chartday.Add(new ChartDay() { CName = nameDays(1), CTemp = Math.Round((weaDays.list[1].temp.day - 273.1), 2) }); chartday.Add(new ChartDay() { CName = nameDays(2), CTemp = Math.Round((weaDays.list[2].temp.day - 273.1), 2) }); chartday.Add(new ChartDay() { CName = nameDays(3), CTemp = Math.Round((weaDays.list[3].temp.day - 273.1), 2) }); chartday.Add(new ChartDay() { CName = nameDays(4), CTemp = Math.Round((weaDays.list[4].temp.day - 273.1), 2) }); chartday.Add(new ChartDay() { CName = nameDays(5), CTemp = Math.Round((weaDays.list[5].temp.day - 273.1), 2) }); chartday.Add(new ChartDay() { CName = nameDays(6), CTemp = Math.Round((weaDays.list[6].temp.day - 273.1), 2) }); chartday.Add(new ChartDay() { CName = nameDays(7), CTemp = Math.Round((weaDays.list[7].temp.day - 273.1), 2) }); (LineChart.Series[0] as LineSeries).ItemsSource = chartday; }
private async void SevenDays() { WeatherDays weaDays = await weathersD(); //add Image string imgD1 = "http://openweathermap.org/img/w/" + weaDays.list[1].weather[0].icon + ".png"; string imgD2 = "http://openweathermap.org/img/w/" + weaDays.list[2].weather[0].icon + ".png"; string imgD3 = "http://openweathermap.org/img/w/" + weaDays.list[3].weather[0].icon + ".png"; string imgD4 = "http://openweathermap.org/img/w/" + weaDays.list[4].weather[0].icon + ".png"; string imgD5 = "http://openweathermap.org/img/w/" + weaDays.list[5].weather[0].icon + ".png"; string imgD6 = "http://openweathermap.org/img/w/" + weaDays.list[6].weather[0].icon + ".png"; string imgD7 = "http://openweathermap.org/img/w/" + weaDays.list[7].weather[0].icon + ".png"; imgDay1.Source = new BitmapImage(new Uri(imgD1)); imgDay2.Source = new BitmapImage(new Uri(imgD2)); imgDay3.Source = new BitmapImage(new Uri(imgD3)); imgDay4.Source = new BitmapImage(new Uri(imgD4)); imgDay5.Source = new BitmapImage(new Uri(imgD5)); imgDay6.Source = new BitmapImage(new Uri(imgD6)); imgDay7.Source = new BitmapImage(new Uri(imgD7)); //Add Temp Day tbDTemp1.Text = Math.Round((weaDays.list[1].temp.day - 273.1), 2).ToString() + " ℃"; tbDTemp2.Text = Math.Round((weaDays.list[2].temp.day - 273.1), 2).ToString() + " ℃"; tbDTemp3.Text = Math.Round((weaDays.list[3].temp.day - 273.1), 2).ToString() + " ℃"; tbDTemp4.Text = Math.Round((weaDays.list[4].temp.day - 273.1), 2).ToString() + " ℃"; tbDTemp5.Text = Math.Round((weaDays.list[5].temp.day - 273.1), 2).ToString() + " ℃"; tbDTemp6.Text = Math.Round((weaDays.list[6].temp.day - 273.1), 2).ToString() + " ℃"; tbDTemp7.Text = Math.Round((weaDays.list[7].temp.day - 273.1), 2).ToString() + " ℃"; //Add Temp Night tbNTemp1.Text = Math.Round((weaDays.list[1].temp.night - 273.1), 2).ToString() + " ℃"; tbNTemp2.Text = Math.Round((weaDays.list[2].temp.night - 273.1), 2).ToString() + " ℃"; tbNTemp3.Text = Math.Round((weaDays.list[3].temp.night - 273.1), 2).ToString() + " ℃"; tbNTemp4.Text = Math.Round((weaDays.list[4].temp.night - 273.1), 2).ToString() + " ℃"; tbNTemp5.Text = Math.Round((weaDays.list[5].temp.night - 273.1), 2).ToString() + " ℃"; tbNTemp6.Text = Math.Round((weaDays.list[6].temp.night - 273.1), 2).ToString() + " ℃"; tbNTemp7.Text = Math.Round((weaDays.list[7].temp.night - 273.1), 2).ToString() + " ℃"; //Weather Description tbWDes1.Text = weaDays.list[1].weather[0].description; tbWDes2.Text = weaDays.list[2].weather[0].description; tbWDes3.Text = weaDays.list[3].weather[0].description; tbWDes4.Text = weaDays.list[4].weather[0].description; tbWDes5.Text = weaDays.list[5].weather[0].description; tbWDes6.Text = weaDays.list[6].weather[0].description; tbWDes7.Text = weaDays.list[7].weather[0].description; //Wind Speed tbWindS1.Text = weaDays.list[1].speed.ToString() + " m/s"; tbWindS2.Text = weaDays.list[2].speed.ToString() + " m/s"; tbWindS3.Text = weaDays.list[3].speed.ToString() + " m/s"; tbWindS4.Text = weaDays.list[4].speed.ToString() + " m/s"; tbWindS5.Text = weaDays.list[5].speed.ToString() + " m/s"; tbWindS6.Text = weaDays.list[6].speed.ToString() + " m/s"; tbWindS7.Text = weaDays.list[7].speed.ToString() + " m/s"; //Name Day tbDayN1.Text = nameDays(1); tbDayN2.Text = nameDays(2); tbDayN3.Text = nameDays(3); tbDayN4.Text = nameDays(4); tbDayN5.Text = nameDays(5); tbDayN6.Text = nameDays(6); tbDayN7.Text = nameDays(7); }