using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Data; using Microsoft.UI; using DashCaddy.Desktop.ViewModels; using Windows.UI; namespace DashCaddy.Desktop.ViewModels; public class StatusToColorConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { if (value is ServiceHealth health) { return health switch { ServiceHealth.Healthy => new SolidColorBrush(Colors.LimeGreen), ServiceHealth.Degraded => new SolidColorBrush(Colors.Gold), ServiceHealth.Unhealthy => new SolidColorBrush(Colors.Red), _ => new SolidColorBrush(Colors.Gray) }; } if (value is bool boolVal) { return boolVal ? new SolidColorBrush(Colors.LimeGreen) : new SolidColorBrush(Colors.Red); } return new SolidColorBrush(Colors.Gray); } public object ConvertBack(object value, Type targetType, object parameter, string language) => throw new NotImplementedException(); } public class StatusToTextConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { if (value is ServiceHealth health) { return health switch { ServiceHealth.Healthy => "Healthy", ServiceHealth.Degraded => "Degraded", ServiceHealth.Unhealthy => "Unhealthy", _ => "Unknown" }; } return "Unknown"; } public object ConvertBack(object value, Type targetType, object parameter, string language) => throw new NotImplementedException(); } public class BoolToVisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { if (value is bool boolVal) { return boolVal ? Visibility.Visible : Visibility.Collapsed; } return Visibility.Collapsed; } public object ConvertBack(object value, Type targetType, object parameter, string language) => throw new NotImplementedException(); } public class InverseBoolConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { if (value is bool boolVal) return !boolVal; return true; } public object ConvertBack(object value, Type targetType, object parameter, string language) => throw new NotImplementedException(); }