WeatherImageConverter.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using MediaBrowser.Model.Weather;
  2. using System;
  3. using System.ComponentModel.Composition;
  4. using System.Globalization;
  5. using System.Windows.Data;
  6. namespace MediaBrowser.Plugins.DefaultTheme.Converters
  7. {
  8. [PartNotDiscoverable]
  9. public class WeatherImageConverter : IValueConverter
  10. {
  11. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  12. {
  13. var weather = value as WeatherInfo;
  14. if (weather != null)
  15. {
  16. switch (weather.CurrentWeather.Condition)
  17. {
  18. case WeatherConditions.Thunderstorm:
  19. return "../Images/Weather/Thunder.png";
  20. case WeatherConditions.Overcast:
  21. return "../Images/Weather/Overcast.png";
  22. case WeatherConditions.Mist:
  23. case WeatherConditions.Sleet:
  24. case WeatherConditions.Rain:
  25. return "../Images/Weather/Rain.png";
  26. case WeatherConditions.Blizzard:
  27. case WeatherConditions.Snow:
  28. return "../Images/Weather/Snow.png";
  29. default:
  30. return "../Images/Weather/Sunny.png";
  31. }
  32. }
  33. return null;
  34. }
  35. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  36. {
  37. throw new NotImplementedException();
  38. }
  39. }
  40. }