@@ -199,7 +199,7 @@ public async void OnLoaded()
199199 ButtonEnum . YesNo
200200 ) ;
201201
202- var result = await box . ShowAsync ( ) ;
202+ var result = await box . ShowAsPopupAsync ( GetParentWindow ( ) ) ;
203203
204204 if ( result . HasFlag ( ButtonResult . Yes ) )
205205 {
@@ -212,7 +212,7 @@ public async void OnLoaded()
212212 _logger . LogError ( ex , Assets . Resources . FailedUpdateMetadata ) ;
213213 await MessageBoxManager
214214 . GetMessageBoxStandard ( Assets . Resources . Error , string . Format ( Assets . Resources . FailedUpdateMetadataMessageBoxError , ex . Message ) , ButtonEnum . Ok )
215- . ShowAsync ( ) ;
215+ . ShowAsPopupAsync ( GetParentWindow ( ) ) ;
216216 }
217217 }
218218 }
@@ -228,7 +228,7 @@ await MessageBoxManager
228228 . GetMessageBoxStandard ( Assets . Resources . Warning , Assets . Resources . FailedLoadLocalMetadataMessageBoxWarning ,
229229 ButtonEnum . Ok ) ;
230230
231- await box . ShowAsync ( ) ;
231+ await box . ShowAsPopupAsync ( GetParentWindow ( ) ) ;
232232 }
233233
234234 try
@@ -241,7 +241,7 @@ await MessageBoxManager
241241 await MessageBoxManager
242242 . GetMessageBoxStandard ( Assets . Resources . Error , string . Format ( Assets . Resources . FailedLoadLocalMetadataMessageBoxError , ex . Message ) ,
243243 ButtonEnum . Ok )
244- . ShowAsync ( ) ;
244+ . ShowAsPopupAsync ( GetParentWindow ( ) ) ;
245245 }
246246
247247 if ( _configurationService . Config . CheckForAppUpdates )
@@ -255,7 +255,7 @@ await MessageBoxManager
255255 Assets . Resources . NewAppReleaseAvailable ,
256256 "https://github.com/xboxoneresearch/XboxPostcodeMonitor/releases"
257257 ) ) ;
258- await box . ShowAsync ( ) ;
258+ await box . ShowAsPopupAsync ( GetParentWindow ( ) ) ;
259259 }
260260 }
261261 }
@@ -328,7 +328,7 @@ private async Task SaveLogAsync()
328328 await MessageBoxManager
329329 . GetMessageBoxStandard ( Assets . Resources . Error , string . Format ( Assets . Resources . ErrorSavingLogFileMessageBoxError , ex . Message ) ,
330330 ButtonEnum . Ok )
331- . ShowAsync ( ) ;
331+ . ShowAsPopupAsync ( GetParentWindow ( ) ) ;
332332 }
333333 }
334334
@@ -370,7 +370,7 @@ private async Task ToggleConnectionAsync()
370370 await MessageBoxManager
371371 . GetMessageBoxStandard ( Assets . Resources . Error , string . Format ( Assets . Resources . ErrorConectionMessageBoxError , ex . Message ) ,
372372 ButtonEnum . Ok )
373- . ShowAsync ( ) ;
373+ . ShowAsPopupAsync ( GetParentWindow ( ) ) ;
374374 }
375375
376376 if ( IsConnected && _configurationService . Config . CheckForFwUpdates )
@@ -384,7 +384,7 @@ await MessageBoxManager
384384 Assets . Resources . NewFirmwareReleaseAvailable ,
385385 "https://github.com/xboxoneresearch/PicoDurangoPOST/releases"
386386 ) ) ;
387- await box . ShowAsync ( ) ;
387+ await box . ShowAsPopupAsync ( GetParentWindow ( ) ) ;
388388 }
389389 }
390390 }
@@ -441,12 +441,4 @@ private async Task ShowConfigurationAsync()
441441
442442 await dialog . ShowDialog ( GetParentWindow ( ) ) ;
443443 }
444-
445- private Window GetParentWindow ( )
446- {
447- if ( Avalonia . Application . Current ? . ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop )
448- return desktop ? . MainWindow ?? throw new Exception ( Assets . Resources . FailedGetMainWindow ) ;
449- else
450- throw new Exception ( Assets . Resources . FailedGetApplicationLifetime ) ;
451- }
452444}
0 commit comments