Files
OpenNest/OpenNest.WinForms.Tests/Forms/EditPlateFormOutlineTests.cs
T
ajandClaude Opus 5.5 3edf65524f feat(nest-info): redesign Edit Nest and share plate settings with Edit Plate
The Info tab showed the thickness name twice: the thickness box's list label
("1/4" - 0.25") and the separate Thickness name box. The box now shows the bare
decimal with a Name box beside it; the list still names each entry, and a
picked entry keeps its name when the box switches to the number. Fields are
grouped into Nest and Material sections and the dates are one gray line.

The Defaults tab and Edit Plate edited the same size, spacing and quadrant
with duplicated controls, and the Defaults tab always stepped spacing by 0.25
even in millimeters. Both now host one PlateSettingsEditor; the forms stay
separate because each has its own extras (quantity and outline, or use for
new nests).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 22:16:47 -05:00

62 lines
2.2 KiB
C#

using System.Windows.Forms;
using OpenNest.Forms;
using OpenNest.Geometry;
namespace OpenNest.WinForms.Tests.Forms;
/// <summary>Edit Plate with a sheet outline: the size follows the outline and is read-only
/// while there is one, Done applies the outline, and Clear makes the sheet a rectangle again.</summary>
public class EditPlateFormOutlineTests
{
private static SheetOutline Ell() => new(new[]
{
new Vector(0, 0), new Vector(96, 0), new Vector(96, 24), new Vector(48, 24), new Vector(48, 48), new Vector(0, 48),
});
[Fact]
public void OutlineSetsTheSizeAndDoneAppliesIt() => RunSta(() =>
{
var plate = new Plate(60, 120);
using var form = new EditPlateForm(plate);
var size = (TextBox)form.Controls.Find("sizeBox", true)[0];
var clear = (Button)form.Controls.Find("buttonClearOutline", true)[0];
Assert.False(size.ReadOnly);
Assert.False(clear.Enabled);
form.Outline = Ell();
Assert.True(size.ReadOnly);
Assert.True(clear.Enabled);
Assert.Equal(new Size(48, 96).ToString(), form.SizeString);
Assert.Contains("6 vertices", ((Label)form.Controls.Find("labelOutline", true)[0]).Text);
Assert.True(((Button)form.Controls.Find("applyButton", true)[0]).Enabled);
form.Apply();
Assert.Equal(Ell(), plate.Outline);
Assert.Equal(48, plate.Size.Width);
Assert.Equal(96, plate.Size.Length);
});
[Fact]
public void ClearMakesTheSheetARectangleOfTheSameSize() => RunSta(() =>
{
var plate = new Plate { Outline = Ell(), Quadrant = 2 };
using var form = new EditPlateForm(plate);
var size = (TextBox)form.Controls.Find("sizeBox", true)[0];
Assert.True(size.ReadOnly);
form.Outline = null; // what Clear does
Assert.False(size.ReadOnly);
Assert.False(((Button)form.Controls.Find("buttonClearOutline", true)[0]).Enabled);
form.Apply();
Assert.Null(plate.Outline);
Assert.Equal(48, plate.Size.Width);
Assert.Equal(96, plate.Size.Length);
Assert.Equal(2, plate.Quadrant);
});
private static void RunSta(Action action) =>
StaTestThread.Run(action, TimeSpan.FromSeconds(30), "Edit Plate outline test timed out.");
}