Added Maglink RTK GNSS receiver integration with correct BLE UUIDs and device name filtering (ML-* prefix). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
69 lines
2.4 KiB
C#
69 lines
2.4 KiB
C#
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();
|
|
}
|