From 2b8a3ce7dba18816ef0dcc7a7c111768fbc501b8 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Tue, 29 Sep 2026 08:38:48 -0400 Subject: [PATCH] fix(leadin): add close button to Place Lead-in side panel The docked side panel could only be closed with Escape, which was unreliable: MainForm consumes Escape before ActionLeadIn's KeyDown handler, so with a part selected ActionManager called the action's empty CancelAction and nothing happened; with nothing selected the panel closed but was stored as the previous action, so the next Escape reopened it. - EditNestForm side panel gets a header with the panel title and an always-visible close button that ends the action. - ActionLeadIn.CancelAction now steps back (unlock contour, then deselect part), replacing the dead KeyDown handler. - Actions can opt out of Escape-resume (ResumeOnEscape); the lead-in action does, so a closed panel stays closed. --- .../Forms/LeadInSidePanelTests.cs | 64 +++++++++++++++++++ OpenNest/Actions/Action.cs | 5 ++ OpenNest/Actions/ActionLeadIn.cs | 43 +++++-------- OpenNest/Controls/ActionManager.cs | 12 ++++ OpenNest/Controls/PlateView.cs | 2 + OpenNest/Forms/EditNestForm.cs | 52 ++++++++++++++- 6 files changed, 149 insertions(+), 29 deletions(-) create mode 100644 OpenNest.WinForms.Tests/Forms/LeadInSidePanelTests.cs diff --git a/OpenNest.WinForms.Tests/Forms/LeadInSidePanelTests.cs b/OpenNest.WinForms.Tests/Forms/LeadInSidePanelTests.cs new file mode 100644 index 0000000..80af5f0 --- /dev/null +++ b/OpenNest.WinForms.Tests/Forms/LeadInSidePanelTests.cs @@ -0,0 +1,64 @@ +using System.Runtime.ExceptionServices; +using System.Windows.Forms; +using OpenNest.Forms; + +namespace OpenNest.WinForms.Tests.Forms; + +public class LeadInSidePanelTests +{ + [Theory] + [InlineData(true)] + [InlineData(false)] + public void PanelClosesWithoutEscapeReopeningIt(bool useCloseButton) => RunSta(() => + { + using var form = new EditNestForm(new Nest("lead-in panel")); + form.Show(); + + form.PlaceLeadIn_Click(null!, EventArgs.Empty); + Assert.True(form.IsSidePanelVisible); + Assert.Equal("Place Lead-in", form.PlateView.Status); + + if (useCloseButton) + { + var close = Assert.IsType