Wrap save and restore in tyy/catch blocks
This commit is contained in:
parent
ab38eb5571
commit
6dd885f0b2
@ -26,6 +26,8 @@ namespace LibationAvalonia
|
||||
public static void RestoreSizeAndLocation(this Window form, Configuration config)
|
||||
{
|
||||
if (Design.IsDesignMode) return;
|
||||
try
|
||||
{
|
||||
|
||||
FormSizeAndPosition savedState = config.GetNonString<FormSizeAndPosition>(form.GetType().Name);
|
||||
|
||||
@ -64,10 +66,17 @@ namespace LibationAvalonia
|
||||
// FINAL: for Maximized: start normal state, set size and location, THEN set max state
|
||||
form.WindowState = savedState.IsMaximized ? WindowState.Maximized : WindowState.Normal;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Serilog.Log.Logger.Error(ex, "Failed to save {form} size and location", form.GetType().Name);
|
||||
}
|
||||
}
|
||||
public static void SaveSizeAndLocation(this Window form, Configuration config)
|
||||
{
|
||||
if (Design.IsDesignMode) return;
|
||||
|
||||
try
|
||||
{
|
||||
var saveState = new FormSizeAndPosition();
|
||||
|
||||
saveState.IsMaximized = form.WindowState == WindowState.Maximized;
|
||||
@ -86,6 +95,11 @@ namespace LibationAvalonia
|
||||
|
||||
config.SetObject(form.GetType().Name, saveState);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Serilog.Log.Logger.Error(ex, "Failed to save {form} size and location", form.GetType().Name);
|
||||
}
|
||||
}
|
||||
|
||||
class FormSizeAndPosition
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user