add Helper API to workaround shitty Avalonia API
This commit is contained in:
parent
93d9dc7860
commit
4df98148fa
31
Avalonia.EliteBGS/Helper.cs
Normal file
31
Avalonia.EliteBGS/Helper.cs
Normal 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];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user