using FluentAvalonia.Core;
using FluentAvalonia.UI.Controls;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.HLE.FileSystem;
using System;
using System.ComponentModel;
namespace Ryujinx.Ava.UI.Windows
{
public partial class SettingsWindow : StyleableWindow
internal SettingsViewModel ViewModel { get; set; }
public SettingsWindow(VirtualFileSystem virtualFileSystem, ContentManager contentManager)
Title = $"Ryujinx {Program.Version} - {LocaleManager.Instance[LocaleKeys.Settings]}";
ViewModel = new SettingsViewModel(virtualFileSystem, contentManager);
DataContext = ViewModel;
ViewModel.CloseWindow += Close;
ViewModel.SaveSettingsEvent += SaveSettings;
InitializeComponent();
Load();
}
public SettingsWindow()
ViewModel = new SettingsViewModel();
public void SaveSettings()
InputPage.ControllerSettings?.SaveCurrentProfile();
if (Owner is MainWindow window && ViewModel.DirectoryChanged)
window.ViewModel.LoadApplications();
private void Load()
Pages.Children.Clear();
NavPanel.SelectionChanged += NavPanelOnSelectionChanged;
NavPanel.SelectedItem = NavPanel.MenuItems.ElementAt(0);
private void NavPanelOnSelectionChanged(object sender, NavigationViewSelectionChangedEventArgs e)
if (e.SelectedItem is NavigationViewItem navItem && navItem.Tag is not null)
switch (navItem.Tag.ToString())
case "UiPage":
UiPage.ViewModel = ViewModel;
NavPanel.Content = UiPage;
break;
case "InputPage":
NavPanel.Content = InputPage;
case "HotkeysPage":
NavPanel.Content = HotkeysPage;
case "SystemPage":
SystemPage.ViewModel = ViewModel;
NavPanel.Content = SystemPage;
case "CpuPage":
NavPanel.Content = CpuPage;
case "GraphicsPage":
NavPanel.Content = GraphicsPage;
case "AudioPage":
NavPanel.Content = AudioPage;
case "NetworkPage":
NavPanel.Content = NetworkPage;
case "LoggingPage":
NavPanel.Content = LoggingPage;
default:
throw new NotImplementedException();
protected override void OnClosing(CancelEventArgs e)
HotkeysPage.Dispose();
InputPage.Dispose();
base.OnClosing(e);