fix(converter): accept a required quantity of 0 when loading drawings

Nest drawings can require no parts, but the CAD Converter's quantity
spinner had a minimum of 1, so Edit Drawings in Converter threw
ArgumentOutOfRangeException as soon as such a drawing was selected.
Lowering the minimum to 0 lets the converter load it and hand the
drawing back with its quantity still 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Opus 5.5 committed 2026-10-26 12:26:29 -04:00
1 parent a3b7c715d5
commit a3a75d589d
2 files changed
+46 -1

No files matched your search

@@ -0,0 +1,45 @@
using System.Drawing;
using System.Windows.Forms;
using OpenNest.Bending;
using OpenNest.Forms;
using OpenNest.Geometry;
using OpenNest.IO;
namespace OpenNest.WinForms.Tests.Forms;
/// <summary>
/// A nest drawing may require no parts (quantity 0); editing it in the CAD Converter must keep that.
/// </summary>
public class CadConverterQuantityTests
{
[Fact]
public void LoadingADrawingThatRequiresNoParts_KeepsItsQuantityAtZero() => ArchUnitsTests.RunSta(() =>
{
using var form = new CadConverterForm();
form.WindowState = FormWindowState.Normal;
form.StartPosition = FormStartPosition.Manual;
form.Location = new Point(0, 0);
form.Size = new System.Drawing.Size(1200, 800);
form.Show();
form.LoadDrawings([Square(0)]);
var drawing = Assert.Single(form.GetDrawings());
Assert.Equal(0, drawing.Quantity.Required);
form.Close();
});
private static Drawing Square(int quantity)
{
var entities = new List<Entity>
{
new Line(0, 0, 10, 0), new Line(10, 0, 10, 10), new Line(10, 10, 0, 10), new Line(0, 10, 0, 0),
};
foreach (var e in entities)
e.Layer = new Layer("0") { IsVisible = true };
var drawing = CadImporter.BuildDrawing(new CadImportResult { Entities = entities, Name = "square" }, entities,
new List<Bend>(), 1, null, null);
drawing.Quantity.Required = quantity;
return drawing;
}
}
+1 -1
View File
@@ -200,7 +200,7 @@ namespace OpenNest.Forms
numQuantity.Location = new System.Drawing.Point(37, 6);
numQuantity.Margin = new System.Windows.Forms.Padding(2, 0, 8, 0);
numQuantity.Maximum = new decimal(new int[] { 9999, 0, 0, 0 });
numQuantity.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
numQuantity.Minimum = new decimal(new int[] { 0, 0, 0, 0 });
numQuantity.Name = "numQuantity";
numQuantity.Size = new System.Drawing.Size(50, 23);
numQuantity.TabIndex = 1;