Files
SourMesen 40335ce735 UI: Update to Avalonia 12, .NET 10 and replace ReactiveUI with MVVM community toolkit (#142)
Also fixes DX11.0 support (for Win7 PCs that aren't fully updated), which stopped working after the recent variable refresh rate changes
2026-07-03 16:04:42 +09:00

41 lines
1.2 KiB
C#

using Avalonia.Controls;
using Avalonia.Rendering;
using Mesen.Localization;
using Mesen.Windows;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mesen.Utilities
{
public class MesenMsgBox
{
public static Task ShowException(Exception ex)
{
return MesenMsgBox.Show(null, "UnexpectedError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.Message + Environment.NewLine + ex.StackTrace);
}
public static Task<DialogResult> Show(Window? parent, string text, MessageBoxButtons buttons, MessageBoxIcon icon, params string[] args)
{
Window? wnd = parent as Window;
if(parent != null && wnd == null) {
throw new Exception("Invalid parent window");
}
string resourceText = ResourceHelper.GetMessage(text, args);
if(resourceText.StartsWith("[[")) {
if(args != null && args.Length > 0) {
return MessageBox.Show(wnd, string.Format("Critical error (" + text + ") {0}", args), "MesenCE", buttons, icon);
} else {
return MessageBox.Show(wnd, string.Format("Critical error (" + text + ")"), "MesenCE", buttons, icon);
}
} else {
return MessageBox.Show(wnd, ResourceHelper.GetMessage(text, args), "MesenCE", buttons, icon);
}
}
}
}