This repository has been archived on 2026-03-14. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Eco/VideoBrowser/Controls/CefSharpBrowser/Converters/StringToImageConverter.cs
2023-07-24 12:00:34 +02:00

63 lines
2.1 KiB
C#

namespace VideoBrowser.Controls.CefSharpBrowser.Converters
{
using System;
using System.Globalization;
using System.Windows.Data;
using VideoBrowser.Controls.CefSharpBrowser.Helpers;
/// <summary>
/// Defines the <see cref="StringToImageConverter" />.
/// </summary>
public class StringToImageConverter : IValueConverter
{
#region Properties
/// <summary>
/// Gets the Instance.
/// </summary>
public static StringToImageConverter Instance { get; } = new StringToImageConverter();
#endregion Properties
#region Methods
/// <summary>
/// The Convert.
/// </summary>
/// <param name="value">The value<see cref="object"/>.</param>
/// <param name="targetType">The targetType<see cref="Type"/>.</param>
/// <param name="parameter">The parameter<see cref="object"/>.</param>
/// <param name="culture">The culture<see cref="CultureInfo"/>.</param>
/// <returns>The <see cref="object"/>.</returns>
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;
}
/// <summary>
/// The ConvertBack.
/// </summary>
/// <param name="value">The value<see cref="object"/>.</param>
/// <param name="targetType">The targetType<see cref="Type"/>.</param>
/// <param name="parameter">The parameter<see cref="object"/>.</param>
/// <param name="culture">The culture<see cref="CultureInfo"/>.</param>
/// <returns>The <see cref="object"/>.</returns>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion Methods
}
}