add Helper API to workaround shitty Avalonia API

This commit is contained in:
Florian Stinglmayr 2024-11-08 10:24:48 +01:00
parent 93d9dc7860
commit 4df98148fa

View File

@ -0,0 +1,31 @@
using Avalonia;
using Avalonia.Controls;
using MsBox.Avalonia;
namespace EliteBGS;
public class Helper {
public static void MessageBox(Window owner, string caption, string text) {
var box = MessageBoxManager
.GetMessageBoxStandard(caption, text)
;
var result = box.ShowAsPopupAsync(owner);
result.Wait();
}
public static string? OpenFileDialog(Window owner) {
OpenFileDialog dlg = new OpenFileDialog();
dlg.AllowMultiple = false;
var result = dlg.ShowAsync(owner);
result.Wait();
var filename = result.Result;
if (filename == null || filename.Length <= 0) {
return null;
}
return filename[0];
}
}