From 72776886cb5677509239c306fcd0db183836daee Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Sat, 10 Oct 2026 15:39:11 -0400 Subject: [PATCH] Remember saved nest browser sort preferences --- OpenNest.Data/NestBrowseSession.cs | 5 ++++- OpenNest/Forms/SavedNestsForm.cs | 11 ++++++++++- OpenNest/Properties/Settings.Designer.cs | 16 ++++++++++++++++ OpenNest/Properties/Settings.settings | 8 +++++++- docs/nest-storage.md | 3 +++ 5 files changed, 40 insertions(+), 3 deletions(-) diff --git a/OpenNest.Data/NestBrowseSession.cs b/OpenNest.Data/NestBrowseSession.cs index ec65c03..57ec19f 100644 --- a/OpenNest.Data/NestBrowseSession.cs +++ b/OpenNest.Data/NestBrowseSession.cs @@ -15,7 +15,8 @@ public sealed class NestBrowseSession : IDisposable private int _generation; private bool _disposed; - public NestBrowseSession(INestRepository repository, int pageSize = NestQuery.DefaultLimit) + public NestBrowseSession(INestRepository repository, int pageSize = NestQuery.DefaultLimit, + NestSortField sort = NestSortField.SavedAt, bool descending = true) { ArgumentNullException.ThrowIfNull(repository); if (pageSize < 1 || pageSize > NestQuery.MaxLimit) @@ -23,6 +24,8 @@ public sealed class NestBrowseSession : IDisposable _repository = repository; PageSize = pageSize; + Sort = Enum.IsDefined(sort) ? sort : NestSortField.SavedAt; + Descending = descending; } public int PageSize { get; } diff --git a/OpenNest/Forms/SavedNestsForm.cs b/OpenNest/Forms/SavedNestsForm.cs index a58d7da..fbd628c 100644 --- a/OpenNest/Forms/SavedNestsForm.cs +++ b/OpenNest/Forms/SavedNestsForm.cs @@ -70,8 +70,17 @@ public sealed class SavedNestsForm : Form { this.repository = repository; this.serverUrl = serverUrl ?? ""; - session = new NestBrowseSession(repository); + var settings = Properties.Settings.Default; + var sort = Enum.TryParse(settings.SavedNestsSortColumn, out var savedSort) + && Enum.IsDefined(savedSort) ? savedSort : NestSortField.SavedAt; + session = new NestBrowseSession(repository, sort: sort, descending: settings.SavedNestsSortDescending); details = new NestDetailsSession(LoadDetailsAsync); + FormClosed += (_, _) => + { + settings.SavedNestsSortColumn = session.Sort.ToString(); + settings.SavedNestsSortDescending = session.Descending; + settings.Save(); + }; Text = WindowTitle; // Placed on the owner's screen in Load; see FitToScreen. diff --git a/OpenNest/Properties/Settings.Designer.cs b/OpenNest/Properties/Settings.Designer.cs index c9ca0ac..366191c 100644 --- a/OpenNest/Properties/Settings.Designer.cs +++ b/OpenNest/Properties/Settings.Designer.cs @@ -16,6 +16,22 @@ namespace OpenNest.Properties { internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("SavedAt")] + public string SavedNestsSortColumn { + get { return ((string)(this["SavedNestsSortColumn"])); } + set { this["SavedNestsSortColumn"] = value; } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool SavedNestsSortDescending { + get { return ((bool)(this["SavedNestsSortDescending"])); } + set { this["SavedNestsSortDescending"] = value; } + } public static Settings Default { get { diff --git a/OpenNest/Properties/Settings.settings b/OpenNest/Properties/Settings.settings index 2d229e7..c0ab09c 100644 --- a/OpenNest/Properties/Settings.settings +++ b/OpenNest/Properties/Settings.settings @@ -2,6 +2,12 @@ + + SavedAt + + + True + 0, 0 @@ -57,4 +63,4 @@ Classic - \ No newline at end of file + diff --git a/docs/nest-storage.md b/docs/nest-storage.md index e831cb9..3e7e426 100644 --- a/docs/nest-storage.md +++ b/docs/nest-storage.md @@ -10,6 +10,9 @@ The desktop app can save nests two ways: column header sorts every match on the server (click again to reverse); the arrow buttons move between pages and the title and find bar show the range and total. Dates and numbers are not searched as text; sort their column instead. + The selected sort column and direction are remembered for the current Windows + user when the browser closes, including across app restarts. Until a selection + is saved, nests appear newest-saved first. Below the list, the **Details** tabs show the highlighted nest's plates (duplicates, size, parts, drawings, utilization) and drawings (required, nested, remaining, area); they are read from that nest's archive, which is downloaded