From 2aecafb35627034e7ed64aafdfc553c1a65e60b4 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Fri, 16 Oct 2026 12:40:33 -0400 Subject: [PATCH] feat(desktop): Save to Drawing Library dialog Operators can now save a nest drawing to the shared drawing library. Right- click a drawing in the drawing list > Save to Drawing Library... opens a dialog with name, customer, material (post materials suggested), grade, thickness, cut type and notes, prefilled by the save model; units follow the nest. Whenever the details change, the dialog looks up library drawings with the same details and offers Save as: the next revision of the match (the default for one match or the linked drawing), a choice among several, or a separate drawing. Save stays disabled until the lookup for the current details has finished, so a choice can never apply to details it was not made for. A 409 is shown and the choices are refreshed; a save that could not be confirmed tells the operator that saving again checks it and never stores it twice. On success only the drawing's library link changes, and the chosen cut type is remembered per PC. There is no nest dirty flag to set, so the operator saves the nest to keep the new link. The item is Database mode only and is shown only where the drawing list's host handles it (not the best-fit viewer). Co-Authored-By: Claude Opus 5.5 --- .../Forms/SaveToDrawingLibraryFormTests.cs | 274 ++++++++++++++ OpenNest/Controls/DrawingListBox.cs | 24 ++ OpenNest/Forms/EditNestForm.cs | 39 ++ OpenNest/Forms/NestStorage.cs | 2 +- .../SaveToDrawingLibraryForm.Designer.cs | 336 ++++++++++++++++++ OpenNest/Forms/SaveToDrawingLibraryForm.cs | 278 +++++++++++++++ OpenNest/Properties/Settings.Designer.cs | 13 + OpenNest/Properties/Settings.settings | 3 + docs/nest-storage.md | 35 +- 9 files changed, 1001 insertions(+), 3 deletions(-) create mode 100644 OpenNest.WinForms.Tests/Forms/SaveToDrawingLibraryFormTests.cs create mode 100644 OpenNest/Forms/SaveToDrawingLibraryForm.Designer.cs create mode 100644 OpenNest/Forms/SaveToDrawingLibraryForm.cs diff --git a/OpenNest.WinForms.Tests/Forms/SaveToDrawingLibraryFormTests.cs b/OpenNest.WinForms.Tests/Forms/SaveToDrawingLibraryFormTests.cs new file mode 100644 index 00000000..87032155 --- /dev/null +++ b/OpenNest.WinForms.Tests/Forms/SaveToDrawingLibraryFormTests.cs @@ -0,0 +1,274 @@ +using System.Reflection; +using System.Security.Cryptography; +using System.Windows.Forms; +using OpenNest.Data; +using OpenNest.Forms; +using OpenNest.Shapes; + +namespace OpenNest.WinForms.Tests.Forms; + +public class SaveToDrawingLibraryFormTests +{ + private const string Server = "http://library.test:8090"; + private static readonly TimeSpan TestTimeout = TimeSpan.FromSeconds(60); + + [Fact] + public void NoMatch_PrefillsTheDetails_DefaultsToASeparateDrawing_AndSavesAndLinks() + { + StaTestThread.Run( + () => + { + var store = new FakeStore(); + var (nest, drawing) = MatchingNest(); + + var form = new SaveToDrawingLibraryForm(store, Server, nest, drawing, CutType.Waterjet, "Synthetic operator"); + form.ShowMessage = (text, _, _) => throw new Xunit.Sdk.XunitException("Unexpected message: " + text); + form.Show(); + var saveAs = Field(form, "saveAsBox"); + var save = Field