Skip to content

Commit

Permalink
Fix ordering of FormStateController interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Sep 8, 2024
1 parent 6d3a563 commit 104c7f4
Show file tree
Hide file tree
Showing 32 changed files with 47 additions and 4 deletions.
10 changes: 8 additions & 2 deletions NAPS2.Lib/EtoForms/EtoDialogBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
10 changes: 8 additions & 2 deletions NAPS2.Lib/EtoForms/EtoFormBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/AboutForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ protected override void BuildLayout()
{
FormStateController.Resizable = false;
FormStateController.RestoreFormState = false;
base.BuildLayout();

LayoutController.DefaultSpacing = 2;
LayoutController.Content = L.Row(
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/AdvancedProfileForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/AuthorizeForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/AutoSaveSettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/BatchPromptForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/BatchScanForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ protected override void BuildLayout()

FormStateController.FixedHeightLayout = true;
AbortButton = _cancel;
base.BuildLayout();

LayoutController.Content = L.Column(
L.Row(
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/ChooseDeviceForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/DesktopForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/DownloadProgressForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/EditProfileForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/EmailProviderForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/EmailSettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/ErrorForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ protected override void BuildLayout()

FormStateController.RestoreFormState = false;
FormStateController.FixedHeightLayout = true;
base.BuildLayout();

LayoutController.Content = L.Column(
L.Row(
Expand Down
2 changes: 2 additions & 0 deletions NAPS2.Lib/EtoForms/Ui/ImageFormBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ protected ImageFormBase(Naps2Config config, UiImageList imageList, ThumbnailCont

protected override void BuildLayout()
{
base.BuildLayout();

LayoutController.Content = L.Column(
Overlay.Scale(),
CreateControls(),
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/ImageSettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/ManualIpForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ protected override void BuildLayout()
{
FormStateController.RestoreFormState = false;
FormStateController.FixedHeightLayout = true;
base.BuildLayout();

LayoutController.Content = L.Column(
C.Label(UiStrings.IpHost),
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/OcrDownloadForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/OcrMultiLangForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/OcrSetupForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public OcrSetupForm(Naps2Config config, TesseractLanguageManager tesseractLangua
protected override void BuildLayout()
{
FormStateController.Resizable = false;
base.BuildLayout();

LayoutController.Content = L.Column(
_enableOcr,
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/PageSizeForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ protected override void BuildLayout()

FormStateController.RestoreFormState = false;
FormStateController.FixedHeightLayout = true;
base.BuildLayout();

LayoutController.Content = L.Column(
C.Label(UiStrings.NameOptional),
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/PdfPasswordForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ protected override void BuildLayout()

FormStateController.RestoreFormState = false;
FormStateController.FixedHeightLayout = true;
base.BuildLayout();

_passwordBox.Title = FileName!;
_passwordBox.TitleWrapWidth = 300;
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/PdfSettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/PlaceholdersForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/PreviewForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/ProfilesForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/ProgressForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ protected override void BuildLayout()
{
FormStateController.RestoreFormState = false;
FormStateController.SaveFormState = false;
base.BuildLayout();

LayoutController.Content = L.Column(
_status,
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/RecoverForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/ScannerSharingForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/SettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/EtoForms/Ui/SharedDeviceForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 104c7f4

Please sign in to comment.