Files
GeekDesk/Converts/TextToColorConverter.cs
2025-03-07 10:59:39 +08:00

31 lines
880 B
C#

using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
namespace GeekDesk.Converts
{
internal class TextToColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return null;
}
string str = value as string;
return new SolidColorBrush((Color)ColorConverter.ConvertFromString(str));
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return null;
}
string str = value as string;
return new SolidColorBrush((Color)ColorConverter.ConvertFromString(str));
}
}
}