blob: ec6f76825401768835d66465d23fdc5a044d69cf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Threading;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.Windows;
using System.Threading.Tasks;
namespace Ryujinx.Ava.UI.Applet
{
internal partial class ErrorAppletWindow : StyleableWindow
{
private readonly Window _owner;
private object _buttonResponse;
public ErrorAppletWindow(Window owner, string[] buttons, string message)
{
_owner = owner;
Message = message;
DataContext = this;
InitializeComponent();
int responseId = 0;
if (buttons != null)
{
foreach (string buttonText in buttons)
{
AddButton(buttonText, responseId);
responseId++;
}
}
else
{
AddButton(LocaleManager.Instance[LocaleKeys.InputDialogOk], 0);
}
}
public ErrorAppletWindow()
{
DataContext = this;
InitializeComponent();
}
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;
}
}
}
|