WeatherInformation: current weather
authorgu.martinm@gmail.com <gu.martinm@gmail.com>
Sun, 27 Jul 2014 16:40:05 +0000 (18:40 +0200)
committergu.martinm@gmail.com <gu.martinm@gmail.com>
Sun, 27 Jul 2014 16:40:05 +0000 (18:40 +0200)
WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml
WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml.cs
WindowsPhone/WeatherInformation/WeatherInformation/SampleData/MainViewModelSampleData.xaml
WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/MainViewModel.cs

index ce1185f..f72410f 100644 (file)
                             </Grid.ColumnDefinitions>
                             <StackPanel Grid.Column="0" Grid.Row="0" Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Center">
                                 <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
-                                    <TextBlock Text="{Binding LocalizedResources.MainPageCurrentFeelsLike, Mode=OneWay, Source={StaticResource LocalizedStrings}}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
+                                    <TextBlock Text="{Binding CurrentFeelsLikeText}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
                                     <TextBlock Text="{Binding CurrentFeelsLikeTemp}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,0,2,0"/>
                                     <TextBlock Text="{Binding CurrentFeelsLikeTempUnits}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Margin="2,0"/>
                                 </StackPanel>
                                 <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
-                                    <TextBlock Text="{Binding LocalizedResources.MainPageCurrentHumidity, Mode=OneWay, Source={StaticResource LocalizedStrings}}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
+                                    <TextBlock Text="{Binding CurrentHumidityText}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
                                     <TextBlock Text="{Binding CurrentHumidity}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,0,2,0"/>
                                     <TextBlock Text="{Binding CurrentHumidityUnits}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Margin="2,0"/>
                                 </StackPanel>
                                 <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
-                                    <TextBlock Text="{Binding LocalizedResources.MainPageCurrentRain, Mode=OneWay, Source={StaticResource LocalizedStrings}}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
+                                    <TextBlock Text="{Binding CurrentRainText}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
                                     <TextBlock Text="{Binding CurrentRain}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,0,2,0"/>
                                     <TextBlock Text="{Binding CurrentRainUnits}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Margin="2,0"/>
                                 </StackPanel>
                             </StackPanel>
                             <StackPanel Grid.Column="1" Grid.Row="0" Orientation="Vertical" HorizontalAlignment="Right" VerticalAlignment="Center">
                                 <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
-                                    <TextBlock Text="{Binding LocalizedResources.MainPageCurrentSnow, Mode=OneWay, Source={StaticResource LocalizedStrings}}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0,12,0"/>
+                                    <TextBlock Text="{Binding CurrentSnowText}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0,12,0"/>
                                     <TextBlock Text="{Binding CurrentSnow}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,0,2,0"/>
                                     <TextBlock Text="{Binding CurrentSnowUnits}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Margin="2,0"/>
                                 </StackPanel>
                                 <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
-                                    <TextBlock Text="{Binding LocalizedResources.MainPageCurrentWind, Mode=OneWay, Source={StaticResource LocalizedStrings}}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
+                                    <TextBlock Text="{Binding CurrentWindText}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
                                     <TextBlock Text="{Binding CurrentWind}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,0,2,0"/>
                                     <TextBlock Text="{Binding CurrentWindUnits}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Margin="2,0"/>
                                 </StackPanel>
                                 <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
-                                    <TextBlock Text="{Binding LocalizedResources.MainPageCurrentClouds, Mode=OneWay, Source={StaticResource LocalizedStrings}}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
+                                    <TextBlock Text="{Binding CurrentCloudsText}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
                                     <TextBlock Text="{Binding CurrentClouds}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,0,2,0"/>
                                     <TextBlock Text="{Binding CurrentSnowUnits}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Margin="2,0"/>
                                 </StackPanel>
                         </Grid>
                         <StackPanel Grid.Column="0" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Center">
                             <StackPanel Orientation="Horizontal">
