From 17c1fd576057bdd2d6aea517d733fe8af6e6b2ba Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Sat, 23 Feb 2013 10:58:08 -0500 Subject: moved ui to it's own repo --- MediaBrowser.UI/Converters/UserImageConverter.cs | 97 ------------------------ 1 file changed, 97 deletions(-) delete mode 100644 MediaBrowser.UI/Converters/UserImageConverter.cs (limited to 'MediaBrowser.UI/Converters/UserImageConverter.cs') diff --git a/MediaBrowser.UI/Converters/UserImageConverter.cs b/MediaBrowser.UI/Converters/UserImageConverter.cs deleted file mode 100644 index f979107c8..000000000 --- a/MediaBrowser.UI/Converters/UserImageConverter.cs +++ /dev/null @@ -1,97 +0,0 @@ -using MediaBrowser.Model.Dto; -using MediaBrowser.Model.Net; -using System; -using System.Globalization; -using System.Windows.Data; - -namespace MediaBrowser.UI.Converters -{ - /// - /// Class UserImageConverter - /// - public class UserImageConverter : IValueConverter - { - /// - /// Converts a value. - /// - /// The value produced by the binding source. - /// The type of the binding target property. - /// The converter parameter to use. - /// The culture to use in the converter. - /// A converted value. If the method returns null, the valid null value is used. - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - var user = value as UserDto; - - if (user != null && user.HasPrimaryImage) - { - var config = parameter as string; - - int? maxWidth = null; - int? maxHeight = null; - int? width = null; - int? height = null; - - if (!string.IsNullOrEmpty(config)) - { - var vals = config.Split(','); - - width = GetSize(vals[0]); - height = GetSize(vals[1]); - maxWidth = GetSize(vals[2]); - maxHeight = GetSize(vals[3]); - } - - var uri = App.Instance.ApiClient.GetUserImageUrl(user, new ImageOptions - { - Width = width, - Height = height, - MaxWidth = maxWidth, - MaxHeight = maxHeight, - Quality = 100 - }); - - try - { - return App.Instance.GetRemoteBitmapAsync(uri).Result; - } - catch (HttpException) - { - - } - } - - return null; - } - - /// - /// Gets the size. - /// - /// The val. - /// System.Nullable{System.Int32}. - private int? GetSize(string val) - { - if (string.IsNullOrEmpty(val) || val == "0") - { - return null; - } - - return int.Parse(val); - } - - - /// - /// Converts a value. - /// - /// The value that is produced by the binding target. - /// The type to convert to. - /// The converter parameter to use. - /// The culture to use in the converter. - /// A converted value. If the method returns null, the valid null value is used. - /// - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} -- cgit v1.2.3