2023-08-24 22:28:37 -04:00
|
|
|
|
using Avalonia.Data.Converters;
|
|
|
|
|
using SPTInstaller.CustomControls;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
|
|
|
|
namespace SPTInstaller.Converters;
|
2024-05-01 10:31:55 -04:00
|
|
|
|
|
2023-08-24 22:28:37 -04:00
|
|
|
|
public class StatusSpinnerIsStateConverter : IValueConverter
|
|
|
|
|
{
|
|
|
|
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
|
|
|
{
|
2024-05-01 10:31:55 -04:00
|
|
|
|
if (value == null || parameter == null)
|
2023-08-24 22:28:37 -04:00
|
|
|
|
return null;
|
2024-05-01 10:31:55 -04:00
|
|
|
|
|
2023-08-24 22:28:37 -04:00
|
|
|
|
if (value is not StatusSpinner.SpinnerState state)
|
|
|
|
|
return null;
|
2024-05-01 10:31:55 -04:00
|
|
|
|
|
2023-08-24 22:28:37 -04:00
|
|
|
|
if (parameter is not string stateName)
|
|
|
|
|
return null;
|
2024-05-01 10:31:55 -04:00
|
|
|
|
|
2023-08-24 22:28:37 -04:00
|
|
|
|
return state.ToString().ToLower() == stateName.ToLower();
|
|
|
|
|
}
|
2024-05-01 10:31:55 -04:00
|
|
|
|
|
2023-08-24 22:28:37 -04:00
|
|
|
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
|
|
|
{
|
|
|
|
|
return value;
|
|
|
|
|
}
|
2024-05-01 10:31:55 -04:00
|
|
|
|
}
|