fix(autonest): keep the server choice once the dialog closes

AutoNestForm read "Nest on the server" through nestOnServerBox.Visible,
which WinForms reports as false whenever the form is hidden or another tab
is selected. AutoNestCommand reads NestOnServer after ShowDialog returns,
so a checked box never sent the job to the server, and the choice was not
saved when the dialog closed on a tab other than Plates. Availability now
lives in its own field.

Fixes AutoNestFormPlateSourceTests.CurrentPlatesAreNeverNestedOnTheServer
on windows-desktop (Cross-platform tests run 45732432564).
This commit is contained in:
aj committed 2026-11-26 10:49:22 -05:00
1 parent ce594814c6
commit f88b1b37fa
2 files changed
+28 -3

No files matched your search

@@ -32,6 +32,25 @@ public class AutoNestFormPlateSourceTests
Assert.Equal(box.Checked, form.NestOnServer);
});
[Fact]
public void NestOnServerIsReadableWhileTheFormIsHidden() => RunSta(() =>
{
// AutoNestCommand reads the choice after ShowDialog returns, when every control
// reports Visible == false.
using var form = new AutoNestForm(new Nest()) { ServerNestingAvailable = true };
var box = Assert.IsType<CheckBox>(form.Controls.Find("nestOnServerBox", true).Single());
box.Checked = true;
Assert.True(form.ServerNestingAvailable);
Assert.True(form.NestOnServer);
box.Checked = false;
Assert.False(form.NestOnServer);
form.ServerNestingAvailable = false;
box.Checked = true;
Assert.False(form.ServerNestingAvailable);
Assert.False(form.NestOnServer);
});
[Fact]
public void CurrentPlatesOnlyOffersNoStockOptions() => RunSta(() =>
{
+9 -3
View File
@@ -28,6 +28,9 @@ namespace OpenNest.Forms
private CancellationTokenSource ledgerCancellation;
private bool loadingLedger;
private string ledgerSummary = "";
// Kept apart from nestOnServerBox.Visible, which reads false whenever the form is
// hidden (as it is once ShowDialog returns) or another tab is selected.
private bool serverNestingAvailable;
/// <summary>A dark amber that reads on the grid's white rows.</summary>
internal static readonly System.Drawing.Color SubstituteColor = System.Drawing.Color.FromArgb(160, 82, 0);
@@ -116,9 +119,10 @@ namespace OpenNest.Forms
/// </summary>
public bool ServerNestingAvailable
{
get => nestOnServerBox.Visible;
get => serverNestingAvailable;
set
{
serverNestingAvailable = value;
nestOnServerBox.Visible = value;
nestOnServerBox.Checked = value && Properties.Settings.Default.AutoNestOnServer;
UpdateNestOnServerBox();
@@ -126,7 +130,8 @@ namespace OpenNest.Forms
}
/// <summary>True when the user chose to nest on the server with an engine it can run.</summary>
public bool NestOnServer => nestOnServerBox.Visible && nestOnServerBox.Enabled && nestOnServerBox.Checked;
public bool NestOnServer =>
serverNestingAvailable && nestOnServerBox.Enabled && nestOnServerBox.Checked;
private void engineComboBox_SelectedIndexChanged(object sender, EventArgs e) => UpdateNestOnServerBox();
@@ -559,7 +564,8 @@ namespace OpenNest.Forms
DialogResult = DialogResult.None;
ReportStockValidationFailure(error);
}
else if (DialogResult == DialogResult.OK && nestOnServerBox.Visible && nestOnServerBox.Enabled)
else if (DialogResult == DialogResult.OK && serverNestingAvailable
&& nestOnServerBox.Enabled)
{
Properties.Settings.Default.AutoNestOnServer = nestOnServerBox.Checked;
Properties.Settings.Default.Save();