2026-01-26 14:51:28 +09:00

60 lines
1.7 KiB
C#

/*
* Copyright (c) 2022 LG Electronics Inc.
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;
namespace AuroraUIComponent.UIConverter
{
public class BoolToBrushConverter : IValueConverter
{
public Brush True { get; set; }
public Brush False { get; set; }
public object Convert(object value, Type targetType,
object parameter, CultureInfo culture)
{
try {
if (value is bool tf)
return tf ? True : False;
return Brushes.Transparent;
} catch {
return Brushes.Transparent;
}
}
public object ConvertBack(object value, Type targetType,
object parameter, CultureInfo culture)
=> throw new NotImplementedException();
}
public class StringToBrushConverter : IValueConverter
{
private BrushConverter convert = new BrushConverter();
public object Convert(object value, Type targetType,
object parameter, CultureInfo culture)
{
try {
if (value is string brushStr && !string.IsNullOrEmpty(brushStr))
return convert.ConvertFromString(brushStr);
return Brushes.Transparent;
} catch {
return Brushes.Transparent;
}
}
public object ConvertBack(object value, Type targetType,
object parameter, CultureInfo culture)
=> throw new NotImplementedException();
}
}