misc: Created generic type RyujinxControl to allow for more unified control view model definitions

This commit is contained in:
Evan Husted
2025-03-02 21:24:39 -06:00
parent 69d79322bb
commit da3f4e1d3a
25 changed files with 136 additions and 155 deletions

View File

@@ -6,6 +6,7 @@ using Gommon;
using LibHac.Common;
using LibHac.Ns;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.Controls;
using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Ava.UI.Windows;
@@ -25,10 +26,9 @@ using System.Threading.Tasks;
namespace Ryujinx.Ava.UI.Views.Main
{
public partial class MainMenuBarView : UserControl
public partial class MainMenuBarView : RyujinxControl<MainWindowViewModel>
{
public MainWindow Window { get; private set; }
public MainWindowViewModel ViewModel { get; private set; }
public MainMenuBarView()
{

View File

@@ -4,6 +4,8 @@ using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Threading;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.Controls;
using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Ava.UI.Windows;
using Ryujinx.Ava.Utilities.Configuration;
using Ryujinx.Common;
@@ -13,7 +15,7 @@ using System;
namespace Ryujinx.Ava.UI.Views.Main
{
public partial class MainStatusBarView : UserControl
public partial class MainStatusBarView : RyujinxControl<MainWindowViewModel>
{
public MainWindow Window;
@@ -29,7 +31,7 @@ namespace Ryujinx.Ava.UI.Views.Main
if (VisualRoot is MainWindow window)
{
Window = window;
DataContext = window.ViewModel;
ViewModel = window.ViewModel;
LocaleManager.Instance.LocaleChanged += () => Dispatcher.UIThread.Post(() =>
{
if (Window.ViewModel.EnableNonGameRunningControls)

View File

@@ -3,16 +3,15 @@ using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using Ryujinx.Ava.Common;
using Ryujinx.Ava.UI.Controls;
using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Ava.UI.Windows;
using System;
namespace Ryujinx.Ava.UI.Views.Main
{
public partial class MainViewControls : UserControl
public partial class MainViewControls : RyujinxControl<MainWindowViewModel>
{
public MainWindowViewModel ViewModel;
public MainViewControls()
{
InitializeComponent();
@@ -24,7 +23,7 @@ namespace Ryujinx.Ava.UI.Views.Main
if (VisualRoot is MainWindow window)
{
DataContext = ViewModel = window.ViewModel;
ViewModel = window.ViewModel;
}
}