55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Data;
|
|
using System.Windows.Interactivity;
|
|
using System.Windows.Media;
|
|
|
|
namespace MECF.Framework.UI.Client.CenterViews.Maintain
|
|
{
|
|
public class BooleanToUIColorConverter : Behavior<BooleanToUIColorConverter>, IValueConverter
|
|
{
|
|
public Color FalseColor
|
|
{
|
|
get { return (Color)GetValue(FalseColorProperty); }
|
|
set { SetValue(FalseColorProperty, value); }
|
|
}
|
|
|
|
public static readonly DependencyProperty FalseColorProperty =
|
|
DependencyProperty.Register("FalseColor", typeof(Color), typeof(BooleanToUIColorConverter), new PropertyMetadata(Colors.Black));
|
|
|
|
public Color TrueColor
|
|
{
|
|
get { return (Color)GetValue(TrueColorProperty); }
|
|
set { SetValue(TrueColorProperty, value); }
|
|
}
|
|
|
|
public static readonly DependencyProperty TrueColorProperty =
|
|
DependencyProperty.Register("TrueColor", typeof(Color), typeof(BooleanToUIColorConverter), new PropertyMetadata(Colors.Green));
|
|
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value is bool state)
|
|
{
|
|
if (state)
|
|
return new SolidColorBrush(TrueColor);
|
|
else
|
|
{
|
|
return new SolidColorBrush(FalseColor);
|
|
}
|
|
}
|
|
|
|
return new SolidColorBrush(FalseColor);
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|