-                                <TextBlock Text="{Binding LocalizedResources.MainPageCurrentPressure, Mode=OneWay, Source={StaticResource LocalizedStrings}}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
+                                <TextBlock Text="{Binding CurrentPressureText}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
                                 <TextBlock Text="{Binding CurrentPressure}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,0,2,0"/>
                                 <TextBlock Text="{Binding CurrentPressureUnits}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Margin="2,0"/>
                             </StackPanel>
                             <StackPanel Orientation="Horizontal">
-                                <TextBlock Text="{Binding LocalizedResources.MainPageCurrentSunRise, Mode=OneWay, Source={StaticResource LocalizedStrings}}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
+                                <TextBlock Text="{Binding CurrentSunRiseText}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
                                 <TextBlock Text="{Binding CurrentSunRise}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
                             </StackPanel>
                             <StackPanel Orientation="Horizontal">
-                                <TextBlock Text="{Binding LocalizedResources.MainPageCurrentSunSet, Mode=OneWay, Source={StaticResource LocalizedStrings}}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
+                                <TextBlock Text="{Binding CurrentSunSetText}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
                                 <TextBlock Text="{Binding CurrentSunSet}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,0"/>
                             </StackPanel>
                         </StackPanel>
index 2cb803b..d98b2b9 100644 (file)
@@ -129,6 +129,7 @@ namespace WeatherInformation
             (Application.Current as WeatherInformation.App).IsNewLocation = false;
 
             // 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);
index 99d2581..c0ff345 100644 (file)
@@ -6,15 +6,24 @@
     CurrentMaxTempUnits="ºC"
     CurrentMinTemp="15"
     CurrentFeelsLikeTemp="20"
+    CurrentFeelsLikeText="FEELS LIKE"
     CurrentPressure="1015"
+    CurrentPressureText="PRESSURE"
     CurrentRain="10"
+    CurrentRainText="RAIN"
     CurrentSnow="10"
+    CurrentSnowText="SNOW"
+    CurrentSunRiseText="SUN RISE"
     CurrentSunRise="2014.07.19 07:01:54"
+    CurrentSunSetText="SUN SET"
     CurrentSunSet="2014.07.19 21:41:40"
-    CurrentWind="1.03" 
+    CurrentWind="1.03"
+    CurrentWindText="WIND"
     CurrentConditions="Sky is Clear"
+    CurrentCloudsText="CLOUDS"
     CurrentClouds="10"
     CurrentHumidity="50"
+    CurrentHumidityText="HUMIDITY"
     CurrentMinTempUnits="ºC"
     CurrentPressureUnits="hpa"
     CurrentRainUnits="mm 3h"
index bd0550e..4cb995a 100644 (file)
@@ -44,26 +44,35 @@ namespace WeatherInformation.ViewModels
         /// </summary>
         public ObservableCollection<ItemViewModel> ForecastItems{ get; private set; }
         public ObservableCollection<ItemViewModel> CurrentItems { get; private set; }
-        public String CurrentMaxTemp { get; set; }
-        public String CurrentMaxTempUnits { get; set; }
+        public String CurrentMaxTemp { get; private set; }
+        public String CurrentMaxTempUnits { get; private set; }
         public String CurrentMinTemp { get; private set; }
-        public String CurrentMinTempUnits { get; set; }
+        public String CurrentMinTempUnits { get; private set; }
         public String CurrentConditions { get; private set; }
+        public String CurrentFeelsLikeText { get; private set; }
         public String CurrentFeelsLikeTemp { get; private set; }
-        public String CurrentFeelsLikeTempUnits { get; set; }
+        public String CurrentFeelsLikeTempUnits { get; private set; }
+        public String CurrentHumidityText { get; private set; }
         public String CurrentHumidity { get; private set; }
         public String CurrentHumidityUnits { get; private set; }
+        public String CurrentRainText { get; private set; }
         public String CurrentRain { get; private set; }
         public String CurrentRainUnits { get; private set; }
+        public String CurrentSnowText { get; private set; }
         public String CurrentSnow { get; private set; }
         public String CurrentSnowUnits { get; private set; }
+        public String CurrentWindText { get; private set; }
         public String CurrentWind { get; private set; }
         public String CurrentWindUnits { get; private set; }
