KeyboardInputViewModel.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using Avalonia.Svg.Skia;
  2. using CommunityToolkit.Mvvm.ComponentModel;
  3. using Ryujinx.Ava.UI.Models.Input;
  4. namespace Ryujinx.Ava.UI.ViewModels.Input
  5. {
  6. public partial class KeyboardInputViewModel : BaseModel
  7. {
  8. [ObservableProperty] private KeyboardInputConfig _config;
  9. private bool _isLeft;
  10. public bool IsLeft
  11. {
  12. get => _isLeft;
  13. set
  14. {
  15. _isLeft = value;
  16. OnPropertyChanged();
  17. OnPropertyChanged(nameof(HasSides));
  18. }
  19. }
  20. private bool _isRight;
  21. public bool IsRight
  22. {
  23. get => _isRight;
  24. set
  25. {
  26. _isRight = value;
  27. OnPropertyChanged();
  28. OnPropertyChanged(nameof(HasSides));
  29. }
  30. }
  31. public bool HasSides => IsLeft ^ IsRight;
  32. [ObservableProperty] private SvgImage _image;
  33. public readonly InputViewModel ParentModel;
  34. public KeyboardInputViewModel(InputViewModel model, KeyboardInputConfig config)
  35. {
  36. ParentModel = model;
  37. model.NotifyChangesEvent += OnParentModelChanged;
  38. OnParentModelChanged();
  39. Config = config;
  40. }
  41. public void OnParentModelChanged()
  42. {
  43. IsLeft = ParentModel.IsLeft;
  44. IsRight = ParentModel.IsRight;
  45. Image = ParentModel.Image;
  46. }
  47. }
  48. }