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