Ryujinx/Ryujinx.Ava/UI/Windows/DownloadableContentManagerWindow.axaml.cs
Isaac Marovitz c9e15b31b7
Buttons
2023-02-08 21:38:06 -05:00

79 lines
No EOL
2.5 KiB
C#

using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Styling;
using FluentAvalonia.UI.Controls;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.Models;
using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.HLE.FileSystem;
using Ryujinx.Ui.Common.Helper;
using System.Threading.Tasks;
using Button = FluentAvalonia.UI.Controls.Button;
namespace Ryujinx.Ava.UI.Windows
{
public partial class DownloadableContentManagerWindow : UserControl
{
public DownloadableContentManagerViewModel ViewModel;
public DownloadableContentManagerWindow()
{
DataContext = this;
InitializeComponent();
}
public DownloadableContentManagerWindow(VirtualFileSystem virtualFileSystem, ulong titleId, string titleName)
{
DataContext = ViewModel = new DownloadableContentManagerViewModel(virtualFileSystem, titleId, titleName);
InitializeComponent();
// RemoveButton.IsEnabled = false;
// DlcDataGrid.SelectionChanged += DlcDataGrid_SelectionChanged;
}
public static async Task Show(VirtualFileSystem virtualFileSystem, ulong titleId, string titleName)
{
ContentDialog contentDialog = new()
{
PrimaryButtonText = "",
SecondaryButtonText = "",
CloseButtonText = "",
Content = new DownloadableContentManagerWindow(virtualFileSystem, titleId, titleName),
Title = string.Format(LocaleManager.Instance[LocaleKeys.DlcWindowTitle], titleName, titleId.ToString("X16"))
};
Style bottomBorder = new(x => x.OfType<Grid>().Name("DialogSpace").Child().OfType<Border>());
bottomBorder.Setters.Add(new Setter(IsVisibleProperty, false));
contentDialog.Styles.Add(bottomBorder);
await ContentDialogHelper.ShowAsync(contentDialog);
}
public void SaveAndClose()
{
ViewModel.Save();
((ContentDialog)Parent).Hide();
}
private void RemoveDLC(object sender, RoutedEventArgs e)
{
ViewModel.RemoveSelected();
}
private void OpenLocation(object sender, RoutedEventArgs e)
{
if (sender is Button button)
{
if (button.DataContext is DownloadableContentModel model)
{
OpenHelper.LocateFile(model.ContainerPath);
}
}
}
}
}