WaveProgressValueColorConverter.cs 813 B

12345678910111213141516171819202122232425
  1. using System;
  2. using System.Globalization;
  3. using Avalonia;
  4. using Avalonia.Data.Converters;
  5. using Avalonia.Media;
  6. using Avalonia.Styling;
  7. namespace SukiUI.Converters.WaveProgress;
  8. public class WaveProgressValueColorConverter : IValueConverter
  9. {
  10. public static readonly WaveProgressValueColorConverter Instance = new();
  11. public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
  12. {
  13. if (value is not double d) return Brushes.Black;
  14. if (d > 50) return Brushes.GhostWhite;
  15. return Application.Current?.ActualThemeVariant == ThemeVariant.Dark ? Brushes.GhostWhite : Brushes.Black;
  16. }
  17. public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
  18. {
  19. throw new NotSupportedException();
  20. }
  21. }