+        public String CurrentCloudsText { get; private set; }
         public String CurrentClouds { get; private set; }
         public String CurrentCloudsUnits { get; private set; }
+        public String CurrentPressureText { get; private set; }
         public String CurrentPressure { get; private set; }
         public String CurrentPressureUnits { get; private set; }
+        public String CurrentSunRiseText { get; private set; }
         public String CurrentSunRise { get; private set; }
+        public String CurrentSunSetText { get; private set; }
         public String CurrentSunSet { get; private set; }
 
         /// <summary>
@@ -171,6 +180,7 @@ namespace WeatherInformation.ViewModels
             this.CurrentConditions = currentConditions;
             NotifyPropertyChanged("CurrentConditions");
 
+            this.CurrentFeelsLikeText = AppResources.MainPageCurrentFeelsLike;       
             var currentFeelsLikeTemp = "";
             if (remoteCurrentWeatherData.main != null)
             {
@@ -182,7 +192,9 @@ namespace WeatherInformation.ViewModels
             this.CurrentFeelsLikeTempUnits = symbol;
             NotifyPropertyChanged("CurrentFeelsLikeTemp");
             NotifyPropertyChanged("CurrentFeelsLikeTempUnits");
+            NotifyPropertyChanged("CurrentFeelsLikeText");
 
+            this.CurrentHumidityText = AppResources.MainPageCurrentHumidity;
             var currentHumidity = "";
             if (remoteCurrentWeatherData.main != null)
             {
@@ -192,7 +204,9 @@ namespace WeatherInformation.ViewModels
             this.CurrentHumidityUnits = AppResources.MainPageCurrentHumidityUnits;
             NotifyPropertyChanged("CurrentHumidity");
             NotifyPropertyChanged("CurrentHumidityUnits");
+            NotifyPropertyChanged("CurrentHumidityText");
 
+            this.CurrentRainText = AppResources.MainPageCurrentRain;
             var currentRain = "";
             if (remoteCurrentWeatherData.rain != null)
             {
@@ -202,7 +216,9 @@ namespace WeatherInformation.ViewModels
             this.CurrentRainUnits = AppResources.MainPageCurrentRainUnits;
             NotifyPropertyChanged("CurrentRain");
             NotifyPropertyChanged("CurrentRainUnits");
+            NotifyPropertyChanged("CurrentRainText");
 
+            this.CurrentSnowText = AppResources.MainPageCurrentSnow;
             var currentSnow = "";
             if (remoteCurrentWeatherData.snow != null)
             {
@@ -212,7 +228,9 @@ namespace WeatherInformation.ViewModels
             this.CurrentSnowUnits = AppResources.MainPageCurrentSnowUnits;
             NotifyPropertyChanged("CurrentSnow");
             NotifyPropertyChanged("CurrentSnowUnits");
+            NotifyPropertyChanged("CurrentSnowText");
 
+            this.CurrentWindText = AppResources.MainPageCurrentWind;
             var currentWind = "";
             if (remoteCurrentWeatherData.wind != null)
             {
@@ -222,7 +240,9 @@ namespace WeatherInformation.ViewModels
             this.CurrentWindUnits = AppResources.MainPageCurrentWindUnits;
             NotifyPropertyChanged("CurrentWind");
             NotifyPropertyChanged("CurrentWindUnits");
+            NotifyPropertyChanged("CurrentWindText");
 
+            this.CurrentCloudsText = AppResources.MainPageCurrentClouds;
             var currentClouds = "";
             if (remoteCurrentWeatherData.clouds != null)
             {
@@ -232,7 +252,9 @@ namespace WeatherInformation.ViewModels
             this.CurrentCloudsUnits = AppResources.MainPageCurrentCloudsUnits;
             NotifyPropertyChanged("CurrentClouds");
             NotifyPropertyChanged("CurrentCloudsUnits");
+            NotifyPropertyChanged("CurrentCloudsText");
 
+            this.CurrentPressureText = AppResources.MainPageCurrentPressure;
             var currentPressure = "";
             if (remoteCurrentWeatherData.main != null)
             {
@@ -242,14 +264,19 @@ namespace WeatherInformation.ViewModels
             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()