KeyboardInputViewModel.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using Avalonia.Svg.Skia;
  2. using Ryujinx.Ava.UI.Models.Input;
  3. namespace Ryujinx.Ava.UI.ViewModels.Input
  4. {
  5. public class KeyboardInputViewModel : BaseModel
  6. {
  7. private KeyboardInputConfig _config;
  8. public KeyboardInputConfig Config
  9. {
  10. get => _config;
  11. set
  12. {
  13. _config = value;
  14. OnPropertyChanged();
  15. }
  16. }
  17. private bool _isLeft;
  18. public bool IsLeft
  19. {
  20. get => _isLeft;
  21. set
  22. {
  23. _isLeft = value;
  24. OnPropertyChanged();
  25. OnPropertyChanged(nameof(HasSides));
  26. }
  27. }
  28. private bool _isRight;
  29. public bool IsRight
  30. {
  31. get => _isRight;
  32. set
  33. {
  34. _isRight = value;
  35. OnPropertyChanged();
  36. OnPropertyChanged(nameof(HasSides));
  37. }
  38. }
  39. public bool HasSides => IsLeft ^ IsRight;
  40. private SvgImage _image;
  41. public SvgImage Image
  42. {
  43. get => _image;
  44. set
  45. {
  46. _image = value;
  47. OnPropertyChanged();
  48. }
  49. }
  50. public readonly InputViewModel ParentModel;
  51. public KeyboardInputViewModel(InputViewModel model, KeyboardInputConfig config)
  52. {
  53. ParentModel = model;
  54. model.NotifyChangesEvent += OnParentModelChanged;
  55. OnParentModelChanged();
  56. Config = config;
  57. }
  58. public void OnParentModelChanged()
  59. {
  60. IsLeft = ParentModel.IsLeft;
  61. IsRight = ParentModel.IsRight;
  62. Image = ParentModel.Image;
  63. }
  64. }
  65. }