45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
using System.Globalization;
|
|
using Avalonia.Data.Converters;
|
|
using Avalonia.Media;
|
|
|
|
namespace ClaudeDo.Ui.Converters;
|
|
|
|
public class StatusColorConverter : IValueConverter
|
|
{
|
|
public static StatusColorConverter Instance { get; } = new();
|
|
|
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
var status = value?.ToString()?.ToLowerInvariant();
|
|
return status switch
|
|
{
|
|
"queued" => Brushes.DodgerBlue,
|
|
"running" => Brushes.Orange,
|
|
"waitingforreview" => Brushes.MediumPurple,
|
|
"waiting_for_review" => Brushes.MediumPurple,
|
|
"waitingforchildren" => Brushes.DarkOrange,
|
|
"done" => Brushes.Green,
|
|
"failed" => Brushes.Red,
|
|
"manual" => Brushes.Gray,
|
|
_ => Brushes.Transparent,
|
|
};
|
|
}
|
|
|
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
=> throw new NotSupportedException();
|
|
}
|
|
|
|
public class ConnectionColorConverter : IValueConverter
|
|
{
|
|
public static ConnectionColorConverter Instance { get; } = new();
|
|
|
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
var text = value?.ToString();
|
|
return text == "Online" ? Brushes.Green : Brushes.Red;
|
|
}
|
|
|
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
=> throw new NotSupportedException();
|
|
}
|