TimeSinceLastSave = DateTime.Now - dataLastSaveTime;
}
- if (!IsNewLocation)
+ if (TimeSinceLastSave.TotalSeconds < 30 && !IsNewLocation)
{
- // Check to see if data exists in isolated storage and see if the data is fresh.
- // This example uses 30 seconds as the valid time window to make it easy to test.
- // Real apps will use a larger window.
- using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
+ GetStoredData();
+ }
+ else
+ {
+ // Otherwise, it gets the data from the web.
+ var task = LoadDataAsync();
+ try
+ {
+ // TODO: I guess, I may do this because this code is running in a new thread :/ Better alternative just using async? WIP :(
+ // Using Task.WhenAll to avoid deadlock :)
+ Task.WhenAll(task);
+ }
+ catch (Exception ex)
{
- if (isoStore.FileExists("JSONDataFile.txt") && TimeSinceLastSave.TotalSeconds < 30)
+ // If the data request fails, alert the user.
+ ApplicationDataObject = new WeatherData
{
- using (StreamReader sr = new StreamReader(isoStore.OpenFile("JSONDataFile.txt", FileMode.Open)))
- {
- // This method loads the data from isolated storage, if it is available.
- // TODO: qué pasa si JSONRemoteForecastWeatherData o JSONRemoteCurrentWeatherData son null?
- string JSONRemoteForecastWeatherData = sr.ReadLine();
- string JSONRemoteCurrentWeatherData = sr.ReadLine();
- var weatherData = WeatherParser(JSONRemoteForecastWeatherData, JSONRemoteCurrentWeatherData);
- weatherData.JSONRemoteForecastWeatherData = JSONRemoteForecastWeatherData;
- weatherData.JSONRemoteCurrentWeatherData = JSONRemoteCurrentWeatherData;
- weatherData.WasThereRemoteError = false;
- ApplicationDataObject = weatherData;
- }
-
- // TODO: write more methods or something else to avoid nested returns like this... no time right now... :(
- return;
+ RemoteForecastWeatherData = null,
+ RemoteCurrentWeatherData = null,
+ JSONRemoteForecastWeatherData = null,
+ JSONRemoteCurrentWeatherData = null,
+ WasThereRemoteError = true
+ };
+ }
+ }
+ }
+
+ private void GetStoredData()
+ {
+ // Check to see if data exists in isolated storage and see if the data is fresh.
+ // This example uses 30 seconds as the valid time window to make it easy to test.
+ // Real apps will use a larger window.
+
+ string JSONRemoteCurrentWeather = null;
+ string JSONRemoteForecastWeather = null;
+
+ using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
+ {
+ if (isoStore.FileExists("JSONRemoteCurrentWeatherDataFile.txt"))
+ {
+ using (StreamReader sr = new StreamReader(isoStore.OpenFile("JSONRemoteCurrentWeatherDataFile.txt", FileMode.Open)))
+ {
+ // This method loads the data from isolated storage, if it is available.
+ JSONRemoteCurrentWeather = sr.ReadLine();
+ }
+ }
+
+
+ if (isoStore.FileExists("JSONRemoteForecastWeatherDataFile.txt"))
+ {
+ using (StreamReader sr = new StreamReader(isoStore.OpenFile("JSONRemoteForecastWeatherDataFile.txt", FileMode.Open)))
+ {
+ // This method loads the data from isolated storage, if it is available.
+ JSONRemoteForecastWeather = sr.ReadLine();
}
}
}
-
- // Otherwise, it gets the data from the web.
- var task = LoadDataAsync();
- try
+ if (!string.IsNullOrEmpty(JSONRemoteCurrentWeather) && !string.IsNullOrEmpty(JSONRemoteForecastWeather))
{
- // TODO: I guess, I may do this because this code is running in a new thread :/ Better alternative just using async? WIP :(
- // Using Task.WhenAll to avoid deadlock :)
- Task.WhenAll(task);
+ ApplicationDataObject = WeatherDataParser(JSONRemoteForecastWeather, JSONRemoteCurrentWeather);
}
- catch (Exception ex)
- {
- // If the data request fails, alert the user.
- ApplicationDataObject = new WeatherData
- {
- RemoteForecastWeatherData = null,
- RemoteCurrentWeatherData = null,
- JSONRemoteForecastWeatherData = null,
- JSONRemoteCurrentWeatherData = null,
- WasThereRemoteError = true
- };
- }
}
/// <summary>
CultureInfo.InvariantCulture, AppResources.URIAPIOpenWeatherMapForecast,
AppResources.APIVersionOpenWeatherMap, (double)IsolatedStorageSettings.ApplicationSettings["CurrentLatitude"],
(double)IsolatedStorageSettings.ApplicationSettings["CurrentLongitude"], resultsNumber);
- string JSONRemoteForecastWeatherData = await httpClient.GetWeatherDataAsync(formattedForecastURL);
+ string JSONRemoteForecastWeather = await httpClient.GetWeatherDataAsync(formattedForecastURL);
string formattedCurrentURL = String.Format(
CultureInfo.InvariantCulture, AppResources.URIAPIOpenWeatherMapCurrent,
AppResources.APIVersionOpenWeatherMap, (double)IsolatedStorageSettings.ApplicationSettings["CurrentLatitude"],
(double)IsolatedStorageSettings.ApplicationSettings["CurrentLongitude"], resultsNumber);
- string JSONRemoteCurrentWeatherData = await httpClient.GetWeatherDataAsync(formattedCurrentURL);
+ string JSONRemoteCurrentWeather = await httpClient.GetWeatherDataAsync(formattedCurrentURL);
- var weatherData = WeatherParser(JSONRemoteForecastWeatherData, JSONRemoteCurrentWeatherData);
- weatherData.WasThereRemoteError = false;
- weatherData.JSONRemoteForecastWeatherData = JSONRemoteForecastWeatherData;
- weatherData.JSONRemoteCurrentWeatherData = JSONRemoteCurrentWeatherData;
- ApplicationDataObject = weatherData;
+ ApplicationDataObject = WeatherDataParser(JSONRemoteForecastWeather, JSONRemoteCurrentWeather);
}
+ private ForecastWeather ForecastWeatherParser(string remoteForecastWeatherData)
+ {
+ ServiceParser parser = new ServiceParser(new JsonParser());
+ return parser.GetForecastWeather(remoteForecastWeatherData);
+ }
- private WeatherData WeatherParser(string remoteForecastWeatherData, string remoteCurrentWeatherData)
+ private CurrentWeather CurrentWeatherParser(string remoteCurrentWeatherData)
{
ServiceParser parser = new ServiceParser(new JsonParser());
- ForecastWeather remoteForecastWeather = parser.GetForecastWeather(remoteForecastWeatherData);
- CurrentWeather remoteCurrentWeather = parser.GetCurrentWeather(remoteCurrentWeatherData);
+ return parser.GetCurrentWeather(remoteCurrentWeatherData);
+ }
+
+ private WeatherData WeatherDataParser(string JSONRemoteForecastWeather, string JSONRemoteCurrentWeather)
+ {
+ ForecastWeather forecastWeather = null;
+ if (!string.IsNullOrEmpty(JSONRemoteForecastWeather))
+ {
+ forecastWeather = ForecastWeatherParser(JSONRemoteForecastWeather);
+ }
+
+ CurrentWeather currentWeather = null;
+ if (!string.IsNullOrEmpty(JSONRemoteCurrentWeather))
+ {
+ currentWeather = CurrentWeatherParser(JSONRemoteCurrentWeather);
+ }
+
return new WeatherData
{
- RemoteForecastWeatherData = remoteForecastWeather,
- RemoteCurrentWeatherData = remoteCurrentWeather
+ JSONRemoteCurrentWeatherData = JSONRemoteCurrentWeather,
+ JSONRemoteForecastWeatherData = JSONRemoteForecastWeather,
+ RemoteCurrentWeatherData = currentWeather,
+ RemoteForecastWeatherData = forecastWeather,
+ WasThereRemoteError = false
};
}
// TODO: temporary file :/
- private void SaveDataToIsolatedStorage(string isoFileName, WeatherData value)
+ private void SaveDataToIsolatedStorage(string isoFileName, string value)
{
- if (string.IsNullOrEmpty(value.JSONRemoteForecastWeatherData))
- {
- return;
- }
-
using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
using (IsolatedStorageFileStream fileStream = isoStore.OpenFile(isoFileName, FileMode.OpenOrCreate))
using (StreamWriter sw = new StreamWriter(fileStream))
{
- // TODO: qué pasa si JSONRemoteForecastWeatherData o JSONRemoteCurrentWeatherData son null?
- sw.Write(value.JSONRemoteForecastWeatherData);
- sw.Write(value.JSONRemoteCurrentWeatherData);
+ sw.Write(value);
fileStream.Flush(true);
}
// Coming from TOMBSTONED
// Check to see if the key for the application state data is in the State dictionary.
- string JSONRemoteForecastWeatherData = null;
+ string JSONRemoteForecastWeather = null;
if (PhoneApplicationService.Current.State.ContainsKey("JSONRemoteForecastWeatherData"))
{
// If it exists, assign the data to the application member variable.
- JSONRemoteForecastWeatherData = PhoneApplicationService.Current.State["JSONRemoteForecastWeatherData"] as string;
+ JSONRemoteForecastWeather = PhoneApplicationService.Current.State["JSONRemoteForecastWeatherData"] as string;
}
- string JSONRemoteCurrentWeatherData = null;
+ string JSONRemoteCurrentWeather = null;
if (PhoneApplicationService.Current.State.ContainsKey("JSONRemoteCurrentWeatherData"))
{
// If it exists, assign the data to the application member variable.
- JSONRemoteCurrentWeatherData = PhoneApplicationService.Current.State["JSONRemoteCurrentWeatherData"] as string;
+ JSONRemoteCurrentWeather = PhoneApplicationService.Current.State["JSONRemoteCurrentWeatherData"] as string;
}
- // TODO: qué pasa si JSONRemoteForecastWeatherData o JSONRemoteCurrentWeatherData son null?
- var weatherData = WeatherParser(JSONRemoteForecastWeatherData, JSONRemoteCurrentWeatherData);
- weatherData.JSONRemoteForecastWeatherData = JSONRemoteForecastWeatherData;
- weatherData.JSONRemoteCurrentWeatherData = JSONRemoteCurrentWeatherData;
- weatherData.WasThereRemoteError = false;
- ApplicationDataObject = weatherData;
+
+ ApplicationDataObject = WeatherDataParser(JSONRemoteForecastWeather, JSONRemoteCurrentWeather);
if (PhoneApplicationService.Current.State.ContainsKey("IsNewLocation"))
{
if (!string.IsNullOrEmpty(weatherData.JSONRemoteForecastWeatherData))
{
// Store it in the State dictionary.
- PhoneApplicationService.Current.State["JSONRemoteForecastWeatherData"] = weatherData.JSONRemoteForecastWeatherData;
+ PhoneApplicationService.Current.State["JSONRemoteForecastWeatherData"] = weatherData.JSONRemoteForecastWeatherData;
+
+ // Also store it in isolated storage, in case the application is never reactivated.
+ SaveDataToIsolatedStorage("JSONRemoteForecastWeatherDataFile.txt", weatherData.JSONRemoteForecastWeatherData);
}
if (!string.IsNullOrEmpty(weatherData.JSONRemoteCurrentWeatherData))
{
// Store it in the State dictionary.
PhoneApplicationService.Current.State["JSONRemoteCurrentWeatherData"] = weatherData.JSONRemoteCurrentWeatherData;
+
+ // Also store it in isolated storage, in case the application is never reactivated.
+ SaveDataToIsolatedStorage("JSONRemoteCurrentWeatherDataFile.txt", weatherData.JSONRemoteCurrentWeatherData);
}
- PhoneApplicationService.Current.State["IsNewLocation"] = IsNewLocation;
- // Also store it in isolated storage, in case the application is never reactivated.
- SaveDataToIsolatedStorage("JSONDataFile.txt", weatherData);
+ PhoneApplicationService.Current.State["IsNewLocation"] = IsNewLocation;
}
}
var weatherData = ApplicationDataObject;
if (weatherData != null)
{
- SaveDataToIsolatedStorage("JSONDataFile.txt", weatherData);
+ if (!string.IsNullOrEmpty(weatherData.JSONRemoteForecastWeatherData))
+ {
+ // Also store it in isolated storage, in case the application is never reactivated.
+ SaveDataToIsolatedStorage("JSONRemoteForecastWeatherDataFile.txt", weatherData.JSONRemoteForecastWeatherData);
+ }
+ if (!string.IsNullOrEmpty(weatherData.JSONRemoteCurrentWeatherData))
+ {
+ // Also store it in isolated storage, in case the application is never reactivated.
+ SaveDataToIsolatedStorage("JSONRemoteCurrentWeatherDataFile.txt", weatherData.JSONRemoteCurrentWeatherData);
+ }
}
}
}
double tempUnits = isFahrenheit ? 0 : 273.15;
string symbol = isFahrenheit ? AppResources.TemperatureUnitsFahrenheitSymbol : AppResources.TemperatureUnitsCentigradeSymbol;
- var remoteForecastWeatherData = weatherData.RemoteForecastWeatherData;
- this.ForecastItems.Clear();
DateTime unixTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
- foreach (WeatherInformation.Model.ForecastWeatherParser.List item in remoteForecastWeatherData.list)
- {
- DateTime date = unixTime.AddSeconds(item.dt).ToLocalTime();
-
- // 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;
- maxTemp = maxTemp - tempUnits;
- double minTemp = item.temp.min;
- minTemp = minTemp - tempUnits;
-
- 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 = "/Assets/Tiles/IconicTileMediumLarge.png"
- });
-
- count--;
- if (count == 0)
+ var remoteForecastWeatherData = weatherData.RemoteForecastWeatherData;
+ if (remoteForecastWeatherData != null)
+ {
+ this.ForecastItems.Clear();
+
+ foreach (WeatherInformation.Model.ForecastWeatherParser.List item in remoteForecastWeatherData.list)
{
- break;
+ DateTime date = unixTime.AddSeconds(item.dt).ToLocalTime();
+
+ // 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;
+ maxTemp = maxTemp - tempUnits;
+
+ double minTemp = item.temp.min;
+ minTemp = minTemp - tempUnits;
+
+ 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 = "/Assets/Tiles/IconicTileMediumLarge.png"
+ });
+
+ count--;
+ if (count == 0)
+ {
+ break;
+ }
}
}
// TODO: nullables para distinguir cuando hay datos o no. Ahora me llega 0 si no datos (supongo) cuando double/integer
var remoteCurrentWeatherData = weatherData.RemoteCurrentWeatherData;
-
- var currentMaxTemp = "";
- if (remoteCurrentWeatherData.main != null)
+ if (remoteCurrentWeatherData != null)
{
- 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");
+ var currentMaxTemp = "";
+ if (remoteCurrentWeatherData.main != null)
+ {
+ 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");
- var currentMinTemp = "";
- if (remoteCurrentWeatherData.main != null)
- {
- var conversion = remoteCurrentWeatherData.main.temp_min;
- conversion -= tempUnits;
- currentMinTemp = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", conversion);
- }
- 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");
+ var currentMinTemp = "";
+ if (remoteCurrentWeatherData.main != null)
+ {
+ var conversion = remoteCurrentWeatherData.main.temp_min;
+ conversion -= tempUnits;
+ currentMinTemp = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", conversion);
+ }
+ 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");
- 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");
-
- 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");
-
- 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");
-
- 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.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.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.CurrentPressureText = AppResources.MainPageCurrentPressure;
- var currentPressure = "";
- if (remoteCurrentWeatherData.main != null)
- {
- currentPressure = remoteCurrentWeatherData.main.pressure.ToString(CultureInfo.InvariantCulture);
+ 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");
+
+ 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");
+
+ 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");
+
+ 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.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.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.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.CurrentSunRiseText = AppResources.MainPageCurrentSunRise;
+ var sunRiseTime = unixTime.AddSeconds(remoteCurrentWeatherData.sys.sunrise).ToLocalTime();
+ this.CurrentSunRise = sunRiseTime.ToString("MM/dd/yy H:mm:ss", CultureInfo.InvariantCulture);
+ NotifyPropertyChanged("CurrentSunRise");
+ NotifyPropertyChanged("CurrentSunRiseText");
+
+ this.CurrentSunSetText = AppResources.MainPageCurrentSunSet;
+ var sunSetTime = unixTime.AddSeconds(remoteCurrentWeatherData.sys.sunset).ToLocalTime();
+ this.CurrentSunSet = sunSetTime.ToString("MM/dd/yy H:mm:ss", CultureInfo.InvariantCulture);
+ NotifyPropertyChanged("CurrentSunSet");
+ NotifyPropertyChanged("CurrentSunSetText");
}
- this.CurrentPressure = currentPressure;
- this.CurrentPressureUnits = AppResources.MainPageCurrentPressureUnits;
- NotifyPropertyChanged("CurrentPressure");
- NotifyPropertyChanged("CurrentPressureUnits");
- NotifyPropertyChanged("CurrentPressureText");
-
- this.CurrentSunRiseText = AppResources.MainPageCurrentSunRise;
- var sunRiseTime = unixTime.AddSeconds(remoteCurrentWeatherData.sys.sunrise).ToLocalTime();
- this.CurrentSunRise = sunRiseTime.ToString("MM/dd/yy H:mm:ss", CultureInfo.InvariantCulture);
- NotifyPropertyChanged("CurrentSunRise");
- NotifyPropertyChanged("CurrentSunRiseText");
-
- this.CurrentSunSetText = AppResources.MainPageCurrentSunSet;
- var sunSetTime = unixTime.AddSeconds(remoteCurrentWeatherData.sys.sunset).ToLocalTime();
- this.CurrentSunSet = sunSetTime.ToString("MM/dd/yy H:mm:ss", CultureInfo.InvariantCulture);
- NotifyPropertyChanged("CurrentSunSet");
- NotifyPropertyChanged("CurrentSunSetText");
+
}
public bool IsThereCurrentLocation()