using System.ComponentModel;
using System.Globalization;
using WeatherInformation.Model;
+using WeatherInformation.Model.CurrentWeatherParser;
+using WeatherInformation.Model.ForecastWeatherParser;
using WeatherInformation.Model.Images;
using WeatherInformation.Resources;
public String CurrentSunSet { get; private set; }
/// <summary>
- /// Crear y agregar unos pocos objetos ItemViewModel a la colección Items.
+ /// Update UI
/// </summary>
public void LoadData(WeatherData weatherData)
{
// TODO: there must be a better way than using the index value :(
+ bool isFahrenheit = true;
+ int temperatureUnitsSelection = _settings.TemperaruteUnitsSelectionSetting;
+ if (temperatureUnitsSelection != 0)
+ {
+ isFahrenheit = false;
+ }
+ double tempUnits = isFahrenheit ? 0 : 273.15;
+ string symbol = isFahrenheit ? AppResources.TemperatureUnitsFahrenheitSymbol : AppResources.TemperatureUnitsCentigradeSymbol;
+ DateTime baseUnixTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+
+ string country = weatherData.Country;
+ string city = weatherData.City;
+ string cityCountry = String.Format(CultureInfo.InvariantCulture, "{0}, {1}", city, country);
+ this.TitleTextCityCountry = cityCountry;
+ NotifyPropertyChanged("TitleTextCityCountry");
+
+ if (weatherData.Forecast != null)
+ {
+ UpdateForecastUI(weatherData.Forecast, baseUnixTime, symbol, tempUnits);
+ }
+
+ if (weatherData.Current != null)
+ {
+ UpdateCurrentUI(weatherData.Current, baseUnixTime, symbol, tempUnits);
+ }
+ }
- int forecastDayNumbers = _settings.ForecastDayNumbersSelectionSetting;
+ private void UpdateForecastUI(ForecastWeather forecast, DateTime baseUnixTime, string symbol, double tempUnits)
+ {
+ // TODO: there must be a better way than using the index value :(
+ int forecastDayNumbers = _settings.ForecastDayNumbersSelectionSetting;
int count;
- switch(forecastDayNumbers)
+ switch (forecastDayNumbers)
{
- case(0):
+ case (0):
count = 5;
break;
- case(1):
+ case (1):
count = 10;
break;
- case(2):
+ case (2):
count = 14;
break;
default:
break;
}
- // TODO: there must be a better way than using the index value :(
- bool isFahrenheit = true;
- int temperatureUnitsSelection = _settings.TemperaruteUnitsSelectionSetting;
- if (temperatureUnitsSelection != 0)
- {
- isFahrenheit = false;
- }
- double tempUnits = isFahrenheit ? 0 : 273.15;
- string symbol = isFahrenheit ? AppResources.TemperatureUnitsFahrenheitSymbol : AppResources.TemperatureUnitsCentigradeSymbol;
- DateTime unixTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+ this.ForecastItems.Clear();
- var remoteForecastWeatherData = weatherData.Forecast;
- if (remoteForecastWeatherData != null)
+ foreach (WeatherInformation.Model.ForecastWeatherParser.List item in forecast.list)
{
- this.ForecastItems.Clear();
-
- foreach (WeatherInformation.Model.ForecastWeatherParser.List item in remoteForecastWeatherData.list)
+ var lineOne = "";
+ var lineTwo = "";
+ if (item.dt != null)
{
- DateTime date = unixTime.AddSeconds(item.dt);
+ var date = baseUnixTime.AddSeconds(item.dt.Value);
+ lineOne = date.ToString("ddd", CultureInfo.InvariantCulture);
+ lineTwo = date.ToString("dd", CultureInfo.InvariantCulture);
+ }
- // TODO: if I do not receive max temp or min temp... Am I going to receive item.temp.max=0 or item.temp.min=0 (I guess because
- // double has no null value)
- // I need something that is not 0 value in order to find out if OpenWeatherMap sent me values or not :/
- // I guess; I am going to need nullable but I will have to modify my Json Parser :(
- double maxTemp = item.temp.max;
+ string lineThree = symbol;
+ if (item.temp.max != null)
+ {
+ var maxTemp = item.temp.max;
maxTemp = maxTemp - tempUnits;
+ lineThree = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", maxTemp) + symbol;
+ }
- double minTemp = item.temp.min;
+ string lineFour = symbol;
+ if (item.temp.min != null)
+ {
+ var minTemp = item.temp.min;
minTemp = minTemp - tempUnits;
-
- string weatherImage;
- if (item.weather.Count > 0 &&
- item.weather[0].icon != null &&
- RemoteImagesTranslation.GetTransaltedImage(item.weather[0].icon) != null)
- {
- weatherImage = RemoteImagesTranslation.GetTransaltedImage(item.weather[0].icon);
- }
- else
- {
- weatherImage = "weather_severe_alert";
- }
- string weatherImagePath = String.Format(CultureInfo.InvariantCulture, "/Images/{0}.png", weatherImage);
-
- this.ForecastItems.Add(new ItemViewModel()
- {
- LineOne = date.ToString("ddd", CultureInfo.InvariantCulture),
- LineTwo = date.ToString("dd", CultureInfo.InvariantCulture),
- LineThree = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", maxTemp) + symbol,
- LineFour = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", minTemp) + symbol,
- LineFive = weatherImagePath
- });
-
- count--;
- if (count == 0)
- {
- break;
- }
+ lineFour = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", minTemp) + symbol;
}
- }
-
- // TODO: nullables?
- // TODO: nullables para distinguir cuando hay datos o no. Ahora me llega 0 si no datos (supongo) cuando double/integer
- var remoteCurrentWeatherData = weatherData.Current;
- if (remoteCurrentWeatherData != null)
- {
- string weatherImage;
- if (remoteCurrentWeatherData.weather.Count > 0 &&
- remoteCurrentWeatherData.weather[0].icon != null &&
- RemoteImagesTranslation.GetTransaltedImage(remoteCurrentWeatherData.weather[0].icon) != null)
+ string lineFive;
+ if (item.weather.Count > 0 &&
+ item.weather[0].icon != null &&
+ RemoteImagesTranslation.GetTransaltedImage(item.weather[0].icon) != null)
{
- weatherImage = RemoteImagesTranslation.GetTransaltedImage(remoteCurrentWeatherData.weather[0].icon);
+ lineFive = RemoteImagesTranslation.GetTransaltedImage(item.weather[0].icon);
}
else
{
- weatherImage = "weather_severe_alert";
+ lineFive = "weather_severe_alert";
}
- this.CurrentWeatherImagePath = String.Format(CultureInfo.InvariantCulture, "/Images/{0}.png", weatherImage);
- NotifyPropertyChanged("CurrentWeatherImagePath");
- var currentMaxTemp = "";
- if (remoteCurrentWeatherData.main != null)
+ this.ForecastItems.Add(new ItemViewModel()
{
- var conversion = remoteCurrentWeatherData.main.temp_max;
- conversion -= tempUnits;
- currentMaxTemp = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", conversion);
- }
- this.CurrentMaxTemp = currentMaxTemp;
- this.CurrentMaxTempUnits = symbol;
- NotifyPropertyChanged("CurrentMaxTemp");
- NotifyPropertyChanged("CurrentMaxTempUnits");
+ LineOne = lineOne,
+ LineTwo = lineTwo,
+ LineThree = lineThree,
+ LineFour = lineFour,
+ LineFive = String.Format(CultureInfo.InvariantCulture, "/Images/{0}.png", lineFive),
+ });
- var currentMinTemp = "";
- if (remoteCurrentWeatherData.main != null)
+ count--;
+ if (count == 0)
{
- var conversion = remoteCurrentWeatherData.main.temp_min;
- conversion -= tempUnits;
- currentMinTemp = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", conversion);
+ break;
}
- this.CurrentMinTemp = currentMinTemp;
- this.CurrentMinTempUnits = symbol;
- NotifyPropertyChanged("CurrentMinTemp");
- NotifyPropertyChanged("CurrentMinTempUnits");
+ }
+ }
- // TODO: static resource :(
- var currentConditions = "no description available";
- if (remoteCurrentWeatherData.weather.Count > 0)
- {
- currentConditions = remoteCurrentWeatherData.weather[0].description;
- }
- this.CurrentConditions = currentConditions;
- NotifyPropertyChanged("CurrentConditions");
+ private void UpdateCurrentUI(CurrentWeather current, DateTime baseUnixTime, string symbol, double tempUnits)
+ {
+ string weatherImage;
+ if (current.weather.Count > 0 &&
+ current.weather[0].icon != null &&
+ RemoteImagesTranslation.GetTransaltedImage(current.weather[0].icon) != null)
+ {
+ weatherImage = RemoteImagesTranslation.GetTransaltedImage(current.weather[0].icon);
+ }
+ else
+ {
+ weatherImage = "weather_severe_alert";
+ }
+ this.CurrentWeatherImagePath = String.Format(CultureInfo.InvariantCulture, "/Images/{0}.png", weatherImage);
+ NotifyPropertyChanged("CurrentWeatherImagePath");
- this.CurrentFeelsLikeText = AppResources.MainPageCurrentFeelsLike;
- var currentFeelsLikeTemp = "";
- if (remoteCurrentWeatherData.main != null)
- {
- var conversion = remoteCurrentWeatherData.main.temp;
- conversion -= tempUnits;
- currentFeelsLikeTemp = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", conversion);
- }
- this.CurrentFeelsLikeTemp = currentFeelsLikeTemp;
- this.CurrentFeelsLikeTempUnits = symbol;
- NotifyPropertyChanged("CurrentFeelsLikeTemp");
- NotifyPropertyChanged("CurrentFeelsLikeTempUnits");
- NotifyPropertyChanged("CurrentFeelsLikeText");
+ var currentMaxTemp = "";
+ if (current.main != null && current.main.temp_max != null)
+ {
+ var conversion = current.main.temp_max;
+ conversion -= tempUnits;
+ currentMaxTemp = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", conversion);
+ }
+ this.CurrentMaxTemp = currentMaxTemp;
+ this.CurrentMaxTempUnits = symbol;
+ NotifyPropertyChanged("CurrentMaxTemp");
+ NotifyPropertyChanged("CurrentMaxTempUnits");
- this.CurrentHumidityText = AppResources.MainPageCurrentHumidity;
- var currentHumidity = "";
- if (remoteCurrentWeatherData.main != null)
- {
- currentHumidity = remoteCurrentWeatherData.main.humidity.ToString(CultureInfo.InvariantCulture);
- }
- this.CurrentHumidity = currentHumidity;
- this.CurrentHumidityUnits = AppResources.MainPageCurrentHumidityUnits;
- NotifyPropertyChanged("CurrentHumidity");
- NotifyPropertyChanged("CurrentHumidityUnits");
- NotifyPropertyChanged("CurrentHumidityText");
+ var currentMinTemp = "";
+ if (current.main != null && current.main.temp_min != null)
+ {
+ var conversion = current.main.temp_min;
+ conversion -= tempUnits;
+ currentMinTemp = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", conversion);
+ }
+ this.CurrentMinTemp = currentMinTemp;
+ this.CurrentMinTempUnits = symbol;
+ NotifyPropertyChanged("CurrentMinTemp");
+ NotifyPropertyChanged("CurrentMinTempUnits");
- this.CurrentRainText = AppResources.MainPageCurrentRain;
- var currentRain = "";
- if (remoteCurrentWeatherData.rain != null)
- {
- currentRain = remoteCurrentWeatherData.rain.get3h().ToString(CultureInfo.InvariantCulture);
- }
- this.CurrentRain = currentRain;
- this.CurrentRainUnits = AppResources.MainPageCurrentRainUnits;
- NotifyPropertyChanged("CurrentRain");
- NotifyPropertyChanged("CurrentRainUnits");
- NotifyPropertyChanged("CurrentRainText");
+ var currentConditions = AppResources.MainPageCurrentDefaultDescription;
+ if (current.weather.Count > 0 && !String.IsNullOrEmpty(current.weather[0].description))
+ {
+ currentConditions = current.weather[0].description;
+ }
+ this.CurrentConditions = currentConditions;
+ NotifyPropertyChanged("CurrentConditions");
- this.CurrentSnowText = AppResources.MainPageCurrentSnow;
- var currentSnow = "";
- if (remoteCurrentWeatherData.snow != null)
- {
- currentSnow = remoteCurrentWeatherData.snow.get3h().ToString(CultureInfo.InvariantCulture);
- }
- this.CurrentSnow = currentSnow;
- this.CurrentSnowUnits = AppResources.MainPageCurrentSnowUnits;
- NotifyPropertyChanged("CurrentSnow");
- NotifyPropertyChanged("CurrentSnowUnits");
- NotifyPropertyChanged("CurrentSnowText");
+ this.CurrentFeelsLikeText = AppResources.MainPageCurrentFeelsLike;
+ var currentFeelsLikeTemp = "";
+ if (current.main != null && current.main.temp != null)
+ {
+ var conversion = current.main.temp;
+ conversion -= tempUnits;
+ currentFeelsLikeTemp = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", conversion);
+ }
+ this.CurrentFeelsLikeTemp = currentFeelsLikeTemp;
+ this.CurrentFeelsLikeTempUnits = symbol;
+ NotifyPropertyChanged("CurrentFeelsLikeTemp");
+ NotifyPropertyChanged("CurrentFeelsLikeTempUnits");
+ NotifyPropertyChanged("CurrentFeelsLikeText");
- this.CurrentWindText = AppResources.MainPageCurrentWind;
- var currentWind = "";
- if (remoteCurrentWeatherData.wind != null)
- {
- currentWind = remoteCurrentWeatherData.wind.speed.ToString(CultureInfo.InvariantCulture);
- }
- this.CurrentWind = currentWind;
- this.CurrentWindUnits = AppResources.MainPageCurrentWindUnits;
- NotifyPropertyChanged("CurrentWind");
- NotifyPropertyChanged("CurrentWindUnits");
- NotifyPropertyChanged("CurrentWindText");
+ this.CurrentHumidityText = AppResources.MainPageCurrentHumidity;
+ var currentHumidity = "";
+ if (current.main != null && current.main.humidity != null)
+ {
+ currentHumidity = current.main.humidity.Value.ToString(CultureInfo.InvariantCulture);
+ }
+ this.CurrentHumidity = currentHumidity;
+ this.CurrentHumidityUnits = AppResources.MainPageCurrentHumidityUnits;
+ NotifyPropertyChanged("CurrentHumidity");
+ NotifyPropertyChanged("CurrentHumidityUnits");
+ NotifyPropertyChanged("CurrentHumidityText");
- this.CurrentCloudsText = AppResources.MainPageCurrentClouds;
- var currentClouds = "";
- if (remoteCurrentWeatherData.clouds != null)
- {
- currentClouds = remoteCurrentWeatherData.clouds.all.ToString(CultureInfo.InvariantCulture);
- }
- this.CurrentClouds = currentClouds;
- this.CurrentCloudsUnits = AppResources.MainPageCurrentCloudsUnits;
- NotifyPropertyChanged("CurrentClouds");
- NotifyPropertyChanged("CurrentCloudsUnits");
- NotifyPropertyChanged("CurrentCloudsText");
+ this.CurrentRainText = AppResources.MainPageCurrentRain;
+ var currentRain = "";
+ if (current.rain != null && current.rain.get3h() != null)
+ {
+ currentRain = current.rain.get3h().Value.ToString(CultureInfo.InvariantCulture);
+ }
+ this.CurrentRain = currentRain;
+ this.CurrentRainUnits = AppResources.MainPageCurrentRainUnits;
+ NotifyPropertyChanged("CurrentRain");
+ NotifyPropertyChanged("CurrentRainUnits");
+ NotifyPropertyChanged("CurrentRainText");
- this.CurrentPressureText = AppResources.MainPageCurrentPressure;
- var currentPressure = "";
- if (remoteCurrentWeatherData.main != null)
- {
- currentPressure = remoteCurrentWeatherData.main.pressure.ToString(CultureInfo.InvariantCulture);
- }
- this.CurrentPressure = currentPressure;
- this.CurrentPressureUnits = AppResources.MainPageCurrentPressureUnits;
- NotifyPropertyChanged("CurrentPressure");
- NotifyPropertyChanged("CurrentPressureUnits");
- NotifyPropertyChanged("CurrentPressureText");
+ this.CurrentSnowText = AppResources.MainPageCurrentSnow;
+ var currentSnow = "";
+ if (current.snow != null && current.snow.get3h() != null)
+ {
+ currentSnow = current.snow.get3h().Value.ToString(CultureInfo.InvariantCulture);
+ }
+ this.CurrentSnow = currentSnow;
+ this.CurrentSnowUnits = AppResources.MainPageCurrentSnowUnits;
+ NotifyPropertyChanged("CurrentSnow");
+ NotifyPropertyChanged("CurrentSnowUnits");
+ NotifyPropertyChanged("CurrentSnowText");
- this.CurrentSunRiseText = AppResources.MainPageCurrentSunRise;
- var sunRiseTime = unixTime.AddSeconds(remoteCurrentWeatherData.sys.sunrise);
- this.CurrentSunRise = sunRiseTime.ToString("MM/dd/yy H:mm:ss", CultureInfo.InvariantCulture);
- NotifyPropertyChanged("CurrentSunRise");
- NotifyPropertyChanged("CurrentSunRiseText");
+ this.CurrentWindText = AppResources.MainPageCurrentWind;
+ var currentWind = "";
+ if (current.wind != null && current.wind.speed != null)
+ {
+ currentWind = current.wind.speed.Value.ToString(CultureInfo.InvariantCulture);
+ }
+ this.CurrentWind = currentWind;
+ this.CurrentWindUnits = AppResources.MainPageCurrentWindUnits;
+ NotifyPropertyChanged("CurrentWind");
+ NotifyPropertyChanged("CurrentWindUnits");
+ NotifyPropertyChanged("CurrentWindText");
+
+ this.CurrentCloudsText = AppResources.MainPageCurrentClouds;
+ var currentClouds = "";
+ if (current.clouds != null && current.clouds.all != null)
+ {
+ currentClouds = current.clouds.all.Value.ToString(CultureInfo.InvariantCulture);
+ }
+ this.CurrentClouds = currentClouds;
+ this.CurrentCloudsUnits = AppResources.MainPageCurrentCloudsUnits;
+ NotifyPropertyChanged("CurrentClouds");
+ NotifyPropertyChanged("CurrentCloudsUnits");
+ NotifyPropertyChanged("CurrentCloudsText");
+
+ this.CurrentPressureText = AppResources.MainPageCurrentPressure;
+ var currentPressure = "";
+ if (current.main != null && current.main.pressure != null)
+ {
+ currentPressure = current.main.pressure.Value.ToString(CultureInfo.InvariantCulture);
+ }
+ this.CurrentPressure = currentPressure;
+ this.CurrentPressureUnits = AppResources.MainPageCurrentPressureUnits;
+ NotifyPropertyChanged("CurrentPressure");
+ NotifyPropertyChanged("CurrentPressureUnits");
+ NotifyPropertyChanged("CurrentPressureText");
- this.CurrentSunSetText = AppResources.MainPageCurrentSunSet;
- var sunSetTime = unixTime.AddSeconds(remoteCurrentWeatherData.sys.sunset);
- this.CurrentSunSet = sunSetTime.ToString("MM/dd/yy H:mm:ss", CultureInfo.InvariantCulture);
- NotifyPropertyChanged("CurrentSunSet");
- NotifyPropertyChanged("CurrentSunSetText");
+ this.CurrentSunRiseText = AppResources.MainPageCurrentSunRise;
+ string sunRise = "";
+ if (current.sys.sunrise != null)
+ {
+ var sunRiseTime = baseUnixTime.AddSeconds(current.sys.sunrise.Value);
+ sunRise = sunRiseTime.ToString("MM/dd/yy H:mm:ss", CultureInfo.InvariantCulture);
+ }
+ this.CurrentSunRise = sunRise;
+ NotifyPropertyChanged("CurrentSunRise");
+ NotifyPropertyChanged("CurrentSunRiseText");
- string country = weatherData.Country;
- string city = weatherData.City;
- string cityCountry = String.Format(CultureInfo.InvariantCulture, "{0}, {1}", city, country);
- this.TitleTextCityCountry = cityCountry;
- NotifyPropertyChanged("TitleTextCityCountry");
+ this.CurrentSunSetText = AppResources.MainPageCurrentSunSet;
+ string sunSet = "";
+ if (current.sys.sunset != null)
+ {
+ var sunSetTime = baseUnixTime.AddSeconds(current.sys.sunset.Value);
+ sunSet = sunSetTime.ToString("MM/dd/yy H:mm:ss", CultureInfo.InvariantCulture);
}
+ this.CurrentSunSet = sunSet;
+ NotifyPropertyChanged("CurrentSunSet");
+ NotifyPropertyChanged("CurrentSunSetText");
}
public event PropertyChangedEventHandler PropertyChanged;
var remoteForecastWeatherData = weatherData.Forecast;
WeatherInformation.Model.ForecastWeatherParser.List forecast = remoteForecastWeatherData.list[index];
- DateTime unixTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
- DateTime date = unixTime.AddSeconds(forecast.dt).ToLocalTime();
- this.SelectedDate = date.ToString("m", CultureInfo.InvariantCulture);
+ DateTime baseUnixTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+ string selectedDate = "";
+ if (forecast.dt != null)
+ {
+ var date = baseUnixTime.AddSeconds(forecast.dt.Value).ToLocalTime();
+ selectedDate = date.ToString("m", CultureInfo.InvariantCulture);
+ }
+ this.SelectedDate = selectedDate;
NotifyPropertyChanged("SelectedDate");
bool isFahrenheit = true;
var selectedDateMaxTemp = "";
var selectedDateTempUnits = "";
- if (forecast.temp != null)
+ if (forecast.temp != null && forecast.temp.max != null)
{
var conversion = forecast.temp.max;
conversion -= tempUnits;
var selectedDateMinTemp = "";
selectedDateTempUnits = "";
- if (forecast.temp != null)
+ if (forecast.temp != null && forecast.temp.min != null)
{
var conversion = forecast.temp.min;
conversion -= tempUnits;
this.SelectedDateMaxTempUnits = selectedDateTempUnits;
NotifyPropertyChanged("SelectedDateMinTempUnits");
- // TODO: static resource :(
- var selectedDateConditions = "no description available";
- if (forecast.weather.Count > 0)
+ var selectedDateConditions = AppResources.SelectedDatePageDefaultDescription;
+ if (forecast.weather.Count > 0 && !String.IsNullOrEmpty(forecast.weather[0].description))
{
selectedDateConditions = forecast.weather[0].description;
}
this.SelectedDateConditions = selectedDateConditions;
NotifyPropertyChanged("SelectedDateConditions");
- // TODO: nullables para distinguir cuando hay datos o no. Ahora me llega 0 si no datos (supongo) cuando double/integer
this.SelectedDateHumidityText = AppResources.MainPageCurrentHumidity;
- this.SelectedDateHumidity = forecast.humidity.ToString(CultureInfo.InvariantCulture);
+ var selectedDateHumidity = "";
+ if (forecast.humidity != null)
+ {
+ selectedDateHumidity = forecast.humidity.Value.ToString(CultureInfo.InvariantCulture);
+ }
+ this.SelectedDateHumidity = selectedDateHumidity;
this.SelectedDateHumidityUnits = AppResources.MainPageCurrentHumidityUnits;
NotifyPropertyChanged("SelectedDateHumidity");
NotifyPropertyChanged("SelectedDateHumidityUnits");
NotifyPropertyChanged("SelectedDateHumidityText");
this.SelectedDateRainText = AppResources.MainPageCurrentRain;
- this.SelectedDateRain = forecast.rain.ToString(CultureInfo.InvariantCulture);
+ var selectedDateRain = "";
+ if (forecast.rain != null)
+ {
+ selectedDateRain = forecast.rain.Value.ToString(CultureInfo.InvariantCulture);
+ }
+ this.SelectedDateRain = selectedDateRain;
this.SelectedDateRainUnits = AppResources.MainPageCurrentRainUnits;
NotifyPropertyChanged("SelectedDateRain");
NotifyPropertyChanged("SelectedDateRainUnits");
NotifyPropertyChanged("SelectedDateRainText");
this.SelectedDateWindText = AppResources.MainPageCurrentWind;
- this.SelectedDateWind = forecast.speed.ToString(CultureInfo.InvariantCulture);
+ var selectedDateSpeed = "";
+ if (forecast.speed != null)
+ {
+ selectedDateSpeed = forecast.speed.Value.ToString(CultureInfo.InvariantCulture);
+ }
+ this.SelectedDateWind = selectedDateSpeed;
this.SelectedDateWindUnits = AppResources.MainPageCurrentWindUnits;
NotifyPropertyChanged("SelectedDateWind");
NotifyPropertyChanged("SelectedDateWindUnits");
NotifyPropertyChanged("SelectedDateWindText");
this.SelectedDateCloudsText = AppResources.MainPageCurrentClouds;
- this.SelectedDateClouds = forecast.clouds.ToString(CultureInfo.InvariantCulture);
+ var selectedDateClouds = "";
+ if (forecast.clouds != null)
+ {
+ selectedDateClouds = forecast.clouds.Value.ToString(CultureInfo.InvariantCulture);
+ }
+ this.SelectedDateClouds = selectedDateClouds;
this.SelectedDateCloudsUnits = AppResources.MainPageCurrentCloudsUnits;
NotifyPropertyChanged("SelectedDateClouds");
NotifyPropertyChanged("SelectedDateCloudsUnits");
NotifyPropertyChanged("SelectedDateCloudsText");
this.SelectedDatePressureText = AppResources.MainPageCurrentPressure;
- this.SelectedDatePressure = forecast.pressure.ToString(CultureInfo.InvariantCulture);
+ var selectedDatePressure = "";
+ if (forecast.pressure != null)
+ {
+ selectedDatePressure = forecast.pressure.Value.ToString(CultureInfo.InvariantCulture);
+ }
+ this.SelectedDatePressure = selectedDatePressure;
this.SelectedDatePressureUnits = AppResources.MainPageCurrentPressureUnits;
NotifyPropertyChanged("SelectedDatePressure");
NotifyPropertyChanged("SelectedDatePressureUnits");