2022-05-15 13:30:15 +02:00
|
|
|
using Avalonia;
|
|
|
|
using Avalonia.Controls;
|
|
|
|
using Avalonia.Interactivity;
|
|
|
|
using Avalonia.Threading;
|
|
|
|
using Ryujinx.Ava.Common.Locale;
|
2022-12-29 15:24:05 +01:00
|
|
|
using Ryujinx.Ava.UI.Windows;
|
2022-05-15 13:30:15 +02:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
2022-12-29 15:24:05 +01:00
|
|
|
namespace Ryujinx.Ava.UI.Applet
|
2022-05-15 13:30:15 +02:00
|
|
|
{
|
2022-07-24 19:38:38 +02:00
|
|
|
internal partial class ErrorAppletWindow : StyleableWindow
|
2022-05-15 13:30:15 +02:00
|
|
|
{
|
|
|
|
private readonly Window _owner;
|
|
|
|
private object _buttonResponse;
|
|
|
|
|
|
|
|
public ErrorAppletWindow(Window owner, string[] buttons, string message)
|
|
|
|
{
|
|
|
|
_owner = owner;
|
|
|
|
Message = message;
|
|
|
|
DataContext = this;
|
|
|
|
InitializeComponent();
|
|
|
|
#if DEBUG
|
|
|
|
this.AttachDevTools();
|
|
|
|
#endif
|
|
|
|
int responseId = 0;
|
|
|
|
|
|
|
|
if (buttons != null)
|
|
|
|
{
|
|
|
|
foreach (string buttonText in buttons)
|
|
|
|
{
|
|
|
|
AddButton(buttonText, responseId);
|
|
|
|
responseId++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-01-03 19:45:08 +01:00
|
|
|
AddButton(LocaleManager.Instance[LocaleKeys.InputDialogOk], 0);
|
2022-05-15 13:30:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public ErrorAppletWindow()
|
|
|
|
{
|
|
|
|
DataContext = this;
|
|
|
|
InitializeComponent();
|
|
|
|
#if DEBUG
|
|
|
|
this.AttachDevTools();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
public string Message { get; set; }
|
|
|
|
|
|
|
|
private void AddButton(string label, object tag)
|
|
|
|
{
|
|
|
|
Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
{
|
|
|
|
Button button = new() { Content = label, Tag = tag };
|
|
|
|
|
|
|
|
button.Click += Button_Click;
|
|
|
|
ButtonStack.Children.Add(button);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
if (sender is Button button)
|
|
|
|
{
|
|
|
|
_buttonResponse = button.Tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<object> Run()
|
|
|
|
{
|
|
|
|
await ShowDialog(_owner);
|
|
|
|
|
|
|
|
return _buttonResponse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|