WaveProgress.axaml.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using Avalonia;
  2. using Avalonia.Controls;
  3. using Avalonia.Markup.Xaml;
  4. namespace SukiUI.Controls;
  5. public partial class WaveProgress : UserControl
  6. {
  7. public WaveProgress()
  8. {
  9. InitializeComponent();
  10. var theme = SukiTheme.GetInstance();
  11. theme.OnBaseThemeChanged += _ =>
  12. {
  13. Value++;
  14. Value--;
  15. };
  16. theme.OnColorThemeChanged += _ =>
  17. {
  18. Value++;
  19. Value--;
  20. };
  21. }
  22. private void InitializeComponent()
  23. {
  24. AvaloniaXamlLoader.Load(this);
  25. }
  26. public static readonly StyledProperty<double> ValueProperty =
  27. AvaloniaProperty.Register<WaveProgress, double>(nameof(Value), defaultValue: 50);
  28. public double Value
  29. {
  30. get => GetValue(ValueProperty);
  31. set
  32. {
  33. if (value is >= 0 and <= 100)
  34. SetValue(ValueProperty, value);
  35. }
  36. }
  37. public static readonly StyledProperty<bool> IsTextVisibleProperty = AvaloniaProperty.Register<WaveProgress, bool>(nameof(IsTextVisible), defaultValue: true);
  38. public bool IsTextVisible
  39. {
  40. get => GetValue(IsTextVisibleProperty);
  41. set => SetValue(IsTextVisibleProperty, value);
  42. }
  43. }