using Aitex.Core.RT.Log; using System; using System.Collections.Generic; using System.Drawing; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; using System.Windows.Media; namespace MECF.Framework.UI.Core.Converters { public class BoolToBrushConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { try { bool isOpen = (bool)value; if (isOpen) { return System.Windows.Media.Brushes.White; } else { return System.Windows.Media.Brushes.Black; } } catch (Exception ex) { LOG.Write(ex); } return System.Windows.Media.Brushes.Black; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { try { System.Windows.Media.Brush brush = (SolidColorBrush)value; System.Windows.Media.Color color = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(brush.ToString()); return color; } catch (Exception ex) { LOG.Write(ex); } return Colors.Black; } } }