aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Plugins.DefaultTheme/Converters
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Plugins.DefaultTheme/Converters')
-rw-r--r--MediaBrowser.Plugins.DefaultTheme/Converters/TileBackgroundConverter.cs43
-rw-r--r--MediaBrowser.Plugins.DefaultTheme/Converters/WeatherImageConverter.cs43
2 files changed, 86 insertions, 0 deletions
diff --git a/MediaBrowser.Plugins.DefaultTheme/Converters/TileBackgroundConverter.cs b/MediaBrowser.Plugins.DefaultTheme/Converters/TileBackgroundConverter.cs
new file mode 100644
index 000000000..a7a964693
--- /dev/null
+++ b/MediaBrowser.Plugins.DefaultTheme/Converters/TileBackgroundConverter.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Globalization;
+using System.Windows.Data;
+using System.Windows.Media;
+
+namespace MediaBrowser.Plugins.DefaultTheme.Converters
+{
+ public class TileBackgroundConverter : IValueConverter
+ {
+ private static readonly Brush[] TileColors = new Brush[] {
+ new SolidColorBrush(Color.FromRgb((byte)111,(byte)189,(byte)69)),
+ new SolidColorBrush(Color.FromRgb((byte)75,(byte)179,(byte)221)),
+ new SolidColorBrush(Color.FromRgb((byte)65,(byte)100,(byte)165)),
+ new SolidColorBrush(Color.FromRgb((byte)225,(byte)32,(byte)38)),
+ new SolidColorBrush(Color.FromRgb((byte)128,(byte)0,(byte)128)),
+ new SolidColorBrush(Color.FromRgb((byte)0,(byte)128,(byte)64)),
+ new SolidColorBrush(Color.FromRgb((byte)0,(byte)148,(byte)255)),
+ new SolidColorBrush(Color.FromRgb((byte)255,(byte)0,(byte)199)),
+ new SolidColorBrush(Color.FromRgb((byte)255,(byte)135,(byte)15)),
+ new SolidColorBrush(Color.FromRgb((byte)127,(byte)0,(byte)55))
+
+ };
+
+ private static int _currentIndex = new Random(DateTime.Now.Millisecond).Next(0, TileColors.Length);
+
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ int index;
+
+ lock (TileColors)
+ {
+ index = (_currentIndex++) % TileColors.Length;
+ }
+
+ return TileColors[index++];
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new System.NotImplementedException();
+ }
+ }
+}
diff --git a/MediaBrowser.Plugins.DefaultTheme/Converters/WeatherImageConverter.cs b/MediaBrowser.Plugins.DefaultTheme/Converters/WeatherImageConverter.cs
new file mode 100644
index 000000000..0d73a1a6f
--- /dev/null
+++ b/MediaBrowser.Plugins.DefaultTheme/Converters/WeatherImageConverter.cs
@@ -0,0 +1,43 @@
+using MediaBrowser.Model.Weather;
+using System;
+using System.ComponentModel.Composition;
+using System.Globalization;
+using System.Windows.Data;
+
+namespace MediaBrowser.Plugins.DefaultTheme.Converters
+{
+ [PartNotDiscoverable]
+ public class WeatherImageConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ var weather = value as WeatherInfo;
+
+ if (weather != null)
+ {
+ switch (weather.CurrentWeather.Condition)
+ {
+ case WeatherConditions.Thunderstorm:
+ return "../Images/Weather/Thunder.png";
+ case WeatherConditions.Overcast:
+ return "../Images/Weather/Overcast.png";
+ case WeatherConditions.Mist:
+ case WeatherConditions.Sleet:
+ case WeatherConditions.Rain:
+ return "../Images/Weather/Rain.png";
+ case WeatherConditions.Blizzard:
+ case WeatherConditions.Snow:
+ return "../Images/Weather/Snow.png";
+ default:
+ return "../Images/Weather/Sunny.png";
+ }
+ }
+ return null;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}