using MultiTerm.Protocols.Types; using System; using System.Globalization; using System.Windows.Data; using System.Windows.Media; namespace MultiTerm.Wpf.ValueConverters; /// /// Converts a to a acoordingly colored . /// [ValueConversion(typeof(ProtocolConnectionState), typeof(Brush))] public class ProtocolConnectionStateToBrushConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is not ProtocolConnectionState protocolConnectionState) { throw new ArgumentException($"Wrong object provided, can only convert from type {nameof(ProtocolConnectionState)}"); } return protocolConnectionState switch { ProtocolConnectionState.NotConnected => Brushes.LightGray, ProtocolConnectionState.Connected => Brushes.LightGreen, ProtocolConnectionState.UnintentionallyDisconnected => Brushes.OrangeRed, _ => throw new NotImplementedException(), }; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }