diff --git a/NAPS2.Lib/EtoForms/EtoDialogBase.cs b/NAPS2.Lib/EtoForms/EtoDialogBase.cs index 524e6c968b..c14b85aac0 100644 --- a/NAPS2.Lib/EtoForms/EtoDialogBase.cs +++ b/NAPS2.Lib/EtoForms/EtoDialogBase.cs @@ -23,12 +23,18 @@ protected EtoDialogBase(Naps2Config config) EtoPlatform.Current.InitForm(this); } - protected abstract void BuildLayout(); + protected virtual void BuildLayout() + { + FormStateController.LoadState(); + } protected override void OnPreLoad(EventArgs e) { - FormStateController.LoadState(); BuildLayout(); + if (!FormStateController.Loaded) + { + throw new InvalidOperationException("Base BuildLayout method not called"); + } base.OnPreLoad(e); } diff --git a/NAPS2.Lib/EtoForms/EtoFormBase.cs b/NAPS2.Lib/EtoForms/EtoFormBase.cs index 40d22a5d26..5f92d1165d 100644 --- a/NAPS2.Lib/EtoForms/EtoFormBase.cs +++ b/NAPS2.Lib/EtoForms/EtoFormBase.cs @@ -17,12 +17,18 @@ protected EtoFormBase(Naps2Config config) EtoPlatform.Current.InitForm(this); } - protected abstract void BuildLayout(); + protected virtual void BuildLayout() + { + FormStateController.LoadState(); + } protected override void OnPreLoad(EventArgs e) { - FormStateController.LoadState(); BuildLayout(); + if (!FormStateController.Loaded) + { + throw new InvalidOperationException("Base BuildLayout method not called"); + } base.OnPreLoad(e); } diff --git a/NAPS2.Lib/EtoForms/Ui/AboutForm.cs b/NAPS2.Lib/EtoForms/Ui/AboutForm.cs index dc75f7e04e..edab9c5309 100644 --- a/NAPS2.Lib/EtoForms/Ui/AboutForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/AboutForm.cs @@ -40,6 +40,7 @@ protected override void BuildLayout() { FormStateController.Resizable = false; FormStateController.RestoreFormState = false; + base.BuildLayout(); LayoutController.DefaultSpacing = 2; LayoutController.Content = L.Row( diff --git a/NAPS2.Lib/EtoForms/Ui/AdvancedProfileForm.cs b/NAPS2.Lib/EtoForms/Ui/AdvancedProfileForm.cs index 33f4a3c0b9..a50a5e1a6b 100644 --- a/NAPS2.Lib/EtoForms/Ui/AdvancedProfileForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/AdvancedProfileForm.cs @@ -63,6 +63,7 @@ protected override void BuildLayout() FormStateController.DefaultExtraLayoutSize = new Size(60, 0); FormStateController.FixedHeightLayout = true; + base.BuildLayout(); LayoutController.Content = L.Column( L.GroupBox( diff --git a/NAPS2.Lib/EtoForms/Ui/AuthorizeForm.cs b/NAPS2.Lib/EtoForms/Ui/AuthorizeForm.cs index 3eeba69b1c..1f5215602f 100644 --- a/NAPS2.Lib/EtoForms/Ui/AuthorizeForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/AuthorizeForm.cs @@ -23,6 +23,7 @@ protected override void BuildLayout() FormStateController.FixedHeightLayout = true; FormStateController.RestoreFormState = false; FormStateController.Resizable = false; + base.BuildLayout(); LayoutController.Content = L.Row( C.Label(UiStrings.WaitingForAuthorization).Padding(right: 30), diff --git a/NAPS2.Lib/EtoForms/Ui/AutoSaveSettingsForm.cs b/NAPS2.Lib/EtoForms/Ui/AutoSaveSettingsForm.cs index 75b316d701..7149978aa6 100644 --- a/NAPS2.Lib/EtoForms/Ui/AutoSaveSettingsForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/AutoSaveSettingsForm.cs @@ -54,6 +54,7 @@ protected override void BuildLayout() Title = UiStrings.AutoSaveSettingsFormTitle; FormStateController.FixedHeightLayout = true; + base.BuildLayout(); LayoutController.Content = L.Column( C.Label(UiStrings.FilePathLabel).NaturalWidth(300), diff --git a/NAPS2.Lib/EtoForms/Ui/BatchPromptForm.cs b/NAPS2.Lib/EtoForms/Ui/BatchPromptForm.cs index b070fb05d9..045a82edc1 100644 --- a/NAPS2.Lib/EtoForms/Ui/BatchPromptForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/BatchPromptForm.cs @@ -33,6 +33,7 @@ protected override void BuildLayout() FormStateController.SaveFormState = false; FormStateController.RestoreFormState = false; FormStateController.Resizable = false; + base.BuildLayout(); LayoutController.Content = L.Column( C.Label(string.Format(UiStrings.ReadyForScan, ScanNumber)).NaturalWidth(200), diff --git a/NAPS2.Lib/EtoForms/Ui/BatchScanForm.cs b/NAPS2.Lib/EtoForms/Ui/BatchScanForm.cs index c418ca4daf..4d05bc4fb6 100644 --- a/NAPS2.Lib/EtoForms/Ui/BatchScanForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/BatchScanForm.cs @@ -109,6 +109,7 @@ protected override void BuildLayout() FormStateController.FixedHeightLayout = true; AbortButton = _cancel; + base.BuildLayout(); LayoutController.Content = L.Column( L.Row( diff --git a/NAPS2.Lib/EtoForms/Ui/ChooseDeviceForm.cs b/NAPS2.Lib/EtoForms/Ui/ChooseDeviceForm.cs index ecceb57760..90f1888585 100644 --- a/NAPS2.Lib/EtoForms/Ui/ChooseDeviceForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/ChooseDeviceForm.cs @@ -151,6 +151,7 @@ protected override void BuildLayout() FormStateController.SaveFormState = FormStateController.RestoreFormState = true; FormStateController.DefaultExtraLayoutSize = new Size(150, 100); + base.BuildLayout(); LayoutController.Content = L.Column( L.Row( diff --git a/NAPS2.Lib/EtoForms/Ui/DesktopForm.cs b/NAPS2.Lib/EtoForms/Ui/DesktopForm.cs index 6f3cc98af9..48f7ebba11 100644 --- a/NAPS2.Lib/EtoForms/Ui/DesktopForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/DesktopForm.cs @@ -120,6 +120,7 @@ protected override void BuildLayout() FormStateController.AutoLayoutSize = false; FormStateController.DefaultClientSize = new Size(1210, 600); MinimumSize = new Size(600, 300); + base.BuildLayout(); LayoutController.RootPadding = 0; LayoutController.Content = L.LeftPanel( diff --git a/NAPS2.Lib/EtoForms/Ui/DownloadProgressForm.cs b/NAPS2.Lib/EtoForms/Ui/DownloadProgressForm.cs index a090465015..352edd2c1a 100644 --- a/NAPS2.Lib/EtoForms/Ui/DownloadProgressForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/DownloadProgressForm.cs @@ -37,6 +37,7 @@ private void OnDownloadError(object? sender, EventArgs e) protected override void BuildLayout() { FormStateController.RestoreFormState = false; + base.BuildLayout(); LayoutController.Content = L.Column( _totalStatus, diff --git a/NAPS2.Lib/EtoForms/Ui/EditProfileForm.cs b/NAPS2.Lib/EtoForms/Ui/EditProfileForm.cs index 7b13473bb3..483153cd5f 100644 --- a/NAPS2.Lib/EtoForms/Ui/EditProfileForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/EditProfileForm.cs @@ -91,6 +91,7 @@ protected override void BuildLayout() { FormStateController.DefaultExtraLayoutSize = new Size(60, 0); FormStateController.FixedHeightLayout = true; + base.BuildLayout(); LayoutController.Content = L.Column( C.Label(UiStrings.DisplayNameLabel), diff --git a/NAPS2.Lib/EtoForms/Ui/EmailProviderForm.cs b/NAPS2.Lib/EtoForms/Ui/EmailProviderForm.cs index 31aa5022a9..224abd74ab 100644 --- a/NAPS2.Lib/EtoForms/Ui/EmailProviderForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/EmailProviderForm.cs @@ -20,6 +20,7 @@ public EmailProviderForm(Naps2Config config, EmailProviderController controller, protected override void BuildLayout() { FormStateController.FixedHeightLayout = true; + base.BuildLayout(); LayoutController.DefaultSpacing = 0; LayoutController.Content = L.Column( diff --git a/NAPS2.Lib/EtoForms/Ui/EmailSettingsForm.cs b/NAPS2.Lib/EtoForms/Ui/EmailSettingsForm.cs index 2298a1b015..68cf8bd6ae 100644 --- a/NAPS2.Lib/EtoForms/Ui/EmailSettingsForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/EmailSettingsForm.cs @@ -35,6 +35,7 @@ protected override void BuildLayout() { FormStateController.DefaultExtraLayoutSize = new Size(60, 0); FormStateController.FixedHeightLayout = true; + base.BuildLayout(); LayoutController.Content = L.Column( L.GroupBox( diff --git a/NAPS2.Lib/EtoForms/Ui/ErrorForm.cs b/NAPS2.Lib/EtoForms/Ui/ErrorForm.cs index bb71f1083a..5da75fb681 100644 --- a/NAPS2.Lib/EtoForms/Ui/ErrorForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/ErrorForm.cs @@ -22,6 +22,7 @@ protected override void BuildLayout() FormStateController.RestoreFormState = false; FormStateController.FixedHeightLayout = true; + base.BuildLayout(); LayoutController.Content = L.Column( L.Row( diff --git a/NAPS2.Lib/EtoForms/Ui/ImageFormBase.cs b/NAPS2.Lib/EtoForms/Ui/ImageFormBase.cs index 7eaaf25be6..9a74422582 100644 --- a/NAPS2.Lib/EtoForms/Ui/ImageFormBase.cs +++ b/NAPS2.Lib/EtoForms/Ui/ImageFormBase.cs @@ -39,6 +39,8 @@ protected ImageFormBase(Naps2Config config, UiImageList imageList, ThumbnailCont protected override void BuildLayout() { + base.BuildLayout(); + LayoutController.Content = L.Column( Overlay.Scale(), CreateControls(), diff --git a/NAPS2.Lib/EtoForms/Ui/ImageSettingsForm.cs b/NAPS2.Lib/EtoForms/Ui/ImageSettingsForm.cs index 2cd80bd885..1c37202036 100644 --- a/NAPS2.Lib/EtoForms/Ui/ImageSettingsForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/ImageSettingsForm.cs @@ -34,6 +34,7 @@ protected override void BuildLayout() { FormStateController.DefaultExtraLayoutSize = new Size(60, 0); FormStateController.FixedHeightLayout = true; + base.BuildLayout(); LayoutController.Content = L.Column( C.Label(UiStrings.DefaultFilePathLabel), diff --git a/NAPS2.Lib/EtoForms/Ui/ManualIpForm.cs b/NAPS2.Lib/EtoForms/Ui/ManualIpForm.cs index 903aa26c2f..2990c64192 100644 --- a/NAPS2.Lib/EtoForms/Ui/ManualIpForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/ManualIpForm.cs @@ -31,6 +31,7 @@ protected override void BuildLayout() { FormStateController.RestoreFormState = false; FormStateController.FixedHeightLayout = true; + base.BuildLayout(); LayoutController.Content = L.Column( C.Label(UiStrings.IpHost), diff --git a/NAPS2.Lib/EtoForms/Ui/OcrDownloadForm.cs b/NAPS2.Lib/EtoForms/Ui/OcrDownloadForm.cs index 01321f907c..12d50948c6 100644 --- a/NAPS2.Lib/EtoForms/Ui/OcrDownloadForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/OcrDownloadForm.cs @@ -47,6 +47,7 @@ protected override void BuildLayout() { FormStateController.RestoreFormState = false; FormStateController.DefaultExtraLayoutSize = new Size(300, 300); + base.BuildLayout(); LayoutController.Content = L.Column( C.Label(UiStrings.OcrDownloadSummaryText), diff --git a/NAPS2.Lib/EtoForms/Ui/OcrMultiLangForm.cs b/NAPS2.Lib/EtoForms/Ui/OcrMultiLangForm.cs index 23d6f8c7f5..ee3fae2938 100644 --- a/NAPS2.Lib/EtoForms/Ui/OcrMultiLangForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/OcrMultiLangForm.cs @@ -25,6 +25,7 @@ protected override void BuildLayout() { FormStateController.RestoreFormState = false; FormStateController.DefaultExtraLayoutSize = new Size(150, 20); + base.BuildLayout(); LayoutController.Content = L.Column( _languageList.Control.Scale(), diff --git a/NAPS2.Lib/EtoForms/Ui/OcrSetupForm.cs b/NAPS2.Lib/EtoForms/Ui/OcrSetupForm.cs index a40bedda47..439dd9312d 100644 --- a/NAPS2.Lib/EtoForms/Ui/OcrSetupForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/OcrSetupForm.cs @@ -62,6 +62,7 @@ public OcrSetupForm(Naps2Config config, TesseractLanguageManager tesseractLangua protected override void BuildLayout() { FormStateController.Resizable = false; + base.BuildLayout(); LayoutController.Content = L.Column( _enableOcr, diff --git a/NAPS2.Lib/EtoForms/Ui/PageSizeForm.cs b/NAPS2.Lib/EtoForms/Ui/PageSizeForm.cs index df43356568..dc534be8da 100644 --- a/NAPS2.Lib/EtoForms/Ui/PageSizeForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/PageSizeForm.cs @@ -64,6 +64,7 @@ protected override void BuildLayout() FormStateController.RestoreFormState = false; FormStateController.FixedHeightLayout = true; + base.BuildLayout(); LayoutController.Content = L.Column( C.Label(UiStrings.NameOptional), diff --git a/NAPS2.Lib/EtoForms/Ui/PdfPasswordForm.cs b/NAPS2.Lib/EtoForms/Ui/PdfPasswordForm.cs index 4bae955388..ae4a7be201 100644 --- a/NAPS2.Lib/EtoForms/Ui/PdfPasswordForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/PdfPasswordForm.cs @@ -24,6 +24,7 @@ protected override void BuildLayout() FormStateController.RestoreFormState = false; FormStateController.FixedHeightLayout = true; + base.BuildLayout(); _passwordBox.Title = FileName!; _passwordBox.TitleWrapWidth = 300; diff --git a/NAPS2.Lib/EtoForms/Ui/PdfSettingsForm.cs b/NAPS2.Lib/EtoForms/Ui/PdfSettingsForm.cs index 6fcf849677..2f4c74372b 100644 --- a/NAPS2.Lib/EtoForms/Ui/PdfSettingsForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/PdfSettingsForm.cs @@ -64,6 +64,7 @@ protected override void BuildLayout() { FormStateController.DefaultExtraLayoutSize = new Size(60, 0); FormStateController.FixedHeightLayout = true; + base.BuildLayout(); LayoutController.Content = L.Column( C.Label(UiStrings.DefaultFilePathLabel), diff --git a/NAPS2.Lib/EtoForms/Ui/PlaceholdersForm.cs b/NAPS2.Lib/EtoForms/Ui/PlaceholdersForm.cs index 90bcf021db..5bfa76051b 100644 --- a/NAPS2.Lib/EtoForms/Ui/PlaceholdersForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/PlaceholdersForm.cs @@ -38,6 +38,7 @@ protected override void BuildLayout() FormStateController.DefaultExtraLayoutSize = new Size(60, 0); FormStateController.FixedHeightLayout = true; + base.BuildLayout(); LayoutController.Content = L.Column( C.Label(UiStrings.FileNameLabel), diff --git a/NAPS2.Lib/EtoForms/Ui/PreviewForm.cs b/NAPS2.Lib/EtoForms/Ui/PreviewForm.cs index 32126905cf..95ca95fd61 100644 --- a/NAPS2.Lib/EtoForms/Ui/PreviewForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/PreviewForm.cs @@ -130,6 +130,7 @@ protected override void BuildLayout() { FormStateController.AutoLayoutSize = false; FormStateController.DefaultClientSize = new Size(800, 600); + base.BuildLayout(); LayoutController.RootPadding = 0; LayoutController.Content = ImageViewer; diff --git a/NAPS2.Lib/EtoForms/Ui/ProfilesForm.cs b/NAPS2.Lib/EtoForms/Ui/ProfilesForm.cs index 4b7b538bf6..8218e2662b 100644 --- a/NAPS2.Lib/EtoForms/Ui/ProfilesForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/ProfilesForm.cs @@ -131,6 +131,7 @@ public ProfilesForm(Naps2Config config, IScanPerformer scanPerformer, ProfileNam protected override void BuildLayout() { FormStateController.DefaultExtraLayoutSize = new Size(200, 0); + base.BuildLayout(); LayoutController.Content = L.Column( L.Row( diff --git a/NAPS2.Lib/EtoForms/Ui/ProgressForm.cs b/NAPS2.Lib/EtoForms/Ui/ProgressForm.cs index f2c14c4770..02e76360ea 100644 --- a/NAPS2.Lib/EtoForms/Ui/ProgressForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/ProgressForm.cs @@ -29,6 +29,7 @@ protected override void BuildLayout() { FormStateController.RestoreFormState = false; FormStateController.SaveFormState = false; + base.BuildLayout(); LayoutController.Content = L.Column( _status, diff --git a/NAPS2.Lib/EtoForms/Ui/RecoverForm.cs b/NAPS2.Lib/EtoForms/Ui/RecoverForm.cs index a6c9d3257f..845b7be349 100644 --- a/NAPS2.Lib/EtoForms/Ui/RecoverForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/RecoverForm.cs @@ -20,6 +20,7 @@ protected override void BuildLayout() FormStateController.SaveFormState = false; FormStateController.RestoreFormState = false; // FormStateController.Resizable = false; + base.BuildLayout(); var recoverButton = C.DialogButton(this, UiStrings.Recover, beforeClose: () => SelectedAction = RecoverAction.Recover); diff --git a/NAPS2.Lib/EtoForms/Ui/ScannerSharingForm.cs b/NAPS2.Lib/EtoForms/Ui/ScannerSharingForm.cs index 6e91c4ab72..d690518ac2 100644 --- a/NAPS2.Lib/EtoForms/Ui/ScannerSharingForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/ScannerSharingForm.cs @@ -77,6 +77,7 @@ public ScannerSharingForm(Naps2Config config, SharedDevicesListViewBehavior list protected override void BuildLayout() { FormStateController.DefaultExtraLayoutSize = new Size(200, 0); + base.BuildLayout(); LayoutController.Content = L.Column( C.Label(UiStrings.ScannerSharingIntro).DynamicWrap(400), diff --git a/NAPS2.Lib/EtoForms/Ui/SettingsForm.cs b/NAPS2.Lib/EtoForms/Ui/SettingsForm.cs index f47bdcade2..1224d9e8c3 100644 --- a/NAPS2.Lib/EtoForms/Ui/SettingsForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/SettingsForm.cs @@ -54,6 +54,7 @@ protected override void BuildLayout() { FormStateController.DefaultExtraLayoutSize = new Size(60, 0); FormStateController.FixedHeightLayout = true; + base.BuildLayout(); LayoutController.Content = L.Column( L.GroupBox( diff --git a/NAPS2.Lib/EtoForms/Ui/SharedDeviceForm.cs b/NAPS2.Lib/EtoForms/Ui/SharedDeviceForm.cs index 372c9aef37..88c09c1a68 100644 --- a/NAPS2.Lib/EtoForms/Ui/SharedDeviceForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/SharedDeviceForm.cs @@ -50,6 +50,7 @@ protected override void BuildLayout() { FormStateController.DefaultExtraLayoutSize = new Size(60, 0); FormStateController.FixedHeightLayout = true; + base.BuildLayout(); LayoutController.Content = L.Column( C.Label(UiStrings.DisplayNameLabel),