private async void loadForecastInfo_Click(object sender, RoutedEventArgs e) { var forecastInfo = await ForecastProcessor.LoadForecastInformation(); latitudeText.Text = $"Latitude is { forecastInfo.Latitude.ToLocalTime().ToShortTimeString()}"; longitudeText.Text = $"Longitude is { forecastInfo.Longitude.ToLocalTime().ToShortTimeString()}"; }
public async void GetForecastInformation() { if (SelectedLanguage == null || SelectedCity == null) { CurrentSummary = "Select Language/City!"; } else { var forecastInfo = await ForecastProcessor.LoadForecastInformation(SelectedCity.ValueCoord, SelectedLanguage.KeyLang); CurrentSummary = forecastInfo.currently.summary; CurrentTemperature = forecastInfo.currently.temperature + "°C"; CurrentApparentTemperature = forecastInfo.currently.apparentTemperature + "°C"; CurrentPressure = forecastInfo.currently.pressure + "hPa"; CurrentWindSpeed = forecastInfo.currently.windSpeed + "m/s"; CurrentHumidity = forecastInfo.currently.humidity; CurrentUvIndex = forecastInfo.currently.uvIndex; CurrentIcon = @"\Resources\" + forecastInfo.currently.icon + ".png"; string[] DaysAr = new string[8]; string[] IconsDay = new string[8]; for (int i = 0; i < 8; i++) { DaysAr[i] = forecastInfo.daily.data[i].summary + "\n" + forecastInfo.daily.data[i].temperatureHigh + "°C" + "\n" + forecastInfo.daily.data[i].temperatureLow + "°C" + "\n" + forecastInfo.daily.data[i].apparentTemperatureHigh + "°C" + "\n" + forecastInfo.daily.data[i].apparentTemperatureLow + "°C" + "\n" + forecastInfo.daily.data[i].pressure + "hPa" + "\n" + forecastInfo.daily.data[i].windSpeed + "m/s" + "\n" + forecastInfo.daily.data[i].humidity + "\n" + forecastInfo.daily.data[i].uvIndex; IconsDay[i] = forecastInfo.daily.data[i].icon; } Day1 = DaysAr[0]; Day2 = DaysAr[1]; Day3 = DaysAr[2]; Day4 = DaysAr[3]; Day5 = DaysAr[4]; Day6 = DaysAr[5]; Day7 = DaysAr[6]; Day8 = DaysAr[7]; IconDay1 = @"\Resources\" + IconsDay[0] + ".png"; IconDay2 = @"\Resources\" + IconsDay[1] + ".png"; IconDay3 = @"\Resources\" + IconsDay[2] + ".png"; IconDay4 = @"\Resources\" + IconsDay[3] + ".png"; IconDay5 = @"\Resources\" + IconsDay[4] + ".png"; IconDay6 = @"\Resources\" + IconsDay[5] + ".png"; IconDay7 = @"\Resources\" + IconsDay[6] + ".png"; IconDay8 = @"\Resources\" + IconsDay[7] + ".png"; } }
private void OnElapsedTime(object sender) { IProcessor processor = new ForecastProcessor(); string errors; if (!processor.Execute(out errors)) { EventLog.WriteEntry(processor.Name, errors, EventLogEntryType.Error); } }
private async void DisplayForecastDetails() { Forecast forecast = await ForecastProcessor.GetForecast(); int above20DegreeDays = ForecastProcessor.GetNumberOfDaysWithTempAbove(20, forecast); int sunnyDays = ForecastProcessor.GetNumberOfWithWeatherCondition("Clear", forecast); WeatherMap.Text += "In next 5 days" + "\n"; WeatherMap.Text += "--------------" + "\n"; WeatherMap.Text += "The number of days have temperature above 20 degrees = " + above20DegreeDays + "\n"; WeatherMap.Text += "The number of sunny days = " + sunnyDays + "\n"; WeatherMap.Text += "\n N.B 'Clear' days are taken as 'Sunny' days."; }
/// <summary> /// This method is to display the forecast details. /// </summary> /// <returns></returns> private static async Task DisplayForecastDetails() { Forecast forecast = await ForecastProcessor.GetForecast(url); int above20DegreeDays = ForecastProcessor.GetNumberOfDaysWithTempAbove(20, forecast); int sunnyDays = ForecastProcessor.GetNumberOfWithWeatherCondition("Clear", forecast); Console.WriteLine("In next 5 days"); Console.WriteLine("--------------"); Console.WriteLine("The number of days have temperature above 20 degrees = " + above20DegreeDays); Console.WriteLine("The number of sunny days = " + sunnyDays); Console.WriteLine("N.B 'Clear' days are taken as 'Sunny' days."); Console.WriteLine("Updated at " + DateTime.Now); }
private async static void GetWeatherForecast() { await ForecastProcessor.ForecastWeather(); }