From 03aea957d2addf1d003409687c399058336a375a Mon Sep 17 00:00:00 2001 From: "gu.martinm@gmail.com" Date: Mon, 28 Jul 2014 02:41:05 +0200 Subject: [PATCH] WeatherInformation: SelectedDatePage --- .../WeatherInformation/App.xaml.cs | 33 +++- .../WeatherInformation/MainPage.xaml | 2 +- .../WeatherInformation/MainPage.xaml.cs | 7 + .../Model/Services/CustomHTTPClient.cs | 1 + .../Resources/AppResources.Designer.cs | 36 ++++ .../Resources/AppResources.es.xlf | 20 +- .../Resources/AppResources.qps-ploc.xlf | 16 ++ .../WeatherInformation/Resources/AppResources.resx | 12 ++ .../SelectedDateViewModelSampleData.xaml | 35 ++++ .../WeatherInformation/SelectedDatePage.xaml | 138 +++++++++++++ .../WeatherInformation/SelectedDatePage.xaml.cs | 72 +++++++ .../WeatherInformation/ViewModels/MainViewModel.cs | 2 + .../ViewModels/SelectedDateViewModel.cs | 217 +++++++++++++++++++++ .../WeatherInformation/WeatherInformation.csproj | 13 +- 14 files changed, 591 insertions(+), 13 deletions(-) create mode 100644 WindowsPhone/WeatherInformation/WeatherInformation/SampleData/SelectedDateViewModelSampleData.xaml create mode 100644 WindowsPhone/WeatherInformation/WeatherInformation/SelectedDatePage.xaml create mode 100644 WindowsPhone/WeatherInformation/WeatherInformation/SelectedDatePage.xaml.cs create mode 100644 WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/SelectedDateViewModel.cs diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/App.xaml.cs b/WindowsPhone/WeatherInformation/WeatherInformation/App.xaml.cs index a0fe39e..03f213d 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/App.xaml.cs +++ b/WindowsPhone/WeatherInformation/WeatherInformation/App.xaml.cs @@ -154,6 +154,7 @@ namespace WeatherInformation 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); @@ -244,6 +245,7 @@ namespace WeatherInformation 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); fileStream.Flush(true); @@ -273,20 +275,28 @@ namespace WeatherInformation // Coming from TOMBSTONED // Check to see if the key for the application state data is in the State dictionary. + string JSONRemoteForecastWeatherData = null; if (PhoneApplicationService.Current.State.ContainsKey("JSONRemoteForecastWeatherData")) { // If it exists, assign the data to the application member variable. - string JSONRemoteForecastWeatherData = PhoneApplicationService.Current.State["JSONRemoteForecastWeatherData"] as string; - // string remoteCurrentWeatherData = sr.ReadLine(); - var weatherData = WeatherParser(JSONRemoteForecastWeatherData, null); - weatherData.JSONRemoteForecastWeatherData = JSONRemoteForecastWeatherData; - weatherData.JSONRemoteCurrentWeatherData = null; - weatherData.WasThereRemoteError = false; - ApplicationDataObject = weatherData; + JSONRemoteForecastWeatherData = PhoneApplicationService.Current.State["JSONRemoteForecastWeatherData"] as string; } + string JSONRemoteCurrentWeatherData = 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; + } + // 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; + if (PhoneApplicationService.Current.State.ContainsKey("IsNewLocation")) { - IsNewLocation = (bool)IsolatedStorageSettings.ApplicationSettings["IsNewLocation"]; + IsNewLocation = (bool)PhoneApplicationService.Current.State["IsNewLocation"]; } } @@ -301,7 +311,12 @@ namespace WeatherInformation if (!string.IsNullOrEmpty(weatherData.JSONRemoteForecastWeatherData)) { // Store it in the State dictionary. - PhoneApplicationService.Current.State["JSONRemoteForecastWeatherData"] = weatherData.JSONRemoteForecastWeatherData; + PhoneApplicationService.Current.State["JSONRemoteForecastWeatherData"] = weatherData.JSONRemoteForecastWeatherData; + } + if (!string.IsNullOrEmpty(weatherData.JSONRemoteCurrentWeatherData)) + { + // Store it in the State dictionary. + PhoneApplicationService.Current.State["JSONRemoteCurrentWeatherData"] = weatherData.JSONRemoteCurrentWeatherData; } PhoneApplicationService.Current.State["IsNewLocation"] = IsNewLocation; diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml b/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml index f72410f..e430365 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml +++ b/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml @@ -144,7 +144,7 @@ - + diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml.cs b/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml.cs index d98b2b9..ad40048 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml.cs +++ b/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml.cs @@ -7,6 +7,7 @@ using System.Windows.Controls; using System.Windows.Navigation; using WeatherInformation.Model; using WeatherInformation.Resources; +using WeatherInformation.ViewModels; namespace WeatherInformation { @@ -138,7 +139,13 @@ namespace WeatherInformation private void LongListSelector_SelectionChanged(object sender, SelectionChangedEventArgs e) { + LongListSelector longListSelector = sender as LongListSelector; + // TODO: with LINQ :( + ItemViewModel element = longListSelector.SelectedItem as ItemViewModel; + int index = longListSelector.ItemsSource.IndexOf(element); + String uri = string.Format(CultureInfo.InvariantCulture, "/SelectedDatePage.xaml?parameter={0}", index); + NavigationService.Navigate(new Uri(uri, UriKind.Relative)); } private void Location_Click(object sender, EventArgs e) diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/Model/Services/CustomHTTPClient.cs b/WindowsPhone/WeatherInformation/WeatherInformation/Model/Services/CustomHTTPClient.cs index 42ba9a3..c9c2bef 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/Model/Services/CustomHTTPClient.cs +++ b/WindowsPhone/WeatherInformation/WeatherInformation/Model/Services/CustomHTTPClient.cs @@ -22,6 +22,7 @@ namespace WeatherInformation.Model.Services HttpRequestHeaders headers = client.DefaultRequestHeaders; headers.IfModifiedSince = DateTime.UtcNow; + // TODO: THIS IS FUCKED UP. IT IS WORKING RANDOMLY... THE MOST OF THE TIMES IT STOPS HERE FOREVER... string jsonData = await client.GetStringAsync(url); return jsonData; diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.Designer.cs b/WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.Designer.cs index 9118bb7..9598fb4 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.Designer.cs +++ b/WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.Designer.cs @@ -331,6 +331,42 @@ namespace WeatherInformation.Resources { } /// + /// Busca una cadena traducida similar a DAY. + /// + public static string SelectedDatePageDay { + get { + return ResourceManager.GetString("SelectedDatePageDay", resourceCulture); + } + } + + /// + /// Busca una cadena traducida similar a EVENING. + /// + public static string SelectedDatePageEvening { + get { + return ResourceManager.GetString("SelectedDatePageEvening", resourceCulture); + } + } + + /// + /// Busca una cadena traducida similar a MORNING. + /// + public static string SelectedDatePageMorning { + get { + return ResourceManager.GetString("SelectedDatePageMorning", resourceCulture); + } + } + + /// + /// Busca una cadena traducida similar a NIGHT. + /// + public static string SelectedDatePageNight { + get { + return ResourceManager.GetString("SelectedDatePageNight", resourceCulture); + } + } + + /// /// Busca una cadena traducida similar a Forecast day numbers. /// public static string SettingsForecastDayNumbersHeader { diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.es.xlf b/WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.es.xlf index 8ac4022..314a1a1 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.es.xlf +++ b/WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.es.xlf @@ -139,6 +139,22 @@ hpa hpa Not to be translated. + + + NIGHT + NOCHE + + + MORNING + MAÑANA + + + EVENING + TARDE + + + DAY + DÍA mm 3h @@ -152,12 +168,12 @@ % % Not to be translated. - + % % Not to be translated. - + SUN SET SOL SE PONE diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.qps-ploc.xlf b/WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.qps-ploc.xlf index 1aa0c42..6b8c906 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.qps-ploc.xlf +++ b/WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.qps-ploc.xlf @@ -125,6 +125,22 @@ hpa Not to be translated. + + NIGHT + NIGHT + + + MORNING + MORNING + + + EVENING + EVENING + + + DAY + DAY + mm 3h mm 3h diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.resx b/WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.resx index 62525d9..ce474c5 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.resx +++ b/WindowsPhone/WeatherInformation/WeatherInformation/Resources/AppResources.resx @@ -280,4 +280,16 @@ hpa Not to be translated. + + DAY + + + EVENING + + + MORNING + + + NIGHT + \ No newline at end of file diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/SampleData/SelectedDateViewModelSampleData.xaml b/WindowsPhone/WeatherInformation/WeatherInformation/SampleData/SelectedDateViewModelSampleData.xaml new file mode 100644 index 0000000..30098de --- /dev/null +++ b/WindowsPhone/WeatherInformation/WeatherInformation/SampleData/SelectedDateViewModelSampleData.xaml @@ -0,0 +1,35 @@ + diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/SelectedDatePage.xaml b/WindowsPhone/WeatherInformation/WeatherInformation/SelectedDatePage.xaml new file mode 100644 index 0000000..124fbfb --- /dev/null +++ b/WindowsPhone/WeatherInformation/WeatherInformation/SelectedDatePage.xaml @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/SelectedDatePage.xaml.cs b/WindowsPhone/WeatherInformation/WeatherInformation/SelectedDatePage.xaml.cs new file mode 100644 index 0000000..132581a --- /dev/null +++ b/WindowsPhone/WeatherInformation/WeatherInformation/SelectedDatePage.xaml.cs @@ -0,0 +1,72 @@ +using Microsoft.Phone.Controls; +using System; +using System.Globalization; +using System.IO.IsolatedStorage; +using System.Windows; +using WeatherInformation.Model; +using WeatherInformation.Resources; +using WeatherInformation.ViewModels; + +namespace WeatherInformation +{ + public partial class SelectedDate : PhoneApplicationPage + { + SelectedDateViewModel _selectedDateViewModel; + bool _isNewPageInstance = false; + + public SelectedDate() + { + InitializeComponent(); + + _isNewPageInstance = true; + } + + protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) + { + base.OnNavigatedTo(e); + + // If _isNewPageInstance is true, the page constuctor has been called, so + // state may need to be restored. + if (_isNewPageInstance) + { + if (_selectedDateViewModel == null) + { + _selectedDateViewModel = new SelectedDateViewModel(); + // I always receive my parameter even if page was tombstoned. :) + string stringIndex = NavigationContext.QueryString["parameter"]; + _selectedDateViewModel.SelectedDateIndex = Convert.ToInt32(stringIndex, CultureInfo.InvariantCulture); + } + + DataContext = _selectedDateViewModel; + } + // Set _isNewPageInstance to false. If the user navigates back to this page + // and it has remained in memory, this value will continue to be false. + _isNewPageInstance = false; + + UpdateApplicationDataUI(); + } + + void UpdateApplicationDataUI() + { + WeatherData weatherData = (Application.Current as WeatherInformation.App).ApplicationDataObject; + + if (weatherData.WasThereRemoteError) + { + MessageBox.Show( + AppResources.NoticeThereIsNotCurrentLocation, + AppResources.AskForLocationConsentMessageBoxCaption, + MessageBoxButton.OK); + return; + } + + _selectedDateViewModel.LoadData(weatherData); + + // TODO: Should I try to move this code to MainViewModel. It seems so but how? + // TODO: What if the address is not available? I should show something like "Address not found" by default... + string country = (string)IsolatedStorageSettings.ApplicationSettings["Country"]; + string city = (string)IsolatedStorageSettings.ApplicationSettings["City"]; + string cityCountry = String.Format(CultureInfo.InvariantCulture, "{0}, {1}", city, country); + this.TitleTextCityCountry.Title = cityCountry; + } + } +} \ No newline at end of file diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/MainViewModel.cs b/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/MainViewModel.cs index 4cb995a..59cdbf0 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/MainViewModel.cs +++ b/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/MainViewModel.cs @@ -145,6 +145,7 @@ namespace WeatherInformation.ViewModels } // 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.RemoteCurrentWeatherData; @@ -172,6 +173,7 @@ namespace WeatherInformation.ViewModels NotifyPropertyChanged("CurrentMinTemp"); NotifyPropertyChanged("CurrentMinTempUnits"); + // TODO: static resource :( var currentConditions = "no description available"; if (remoteCurrentWeatherData.weather.Count > 0) { diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/SelectedDateViewModel.cs b/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/SelectedDateViewModel.cs new file mode 100644 index 0000000..9cb6625 --- /dev/null +++ b/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/SelectedDateViewModel.cs @@ -0,0 +1,217 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using WeatherInformation.Model; +using WeatherInformation.Resources; + +namespace WeatherInformation.ViewModels +{ + public class SelectedDateViewModel : INotifyPropertyChanged + { + + [DataMember] + public Int32 SelectedDateIndex { get; set; } + + public String SelectedDate { get; private set; } + public String SelectedDateMaxTemp { get; private set; } + public String SelectedDateMaxTempUnits { get; private set; } + public String SelectedDateMinTemp { get; private set; } + public String SelectedDateMinTempUnits { get; private set; } + public String SelectedDateMorningTempText { get; private set; } + public String SelectedDateMorningTemp { get; private set; } + public String SelectedDateMorningTempUnits { get; private set; } + public String SelectedDateDayTempText { get; private set; } + public String SelectedDateDayTemp { get; private set; } + public String SelectedDateDayTempUnits { get; private set; } + public String SelectedDateEveningTempText { get; private set; } + public String SelectedDateEveningTemp { get; private set; } + public String SelectedDateEveningTempUnits { get; private set; } + public String SelectedDateNightTempText { get; private set; } + public String SelectedDateNightTemp { get; private set; } + public String SelectedDateNightTempUnits { get; private set; } + public String SelectedDateConditions { get; private set; } + public String SelectedDateHumidityText { get; private set; } + public String SelectedDateHumidity { get; private set; } + public String SelectedDateHumidityUnits { get; private set; } + public String SelectedDateRainText { get; private set; } + public String SelectedDateRain { get; private set; } + public String SelectedDateRainUnits { get; private set; } + public String SelectedDateWindText { get; private set; } + public String SelectedDateWind { get; private set; } + public String SelectedDateWindUnits { get; private set; } + public String SelectedDateCloudsText { get; private set; } + public String SelectedDateClouds { get; private set; } + public String SelectedDateCloudsUnits { get; private set; } + public String SelectedDatePressureText { get; private set; } + public String SelectedDatePressure { get; private set; } + public String SelectedDatePressureUnits { get; private set; } + + public void LoadData(WeatherData weatherData) + { + var remoteForecastWeatherData = weatherData.RemoteForecastWeatherData; + + WeatherInformation.Model.ForecastWeatherParser.List forecast = remoteForecastWeatherData.list[this.SelectedDateIndex]; + 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); + NotifyPropertyChanged("SelectedDate"); + + // TODO: units :( + bool isFahrenheit = false; + double tempUnits = isFahrenheit ? 0 : 273.15; + string symbol = isFahrenheit ? AppResources.TemperatureUnitsFahrenheitSymbol : AppResources.TemperatureUnitsCentigradeSymbol; + + var selectedDateMaxTemp = ""; + var selectedDateTempUnits = ""; + if (forecast.temp != null) + { + var conversion = forecast.temp.max; + conversion -= tempUnits; + selectedDateMaxTemp = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", conversion); + selectedDateTempUnits = symbol; + } + this.SelectedDateMaxTemp = selectedDateMaxTemp; + NotifyPropertyChanged("SelectedDateMaxTemp"); + this.SelectedDateMaxTempUnits = selectedDateTempUnits; + NotifyPropertyChanged("SelectedDateMaxTempUnits"); + + var selectedDateMinTemp = ""; + selectedDateTempUnits = ""; + if (forecast.temp != null) + { + var conversion = forecast.temp.min; + conversion -= tempUnits; + selectedDateMinTemp = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", conversion); + selectedDateTempUnits = symbol; + } + this.SelectedDateMinTemp = selectedDateMinTemp; + NotifyPropertyChanged("SelectedDateMinTemp"); + this.SelectedDateMaxTempUnits = selectedDateTempUnits; + NotifyPropertyChanged("SelectedDateMinTempUnits"); + + // TODO: static resource :( + var selectedDateConditions = "no description available"; + if (forecast.weather.Count > 0) + { + 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); + this.SelectedDateHumidityUnits = AppResources.MainPageCurrentHumidityUnits; + NotifyPropertyChanged("SelectedDateHumidity"); + NotifyPropertyChanged("SelectedDateHumidityUnits"); + NotifyPropertyChanged("SelectedDateHumidityText"); + + this.SelectedDateRainText = AppResources.MainPageCurrentRain; + this.SelectedDateRain = forecast.rain.ToString(CultureInfo.InvariantCulture); + this.SelectedDateRainUnits = AppResources.MainPageCurrentRainUnits; + NotifyPropertyChanged("SelectedDateRain"); + NotifyPropertyChanged("SelectedDateRainUnits"); + NotifyPropertyChanged("SelectedDateRainText"); + + this.SelectedDateWindText = AppResources.MainPageCurrentWind; + this.SelectedDateWind = forecast.speed.ToString(CultureInfo.InvariantCulture); + this.SelectedDateWindUnits = AppResources.MainPageCurrentWindUnits; + NotifyPropertyChanged("SelectedDateWind"); + NotifyPropertyChanged("SelectedDateWindUnits"); + NotifyPropertyChanged("SelectedDateWindText"); + + this.SelectedDateCloudsText = AppResources.MainPageCurrentClouds; + this.SelectedDateClouds = forecast.clouds.ToString(CultureInfo.InvariantCulture); + this.SelectedDateCloudsUnits = AppResources.MainPageCurrentCloudsUnits; + NotifyPropertyChanged("SelectedDateClouds"); + NotifyPropertyChanged("SelectedDateCloudsUnits"); + NotifyPropertyChanged("SelectedDateCloudsText"); + + this.SelectedDatePressureText = AppResources.MainPageCurrentPressure; + this.SelectedDatePressure = forecast.pressure.ToString(CultureInfo.InvariantCulture); + this.SelectedDatePressureUnits = AppResources.MainPageCurrentPressureUnits; + NotifyPropertyChanged("SelectedDatePressure"); + NotifyPropertyChanged("SelectedDatePressureUnits"); + NotifyPropertyChanged("SelectedDatePressureText"); + + var selectedDateMorningTemp = ""; + selectedDateTempUnits = ""; + if (forecast.temp != null) + { + var conversion = forecast.temp.morn; + conversion -= tempUnits; + selectedDateMorningTemp = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", conversion); + selectedDateTempUnits = symbol; + } + this.SelectedDateMorningTempText = AppResources.SelectedDatePageMorning; + NotifyPropertyChanged("SelectedDateMorningTempText"); + this.SelectedDateMorningTemp = selectedDateMorningTemp; + NotifyPropertyChanged("SelectedDateMorningTemp"); + this.SelectedDateMorningTempUnits = selectedDateTempUnits; + NotifyPropertyChanged("SelectedDateMorningTempUnits"); + + var selectedDateDayTemp = ""; + selectedDateTempUnits = ""; + if (forecast.temp != null) + { + var conversion = forecast.temp.day; + conversion -= tempUnits; + selectedDateDayTemp = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", conversion); + selectedDateTempUnits = symbol; + } + this.SelectedDateDayTempText = AppResources.SelectedDatePageDay; + NotifyPropertyChanged("SelectedDateDayTempText"); + this.SelectedDateDayTemp = selectedDateDayTemp; + NotifyPropertyChanged("SelectedDateDayTemp"); + this.SelectedDateDayTempUnits = selectedDateTempUnits; + NotifyPropertyChanged("SelectedDateDayTempUnits"); + + var selectedDateEveningTemp = ""; + selectedDateTempUnits = ""; + if (forecast.temp != null) + { + var conversion = forecast.temp.eve; + conversion -= tempUnits; + selectedDateEveningTemp = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", conversion); + selectedDateTempUnits = symbol; + } + this.SelectedDateEveningTempText = AppResources.SelectedDatePageEvening; + NotifyPropertyChanged("SelectedDateEveningTempText"); + this.SelectedDateEveningTemp = selectedDateEveningTemp; + NotifyPropertyChanged("SelectedDateEveningTemp"); + this.SelectedDateEveningTempUnits = selectedDateTempUnits; + NotifyPropertyChanged("SelectedDateEveningTempUnits"); + + var selectedDateNightTemp = ""; + selectedDateTempUnits = ""; + if (forecast.temp != null) + { + var conversion = forecast.temp.night; + conversion -= tempUnits; + selectedDateNightTemp = String.Format(CultureInfo.InvariantCulture, "{0:0.##}", conversion); + selectedDateTempUnits = symbol; + } + this.SelectedDateNightTempText = AppResources.SelectedDatePageNight; + NotifyPropertyChanged("SelectedDateNightTempText"); + this.SelectedDateNightTemp = selectedDateNightTemp; + NotifyPropertyChanged("SelectedDateNightTemp"); + this.SelectedDateNightTempUnits = selectedDateTempUnits; + NotifyPropertyChanged("SelectedDateNightTempUnits"); + } + + public event PropertyChangedEventHandler PropertyChanged; + private void NotifyPropertyChanged(String propertyName) + { + PropertyChangedEventHandler handler = PropertyChanged; + if (null != handler) + { + handler(this, new PropertyChangedEventArgs(propertyName)); + } + } + } +} diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/WeatherInformation.csproj b/WindowsPhone/WeatherInformation/WeatherInformation/WeatherInformation.csproj index 53220e0..cb96eff 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/WeatherInformation.csproj +++ b/WindowsPhone/WeatherInformation/WeatherInformation/WeatherInformation.csproj @@ -24,7 +24,7 @@ true 11.0 true - 12.0.41212.0 + 12.0.50429.0 true @@ -128,11 +128,15 @@ True AppResources.resx + + SelectedDatePage.xaml + SettingsPage.xaml + @@ -140,6 +144,9 @@ Designer MSBuild:Compile + + MSBuild:MarkupCompilePass1 + Designer MSBuild:Compile @@ -152,6 +159,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile -- 2.1.4