27 lines
683 B
C#
27 lines
683 B
C#
using System.Globalization;
|
|
using Avalonia.Data.Converters;
|
|
using Avalonia.Media;
|
|
|
|
namespace PSCHelpdesk.Plugins.HetznerServer.Converter;
|
|
|
|
public class StatusConverter: IValueConverter
|
|
{
|
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
var brush = new SolidColorBrush();
|
|
brush.Color = Colors.Green;
|
|
|
|
if (value.Equals("running")) return brush;
|
|
|
|
brush.Color = Colors.Red;
|
|
|
|
return brush;
|
|
}
|
|
|
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
if (value.Equals("RUNNING")) return "green";
|
|
|
|
return "red";
|
|
}
|
|
} |