2024-03-25 18:19:16 -04:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
using Avalonia.Data.Converters;
|
|
|
|
|
using Avalonia.Media;
|
|
|
|
|
using SPTInstaller.CustomControls;
|
|
|
|
|
|
|
|
|
|
namespace SPTInstaller.Converters;
|
|
|
|
|
|
|
|
|
|
public class StateSpinnerStateToColorConverter : IValueConverter
|
|
|
|
|
{
|
|
|
|
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
|
|
|
{
|
2024-05-01 10:31:55 -04:00
|
|
|
|
if (value == null)
|
2024-03-25 18:19:16 -04:00
|
|
|
|
return null;
|
2024-05-01 10:31:55 -04:00
|
|
|
|
|
2024-03-25 18:19:16 -04:00
|
|
|
|
if (value is not StatusSpinner.SpinnerState state)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case StatusSpinner.SpinnerState.Pending:
|
|
|
|
|
return new SolidColorBrush(Colors.Gray);
|
|
|
|
|
case StatusSpinner.SpinnerState.Running:
|
|
|
|
|
return new SolidColorBrush(Colors.DodgerBlue);
|
|
|
|
|
case StatusSpinner.SpinnerState.OK:
|
|
|
|
|
return new SolidColorBrush(Colors.ForestGreen);
|
|
|
|
|
case StatusSpinner.SpinnerState.Warning:
|
|
|
|
|
return new SolidColorBrush(Colors.Goldenrod);
|
|
|
|
|
case StatusSpinner.SpinnerState.Error:
|
|
|
|
|
return new SolidColorBrush(Colors.Crimson);
|
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentOutOfRangeException();
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-01 10:31:55 -04:00
|
|
|
|
|
2024-03-25 18:19:16 -04:00
|
|
|
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
|
|
|
{
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
}
|