Multiprocotol Terminalprogram (BAT)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
MultiTerm/MultiTerm.Wpf/ValueConverters/ProtocolConnectionStateToBr...

34 lines
1.2 KiB

using MultiTerm.Protocols.Types;
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
namespace MultiTerm.Wpf.ValueConverters;
/// <summary>
/// Converts a <see cref="ProtocolConnectionState"/> to a acoordingly colored <see cref="Brush"/>.
/// </summary>
[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();
}
}