mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-11 14:24:13 -04:00
Remember saved nest browser sort preferences
This commit is contained in:
1 parent
d59c03f5ab
commit
72776886cb
5 files changed
+40
-3
No files matched your search
@@ -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; }
|
||||
|
||||
@@ -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<NestSortField>(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.
|
||||
|
||||
Generated
+16
@@ -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 {
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="OpenNest.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="SavedNestsSortColumn" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">SavedAt</Value>
|
||||
</Setting>
|
||||
<Setting Name="SavedNestsSortDescending" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="MainWindowLocation" Type="System.Drawing.Point" Scope="User">
|
||||
<Value Profile="(Default)">0, 0</Value>
|
||||
</Setting>
|
||||
@@ -57,4 +63,4 @@
|
||||
<Value Profile="(Default)">Classic</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
</SettingsFile>
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user