public void Clear() { HourlyForecast.Clear(); TextForecast.Clear(); Chance = Qpf_Rain = Qpf_Snow = String.Empty; Alerts.Clear(); }
public TextForecastItemViewModel(TextForecast txt_forecast) { Title = txt_forecast.title; WeatherIcon = txt_forecast.icon; FctText = Settings.IsFahrenheit ? txt_forecast.fcttext : txt_forecast.fcttext_metric; PoP = txt_forecast.pop + "%"; }
public void UpdateView(Weather weather) { #if WINDOWS_UWP var userlang = Windows.System.UserProfile.GlobalizationPreferences.Languages[0]; var culture = new System.Globalization.CultureInfo(userlang); #else var culture = System.Globalization.CultureInfo.CurrentCulture; #endif // Clear all data Clear(); if (weather.hr_forecast != null && weather.hr_forecast.Length > 0) { foreach (HourlyForecast hr_forecast in weather.hr_forecast) { HourlyForecastItemViewModel hrforecastView = new HourlyForecastItemViewModel(hr_forecast); HourlyForecast.Add(hrforecastView); } } if (weather.txt_forecast != null && weather.txt_forecast.Length > 0) { foreach (TextForecast txt_forecast in weather.txt_forecast) { TextForecastItemViewModel txtforecastView = new TextForecastItemViewModel(txt_forecast); TextForecast.Add(txtforecastView); } } if (weather.precipitation != null) { Chance = weather.precipitation.pop + "%"; Qpf_Rain = Settings.IsFahrenheit ? weather.precipitation.qpf_rain_in.ToString("0.00", culture) + " in" : weather.precipitation.qpf_rain_mm.ToString(culture) + " mm"; Qpf_Snow = Settings.IsFahrenheit ? weather.precipitation.qpf_snow_in.ToString("0.00", culture) + " in" : weather.precipitation.qpf_snow_cm.ToString(culture) + " cm"; } if (weather.weather_alerts != null && weather.weather_alerts.Count > 0) { foreach (WeatherAlert alert in weather.weather_alerts) { // Skip if alert has expired if (alert.ExpiresDate <= DateTimeOffset.Now) { continue; } WeatherAlertViewModel alertView = new WeatherAlertViewModel(alert); Alerts.Add(alertView); } } }