Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion NAPS2.Lib/EtoForms/Ui/BatchScanForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class BatchScanForm : EtoDialogBase
private readonly Button _start = new() { Text = UiStrings.Start };
private readonly Button _cancel = new() { Text = UiStrings.Cancel };
private readonly DropDownWidget<ScanProfile> _profile = new();
private readonly RadioButton _UseExistingImages;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should start with a lowercase letter to match, but also let's rename this to _loadFromNaps2 (and, optionally, you can also rename _load to _loadIntoNaps2)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

private readonly RadioButton _singleScan;
private readonly RadioButton _multipleScansPrompt;
private readonly RadioButton _multipleScansDelay;
Expand Down Expand Up @@ -63,6 +64,7 @@ public BatchScanForm(Naps2Config config, DialogHelper dialogHelper, IProfileMana
_batchScanPerformer = batchScanPerformer;
_errorOutput = errorOutput;
_singleScan = new RadioButton { Text = UiStrings.SingleScan };
_UseExistingImages = new RadioButton(_singleScan) { Text = UiStrings.LoadFromNaps2 };
_multipleScansPrompt = new RadioButton(_singleScan) { Text = UiStrings.MultipleScansPrompt };
_multipleScansDelay = new RadioButton(_singleScan) { Text = UiStrings.MultipleScansDelay };
_load = new RadioButton { Text = UiStrings.LoadIn };
Expand All @@ -76,9 +78,12 @@ public BatchScanForm(Naps2Config config, DialogHelper dialogHelper, IProfileMana

_start.Click += Start;
_cancel.Click += Cancel;
_UseExistingImages.CheckedChanged += UpdateExisting;
_multipleScansDelay.CheckedChanged += UpdateVisibility;
_saveToSingleFile.CheckedChanged += UpdateVisibility;
_saveToSingleFile.CheckedChanged += UpdateExisting;
_saveToMultipleFiles.CheckedChanged += UpdateVisibility;
_saveToMultipleFiles.CheckedChanged += UpdateExisting;

_userTransact = Config.User.BeginTransaction();
_transactionConfig = Config.WithTransaction(_userTransact);
Expand All @@ -100,9 +105,23 @@ private void UpdateVisibility(object? sender, EventArgs e)
_delayVis.IsVisible = _multipleScansDelay.Checked;
_multiVis.IsVisible = _saveToMultipleFiles.Checked;
_fileVis.IsVisible = _saveToSingleFile.Checked || _saveToMultipleFiles.Checked;

LayoutController.Invalidate();
}

private void UpdateExisting(object? sender, EventArgs e)
{
if (_UseExistingImages.Checked)
{
_load.Enabled = false;
_load.Checked = false;
}
else
{
_load.Enabled = true;
}
}

public Action<ProcessedImage> ImageCallback { get; set; } = null!;

private ActionCommand NewProfileCommand { get; }
Expand All @@ -129,12 +148,14 @@ protected override void BuildLayout()
L.GroupBox(
UiStrings.ScanConfig,
L.Column(
_UseExistingImages,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this to the bottom of the column (below the ).Padding(left: 20).Visible(_delayVis) line)

C.Label(UiStrings.ProfileLabel),
L.Row(
_profile.AsControl().Scale().NaturalWidth(100),
C.Button(EditProfileCommand, ButtonImagePosition.Overlay).Width(30),
C.Button(NewProfileCommand, ButtonImagePosition.Overlay).Width(30)
),

_singleScan,
_multipleScansPrompt,
_multipleScansDelay,
Expand Down Expand Up @@ -172,6 +193,16 @@ private void UpdateUIFromSettings()
{
UpdateProfiles();

_UseExistingImages.Checked = _transactionConfig.Get(c => c.BatchSettings.ScanType) == BatchScanType.loadFromNaps2;
if (_UseExistingImages.Checked)
{
_load.Enabled = false;
_load.Checked = false;
}
else
{
_load.Enabled = true;
}
_singleScan.Checked = _transactionConfig.Get(c => c.BatchSettings.ScanType) == BatchScanType.Single;
_multipleScansPrompt.Checked =
_transactionConfig.Get(c => c.BatchSettings.ScanType) == BatchScanType.MultipleWithPrompt;
Expand All @@ -195,6 +226,7 @@ private void UpdateUIFromSettings()
_separateByPatchT.Checked = _transactionConfig.Get(c => c.BatchSettings.SaveSeparator) == SaveSeparator.PatchT;

_filePath.Text = _transactionConfig.Get(c => c.BatchSettings.SavePath);

}

private bool ValidateSettings()
Expand All @@ -212,8 +244,11 @@ private bool ValidateSettings()
? BatchScanType.MultipleWithPrompt
: _multipleScansDelay.Checked
? BatchScanType.MultipleWithDelay
: _UseExistingImages.Checked ? BatchScanType.loadFromNaps2
: BatchScanType.Single);



if (_multipleScansDelay.Checked)
{
if (!int.TryParse(_numberOfScans.Text, out int scanCount) || scanCount <= 0)
Expand Down Expand Up @@ -330,7 +365,7 @@ private void EnableDisableSettings(bool enabled)
{
var controls = new Control[]
{
_profile.AsControl(), _singleScan, _multipleScansPrompt, _multipleScansDelay, _numberOfScans,
_profile.AsControl(), _UseExistingImages, _singleScan, _multipleScansPrompt, _multipleScansDelay, _numberOfScans,
_timeBetweenScans, _load, _saveToSingleFile, _saveToMultipleFiles, _filePerScan, _filePerPage,
_separateByPatchT, _moreInfo
};
Expand Down
Loading