jellyfin-server/MediaBrowser.UI/Converters/WeatherTemperatureConverter.cs
2012-09-20 11:25:22 -04:00

32 lines
965 B
C#

using MediaBrowser.Model.Weather;
using System;
using System.Globalization;
using System.Windows.Data;
namespace MediaBrowser.UI.Converters
{
public class WeatherTemperatureConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var weather = value as WeatherInfo;
if (weather != null)
{
if (App.Instance.ServerConfiguration.WeatherUnit == WeatherUnits.Celsius)
{
return weather.CurrentWeather.TemperatureCelsius + "°C";
}
return weather.CurrentWeather.TemperatureFahrenheit + "°F";
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}