RumbleInputView.axaml.cs
1 using Avalonia.Controls; 2 using FluentAvalonia.UI.Controls; 3 using Ryujinx.Ava.Common.Locale; 4 using Ryujinx.Ava.UI.ViewModels.Input; 5 using System.Threading.Tasks; 6 7 namespace Ryujinx.Ava.UI.Views.Input 8 { 9 public partial class RumbleInputView : UserControl 10 { 11 private readonly RumbleInputViewModel _viewModel; 12 13 public RumbleInputView() 14 { 15 InitializeComponent(); 16 } 17 18 public RumbleInputView(ControllerInputViewModel viewModel) 19 { 20 var config = viewModel.Config; 21 22 _viewModel = new RumbleInputViewModel 23 { 24 StrongRumble = config.StrongRumble, 25 WeakRumble = config.WeakRumble, 26 }; 27 28 InitializeComponent(); 29 30 DataContext = _viewModel; 31 } 32 33 public static async Task Show(ControllerInputViewModel viewModel) 34 { 35 RumbleInputView content = new(viewModel); 36 37 ContentDialog contentDialog = new() 38 { 39 Title = LocaleManager.Instance[LocaleKeys.ControllerRumbleTitle], 40 PrimaryButtonText = LocaleManager.Instance[LocaleKeys.ControllerSettingsSave], 41 SecondaryButtonText = "", 42 CloseButtonText = LocaleManager.Instance[LocaleKeys.ControllerSettingsClose], 43 Content = content, 44 }; 45 46 contentDialog.PrimaryButtonClick += (sender, args) => 47 { 48 var config = viewModel.Config; 49 config.StrongRumble = content._viewModel.StrongRumble; 50 config.WeakRumble = content._viewModel.WeakRumble; 51 }; 52 53 await contentDialog.ShowAsync(); 54 } 55 } 56 }