Fix MessageBox crash when UI has no Screens (#708)

This commit is contained in:
Mbucari 2023-08-11 09:04:05 -06:00
parent 893d68190d
commit ff3ac2d6fd
2 changed files with 7 additions and 4 deletions

View File

@ -177,9 +177,12 @@ Libation.
tbx.MinWidth = vm.TextBlockMinWidth;
tbx.Text = message;
var thisScreen = owner.Screens.ScreenFromVisual(owner);
var maxSize = new Size(0.20 * thisScreen.Bounds.Width, 0.9 * thisScreen.Bounds.Height - 55);
var thisScreen = owner.Screens?.ScreenFromVisual(owner);
var maxSize
= thisScreen is null ? owner.ClientSize
: new Size(0.20 * thisScreen.Bounds.Width, 0.9 * thisScreen.Bounds.Height - 55);
var desiredMax = new Size(maxSize.Width, maxSize.Height);

View File

@ -21,7 +21,7 @@ namespace LibationAvalonia.Views
InitializeComponent();
Configure_Upgrade();
Loaded += MainWindow_Loaded;
Opened += MainWindow_Opened;
Closing += MainWindow_Closing;
LibraryLoaded += MainWindow_LibraryLoaded;
@ -35,7 +35,7 @@ namespace LibationAvalonia.Views
}
}
private async void MainWindow_Loaded(object sender, EventArgs e)
private async void MainWindow_Opened(object sender, EventArgs e)
{
if (Configuration.Instance.FirstLaunch)
{