2023-07-12 09:29:02 +02:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
using Avalonia.Data.Converters;
|
2023-05-11 23:11:39 -04:00
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
namespace SPTInstaller.Converters;
|
|
|
|
|
|
|
|
|
|
public class InvertedProgressConverter : IValueConverter
|
2023-05-11 23:11:39 -04:00
|
|
|
|
{
|
2023-07-12 09:19:33 +02:00
|
|
|
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
2023-05-11 23:11:39 -04:00
|
|
|
|
{
|
2023-07-12 09:29:02 +02:00
|
|
|
|
if (value is int progress)
|
2023-05-11 23:11:39 -04:00
|
|
|
|
{
|
2023-07-12 09:19:33 +02:00
|
|
|
|
return 100 - progress;
|
2023-05-11 23:11:39 -04:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
return value;
|
|
|
|
|
}
|
2023-05-11 23:11:39 -04:00
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
|
|
|
{
|
2023-07-12 09:29:02 +02:00
|
|
|
|
if (value is int invertedProgress)
|
2023-07-12 09:19:33 +02:00
|
|
|
|
{
|
|
|
|
|
return 100 - invertedProgress;
|
2023-05-11 23:11:39 -04:00
|
|
|
|
}
|
2023-07-12 09:19:33 +02:00
|
|
|
|
|
|
|
|
|
return value;
|
2023-05-11 23:11:39 -04:00
|
|
|
|
}
|
2023-07-12 09:19:33 +02:00
|
|
|
|
}
|