using System.Globalization; using FieldLogger.Models; using FieldLogger.Services; namespace FieldLogger.Converters; public sealed class ConnectionStateToColorConverter : IValueConverter { public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => value switch { ConnectionState.Connected => Colors.LimeGreen, ConnectionState.Connecting => Colors.Orange, _ => Colors.IndianRed, }; public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotSupportedException(); } public sealed class ConnectionStateToTextConverter : IValueConverter { public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => value switch { ConnectionState.Connected => "Connected", ConnectionState.Connecting => "Connecting…", _ => "Disconnected", }; public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotSupportedException(); } public sealed class UtilityToNameConverter : IValueConverter { public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => value is int i ? ((UmUtility)i).ToString() : ""; public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotSupportedException(); } public sealed class InvertBoolConverter : IValueConverter { public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => value is bool b && !b; public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => value is bool b && !b; } public sealed class FixStatusToNameConverter : IValueConverter { public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => value is int i ? (GnssFixStatus)i switch { GnssFixStatus.NoFix => "No Fix", GnssFixStatus.Single => "Single", GnssFixStatus.Dgps => "DGPS", GnssFixStatus.RtkFixed => "RTK Fixed", GnssFixStatus.RtkFloat => "RTK Float", _ => "?", } : "—"; public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotSupportedException(); }