Weather pictures plus UTC time instead of local time.
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
- <Image Source="/Assets/Tiles/IconicTileMediumLarge.png" Width="100" Height="100" Margin="12,-6,12,0" />
+ <Image Source="{Binding CurrentWeatherImagePath}" Width="100" Height="100" Margin="12,0" />
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="{Binding CurrentMaxTemp}" TextWrapping="Wrap" Style="{StaticResource PhoneTextLargeStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Margin="2,0"/>
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WeatherInformation.Model.Images
+{
+ class RemoteImagesTranslation
+ {
+ // C# Language Specification§10.11
+ // If a class contains any static fields with initializers, those initializers are executed
+ // in textual order immediately prior to executing the static constructor.
+ private readonly static Dictionary<string, string> images = new Dictionary<string, string>();
+
+ static RemoteImagesTranslation()
+ {
+ images.Add("01d", "weather_clear");
+ images.Add("01n", "weather_clear_night");
+ images.Add("02d", "weather_few_clouds");
+ images.Add("02n", "weather_few_clouds_night");
+ images.Add("03d", "weather_few_clouds");
+ images.Add("03n", "weather_few_clouds");
+ images.Add("04d", "weather_overcast");
+ images.Add("04n", "weather_overcast");
+ images.Add("09d", "weather_showers");
+ images.Add("09n", "weather_showers");
+ images.Add("10d", "weather_showers_scattered");
+ images.Add("10n", "weather_showers_scattered");
+ images.Add("11d", "weather_storm");
+ images.Add("11n", "weather_storm");
+ images.Add("13d", "weather_snow");
+ images.Add("13n", "weather_snow");
+ images.Add("50d", "weather_fog");
+ images.Add("50n", "weather_fog");
+ }
+
+ public static string GetTransaltedImage(string id)
+ {
+ string value;
+ images.TryGetValue(id, out value);
+
+ return value;
+ }
+ }
+}
}
/// <summary>
- /// Busca una cadena traducida similar a SUN RISE.
+ /// Busca una cadena traducida similar a SUN RISE (UTC).
/// </summary>
public static string MainPageCurrentSunRise {
get {
}
/// <summary>
- /// Busca una cadena traducida similar a SUN SET.
+ /// Busca una cadena traducida similar a SUN SET (UTC).
/// </summary>
public static string MainPageCurrentSunSet {
get {
<value>VIENTO</value>
</data>
<data name="MainPageCurrentSunSet" xml:space="preserve">
- <value>SOL SE PONE</value>
+ <value>SOL SE PONE (UTC)</value>
</data>
<data name="MainPageCurrentSunRise" xml:space="preserve">
- <value>SOL SALE</value>
+ <value>SOL SALE (UTC)</value>
</data>
<data name="MainPageCurrentSnow" xml:space="preserve">
<value>NIEVE</value>
<note from="MultilingualBuild" annotates="source" priority="2">Not to be translated.</note>
</trans-unit>
<trans-unit id="Resx/MainPageCurrentSunSet" translate="yes" xml:space="preserve">
- <source>SUN SET</source>
- <target state="translated">SOL SE PONE</target>
- </trans-unit>
+ <source>SUN SET (UTC)</source>
+ <target state="translated">SOL SE PONE (UTC)</target></trans-unit>
<trans-unit id="Resx/MainPageCurrentSunRise" translate="yes" xml:space="preserve">
- <source>SUN RISE</source>
- <target state="translated">SOL SALE</target>
- </trans-unit>
+ <source>SUN RISE (UTC)</source>
+ <target state="translated">SOL SALE (UTC)</target></trans-unit>
<trans-unit id="Resx/MainPageCurrentSnow" translate="yes" xml:space="preserve">
<source>SNOW</source>
<target state="translated">NIEVE</target>
<note from="MultilingualBuild" annotates="source" priority="2">Not to be translated.</note>
</trans-unit>
<trans-unit id="Resx/MainPageCurrentSunSet" translate="yes" xml:space="preserve">
- <source>SUN SET</source>
- <target state="new">SUN SET</target>
+ <source>SUN SET (UTC)</source>
+ <target state="new">SUN SET (UTC)</target>
</trans-unit>
<trans-unit id="Resx/MainPageCurrentSunRise" translate="yes" xml:space="preserve">
- <source>SUN RISE</source>
- <target state="new">SUN RISE</target>
+ <source>SUN RISE (UTC)</source>
+ <target state="new">SUN RISE (UTC)</target>
</trans-unit>
<trans-unit id="Resx/MainPageCurrentSnow" translate="yes" xml:space="preserve">
<source>SNOW</source>
<value>SNOW</value>
</data>
<data name="MainPageCurrentSunRise" xml:space="preserve">
- <value>SUN RISE</value>
+ <value>SUN RISE (UTC)</value>
</data>
<data name="MainPageCurrentSunSet" xml:space="preserve">
- <value>SUN SET</value>
+ <value>SUN SET (UTC)</value>
</data>
<data name="MainPageCurrentWind" xml:space="preserve">
<value>WIND</value>
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:WeatherInformation.ViewModels"
TitleTextCityCountry="City,country"
+ CurrentWeatherImagePath="/Images/weather_clear.png"
CurrentMaxTemp="25"
CurrentMaxTempUnits="ºC"
CurrentMinTemp="15"
CurrentRainText="RAIN"
CurrentSnow="10"
CurrentSnowText="SNOW"
- CurrentSunRiseText="SUN RISE"
+ CurrentSunRiseText="SUN RISE (UTC)"
CurrentSunRise="2014.07.19 07:01:54"
- CurrentSunSetText="SUN SET"
+ CurrentSunSetText="SUN SET (UTC)"
CurrentSunSet="2014.07.19 21:41:40"
CurrentWind="1.03"
CurrentWindText="WIND"
CurrentCloudsUnits="%">
<vm:MainViewModel.ForecastItems>
- <vm:ItemViewModel LineOne="MON" LineTwo="1" LineThree="15ºC" LineFour="10ºC" LineFive="/Assets/Tiles/IconicTileMediumLarge.png"/>
- <vm:ItemViewModel LineOne="TUE" LineTwo="2" LineThree="16ºC" LineFour="10ºC" LineFive="/Assets/Tiles/IconicTileMediumLarge.png"/>
- <vm:ItemViewModel LineOne="WED" LineTwo="3" LineThree="14ºC" LineFour="10ºC" LineFive="/Assets/Tiles/IconicTileMediumLarge.png"/>
- <vm:ItemViewModel LineOne="THU" LineTwo="4" LineThree="12ºC" LineFour="10ºC" LineFive="/Assets/Tiles/IconicTileMediumLarge.png"/>
- <vm:ItemViewModel LineOne="FRI" LineTwo="5" LineThree="13ºC" LineFour="10ºC" LineFive="/Assets/Tiles/IconicTileMediumLarge.png"/>
- <vm:ItemViewModel LineOne="SAT" LineTwo="6" LineThree="20ºC" LineFour="10ºC" LineFive="/Assets/Tiles/IconicTileMediumLarge.png"/>
+ <vm:ItemViewModel LineOne="MON" LineTwo="1" LineThree="15ºC" LineFour="10ºC" LineFive="/Images/weather_clear.png"/>
+ <vm:ItemViewModel LineOne="TUE" LineTwo="2" LineThree="16ºC" LineFour="10ºC" LineFive="/Images/weather_clear_night.png"/>
+ <vm:ItemViewModel LineOne="WED" LineTwo="3" LineThree="14ºC" LineFour="10ºC" LineFive="/Images/weather_few_clouds.png"/>
+ <vm:ItemViewModel LineOne="THU" LineTwo="4" LineThree="12ºC" LineFour="10ºC" LineFive="/Images/weather_few_clouds_night.png"/>
+ <vm:ItemViewModel LineOne="FRI" LineTwo="5" LineThree="13ºC" LineFour="10ºC" LineFive="/Images/weather_fog.png"/>
+ <vm:ItemViewModel LineOne="SAT" LineTwo="6" LineThree="20ºC" LineFour="10ºC" LineFive="/Images/weather_overcast.png"/>
</vm:MainViewModel.ForecastItems>
-
- <vm:MainViewModel.CurrentItems>
- <vm:ItemViewModel LineOne="MON 1" LineTwo="15ºC" LineThree="/Assets/Tiles/IconicTileMediumLarge.png"/>
- <vm:ItemViewModel LineOne="TUE 2" LineTwo="16ºC" LineThree="/Assets/Tiles/IconicTileMediumLarge.png"/>
- <vm:ItemViewModel LineOne="WED 3" LineTwo="14ºC" LineThree="/Assets/Tiles/IconicTileMediumLarge.png"/>
- <vm:ItemViewModel LineOne="THU 4" LineTwo="12ºC" LineThree="/Assets/Tiles/IconicTileMediumLarge.png"/>
- <vm:ItemViewModel LineOne="FRI 5" LineTwo="13ºC" LineThree="/Assets/Tiles/IconicTileMediumLarge.png"/>
- <vm:ItemViewModel LineOne="SAT 6" LineTwo="20ºC" LineThree="/Assets/Tiles/IconicTileMediumLarge.png"/>
- </vm:MainViewModel.CurrentItems>
</vm:MainViewModel>
\ No newline at end of file
xmlns:ViewModels="clr-namespace:WeatherInformation.ViewModels"
TitleTextCityCountry="City,country"
SelectedDate="July 27"
+ SelectedDateWeatherImagePath="/Images/weather_clear.png"
SelectedDateRainText="RAIN"
SelectedDateMaxTempUnits="ºC"
SelectedDateCloudsText="CLOUDS"
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
- <Image Source="/Assets/Tiles/IconicTileMediumLarge.png" Width="100" Height="100" Margin="12,-6,12,0" />
+ <Image Source="{Binding SelectedDateWeatherImagePath}" Width="100" Height="100" Margin="12,0" />
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="{Binding SelectedDateMaxTemp}" TextWrapping="Wrap" Style="{StaticResource PhoneTextLargeStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Margin="2,0"/>
using System.Globalization;
using System.IO.IsolatedStorage;
using WeatherInformation.Model;
+using WeatherInformation.Model.Images;
using WeatherInformation.Resources;
namespace WeatherInformation.ViewModels
public ObservableCollection<ItemViewModel> ForecastItems{ get; private set; }
public ObservableCollection<ItemViewModel> CurrentItems { get; private set; }
public String TitleTextCityCountry { get; private set; }
+ public String CurrentWeatherImagePath { get; private set; }
public String CurrentMaxTemp { get; private set; }
public String CurrentMaxTempUnits { get; private set; }
public String CurrentMinTemp { get; private set; }
foreach (WeatherInformation.Model.ForecastWeatherParser.List item in remoteForecastWeatherData.list)
{
- DateTime date = unixTime.AddSeconds(item.dt).ToLocalTime();
+ DateTime date = unixTime.AddSeconds(item.dt);
// 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)
double 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 = "/Assets/Tiles/IconicTileMediumLarge.png"
+ LineFive = weatherImagePath
});
count--;
var remoteCurrentWeatherData = weatherData.RemoteCurrent;
if (remoteCurrentWeatherData != null)
{
+ string weatherImage;
+ if (remoteCurrentWeatherData.weather.Count > 0 &&
+ remoteCurrentWeatherData.weather[0].icon != null &&
+ RemoteImagesTranslation.GetTransaltedImage(remoteCurrentWeatherData.weather[0].icon) != null)
+ {
+ weatherImage = RemoteImagesTranslation.GetTransaltedImage(remoteCurrentWeatherData.weather[0].icon);
+ }
+ else
+ {
+ weatherImage = "weather_severe_alert";
+ }
+ this.CurrentWeatherImagePath = String.Format(CultureInfo.InvariantCulture, "/Images/{0}.png", weatherImage);
+ NotifyPropertyChanged("CurrentWeatherImagePath");
+
var currentMaxTemp = "";
if (remoteCurrentWeatherData.main != null)
{
NotifyPropertyChanged("CurrentPressureText");
this.CurrentSunRiseText = AppResources.MainPageCurrentSunRise;
- var sunRiseTime = unixTime.AddSeconds(remoteCurrentWeatherData.sys.sunrise).ToLocalTime();
+ var sunRiseTime = unixTime.AddSeconds(remoteCurrentWeatherData.sys.sunrise);
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();
+ var sunSetTime = unixTime.AddSeconds(remoteCurrentWeatherData.sys.sunset);
this.CurrentSunSet = sunSetTime.ToString("MM/dd/yy H:mm:ss", CultureInfo.InvariantCulture);
NotifyPropertyChanged("CurrentSunSet");
NotifyPropertyChanged("CurrentSunSetText");
using System.Text;
using System.Threading.Tasks;
using WeatherInformation.Model;
+using WeatherInformation.Model.Images;
using WeatherInformation.Model.Services;
using WeatherInformation.Resources;
public String TitleTextCityCountry { get; private set; }
public String SelectedDate { get; private set; }
+ public String SelectedDateWeatherImagePath { get; private set; }
public String SelectedDateMaxTemp { get; private set; }
public String SelectedDateMaxTempUnits { get; private set; }
public String SelectedDateMinTemp { get; private set; }
double tempUnits = isFahrenheit ? 0 : 273.15;
string symbol = isFahrenheit ? AppResources.TemperatureUnitsFahrenheitSymbol : AppResources.TemperatureUnitsCentigradeSymbol;
+ string weatherImage;
+ if (forecast.weather.Count > 0 &&
+ forecast.weather[0].icon != null &&
+ RemoteImagesTranslation.GetTransaltedImage(forecast.weather[0].icon) != null)
+ {
+ weatherImage = RemoteImagesTranslation.GetTransaltedImage(forecast.weather[0].icon);
+ }
+ else
+ {
+ weatherImage = "weather_severe_alert";
+ }
+ this.SelectedDateWeatherImagePath = String.Format(CultureInfo.InvariantCulture, "/Images/{0}.png", weatherImage);
+ NotifyPropertyChanged("SelectedDateWeatherImagePath");
+
var selectedDateMaxTemp = "";
var selectedDateTempUnits = "";
if (forecast.temp != null)
<Compile Include="Model\ForecastWeatherParser\List.cs" />
<Compile Include="Model\ForecastWeatherParser\Temp.cs" />
<Compile Include="Model\ForecastWeatherParser\Weather.cs" />
+ <Compile Include="Model\Images\RemoteImagesTranslation.cs" />
<Compile Include="Model\JsonDataParser\JsonParser.cs" />
<Compile Include="Model\Location.cs" />
<Compile Include="Model\LocationDataContext.cs" />
</Content>
<Content Include="Images\add.png" />
<Content Include="Images\feature.settings.png" />
+ <Content Include="Images\weather_clear.png" />
+ <Content Include="Images\weather_clear_night.png" />
+ <Content Include="Images\weather_few_clouds.png" />
+ <Content Include="Images\weather_few_clouds_night.png" />
+ <Content Include="Images\weather_fog.png" />
+ <Content Include="Images\weather_overcast.png" />
+ <Content Include="Images\weather_severe_alert.png" />
+ <Content Include="Images\weather_showers.png" />
+ <Content Include="Images\weather_showers_scattered.png" />
+ <Content Include="Images\weather_snow.png" />
+ <Content Include="Images\weather_storm.png" />
<Content Include="README_FIRST.txt" />
<Content Include="Toolkit.Content\ApplicationBar.Add.png" />
<Content Include="Toolkit.Content\ApplicationBar.Cancel.png" />