From 7f1cff301a0edc35821033757a6debe6ca5615bb Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Fri, 13 Nov 2026 17:31:18 -0500 Subject: [PATCH] feat(avalonia): create new nests from File > New, Ctrl+N, New and + Move the File > New rules into OpenNest.Desktop (NewNestSource): nest defaults, the default machine with its clamps and support grid, Made By and the year's next name, from the nest server in Database mode and the counter both apps keep in user-settings.json otherwise. The WinForms factory now delegates to it. The Avalonia app opens a new nest in a tab with no file (NestTabs.Add), off the UI thread and one at a time, and its nest view keeps an empty last plate as the WinForms nest window does, so a new nest shows Plate 1. Co-Authored-By: Claude Opus 5.5 --- OpenNest.Avalonia/DesktopSettings.cs | 14 ++ OpenNest.Avalonia/MainWindow.axaml | 6 +- OpenNest.Avalonia/MainWindow.axaml.cs | 66 +++++- OpenNest.Avalonia/NestView.axaml.cs | 4 + OpenNest.Desktop.Tests/NestTabsTests.cs | 18 ++ OpenNest.Desktop.Tests/NewNestSourceTests.cs | 201 +++++++++++++++++++ OpenNest.Desktop/NestTabs.cs | 14 ++ OpenNest.Desktop/NewNestSource.cs | 188 +++++++++++++++++ OpenNest/Forms/NewNestFactory.cs | 94 +++------ 9 files changed, 525 insertions(+), 80 deletions(-) create mode 100644 OpenNest.Desktop.Tests/NewNestSourceTests.cs create mode 100644 OpenNest.Desktop/NewNestSource.cs diff --git a/OpenNest.Avalonia/DesktopSettings.cs b/OpenNest.Avalonia/DesktopSettings.cs index 15ab5861..24cebd24 100644 --- a/OpenNest.Avalonia/DesktopSettings.cs +++ b/OpenNest.Avalonia/DesktopSettings.cs @@ -21,6 +21,20 @@ namespace OpenNest.Avalonia public static MachineSettingsSource Machines { get; } = new(Shared, new MachineUserSettingsFile(UserSettingsFile.DefaultPath)); + /// The storage mode and nest server, read once from storage.json as does. + private static readonly NestStorageSettings Storage = NestStorageSettings.Load(NestStorageSettings.DefaultPath); + + private static RemoteNestRepository repository; + + /// + /// File > New nests, numbered by the nest server in Database mode and otherwise by the + /// counter both apps keep in user-settings.json. + /// + public static NewNestSource NewNests { get; } = new( + Machines, + new NewNestUserSettingsFile(UserSettingsFile.DefaultPath), + () => Storage.IsDatabaseMode ? repository ??= new RemoteNestRepository(Storage.ServerUrl) : null); + /// The post processors loaded from Posts/ beside the app, by load order. public static IReadOnlyList PostProcessors { get; private set; } = []; diff --git a/OpenNest.Avalonia/MainWindow.axaml b/OpenNest.Avalonia/MainWindow.axaml index 84af0654..44f9dbfb 100644 --- a/OpenNest.Avalonia/MainWindow.axaml +++ b/OpenNest.Avalonia/MainWindow.axaml @@ -6,6 +6,7 @@ + @@ -45,6 +46,7 @@ +