2025-02-10 20:53:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
|
|
2025-04-24 20:56:44 +08:00
|
|
|
|
using WPFluent.Controls;
|
|
|
|
|
|
|
2025-02-10 20:53:40 +08:00
|
|
|
|
namespace WPFluent.Converters;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Converts an <see cref="IconSourceElement"/> to an <see cref="IconElement"/>.
|
|
|
|
|
|
/// </summary>
|
2025-04-24 20:56:44 +08:00
|
|
|
|
internal class IconSourceElementConverter : IValueConverter
|
2025-02-10 20:53:40 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Converts a value to an <see cref="IconElement"/>.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="value">The value to convert.</param>
|
|
|
|
|
|
/// <param name="targetType">The type of the binding target property.</param>
|
|
|
|
|
|
/// <param name="parameter">The converter parameter.</param>
|
|
|
|
|
|
/// <param name="culture">The culture to use in the converter.</param>
|
|
|
|
|
|
/// <returns>The converted <see cref="IconElement"/>.</returns>
|
|
|
|
|
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
|
|
|
|
{
|
2025-04-24 20:56:44 +08:00
|
|
|
|
if (value is IconSourceElement iconSourceElement)
|
2025-02-10 20:53:40 +08:00
|
|
|
|
{
|
|
|
|
|
|
return iconSourceElement.CreateIconElement();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Converts an <see cref="IconElement"/> back to an IconSourceElement.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="value">The value to convert.</param>
|
|
|
|
|
|
/// <param name="targetType">The type of the binding target property.</param>
|
|
|
|
|
|
/// <param name="parameter">The converter parameter.</param>
|
|
|
|
|
|
/// <param name="culture">The culture to use in the converter.</param>
|
|
|
|
|
|
/// <returns>The converted IconSourceElement.</returns>
|
|
|
|
|
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
|
|
|
|
{ throw new NotImplementedException(); }
|
|
|
|
|
|
}
|