namespace VideoBrowser.Controls.CefSharpBrowser.Converters
{
using System;
using System.Globalization;
using System.Windows.Data;
using VideoBrowser.Controls.CefSharpBrowser.Helpers;
///
/// Defines the .
///
public class StringToImageConverter : IValueConverter
{
#region Properties
///
/// Gets the Instance.
///
public static StringToImageConverter Instance { get; } = new StringToImageConverter();
#endregion Properties
#region Methods
///
/// The Convert.
///
/// The value.
/// The targetType.
/// The parameter.
/// The culture.
/// The .
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is string imageString) || string.IsNullOrEmpty(imageString))
{
return null;
}
if (imageString.IsImageUrl())
{
return imageString;
}
var imageSource = imageString.FindIconForFilename(true);
return imageSource;
}
///
/// The ConvertBack.
///
/// The value.
/// The targetType.
/// The parameter.
/// The culture.
/// The .
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion Methods
}
}