blob: aeb8f60cef1a4948dae347065baf9ab7363ab348 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
using MediaBrowser.Model.Weather;
using System;
using System.Globalization;
using System.Windows.Data;
namespace MediaBrowser.Plugins.DefaultTheme.Converters
{
/// <summary>
/// Generates a weather image based on the current forecast
/// </summary>
public class WeatherImageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var weather = value as WeatherInfo;
if (weather != null && weather.CurrentWeather != null)
{
switch (weather.CurrentWeather.Condition)
{
case WeatherConditions.Thunderstorm:
return "../Resources/Images/Weather/Thunder.png";
case WeatherConditions.Overcast:
return "../Resources/Images/Weather/Overcast.png";
case WeatherConditions.Mist:
case WeatherConditions.Sleet:
case WeatherConditions.Rain:
return "../Resources/Images/Weather/Rain.png";
case WeatherConditions.Blizzard:
case WeatherConditions.Snow:
return "../Resources/Images/Weather/Snow.png";
case WeatherConditions.Cloudy:
return "../Resources/Images/Weather/Cloudy.png";
case WeatherConditions.PartlyCloudy:
return "../Resources/Images/Weather/PartlyCloudy.png";
default:
return "../Resources/Images/Weather/Sunny.png";
}
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
|