feat: persist plate optimizer settings across autonest runs

Add LoadPlateOptions() method to AutoNestForm that restores saved plate
options and salvage rate from the Nest. Call this method in
RunAutoNest_Click when opening the dialog if saved options exist, and save
settings back to Nest after dialog completion.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-05 00:38:59 -04:00
parent ffd060bf61
commit 981188f65e
2 changed files with 26 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows.Forms;
namespace OpenNest.Forms
@@ -76,6 +77,22 @@ namespace OpenNest.Forms
plateOptionsGrid.DataSource = items;
}
public void LoadPlateOptions(List<PlateOption> options, double salvageRate)
{
if (options != null && options.Count > 0)
{
var items = options.Select(o => new PlateOptionItem
{
Width = o.Width,
Length = o.Length,
Cost = o.Cost,
}).ToList();
plateOptionsGrid.DataSource = items;
optimizePlateSizeBox.Checked = true;
}
SalvageRate = salvageRate;
}
private void optimizePlateSizeBox_CheckedChanged(object sender, EventArgs e)
{
plateOptionsPanel.Visible = optimizePlateSizeBox.Checked;

View File

@@ -900,6 +900,9 @@ namespace OpenNest.Forms
var form = new AutoNestForm(activeForm.Nest);
form.AllowPlateCreation = true;
if (activeForm.Nest.PlateOptions.Count > 0)
form.LoadPlateOptions(activeForm.Nest.PlateOptions, activeForm.Nest.SalvageRate);
if (form.ShowDialog() != System.Windows.Forms.DialogResult.OK)
return;
@@ -912,6 +915,12 @@ namespace OpenNest.Forms
var plateOptions = optimizePlateSize ? form.GetPlateOptions() : null;
var salvageRate = form.SalvageRate;
if (optimizePlateSize)
{
activeForm.Nest.PlateOptions = plateOptions;
activeForm.Nest.SalvageRate = salvageRate;
}
nestingCts = new CancellationTokenSource();
var progressForm = new NestProgressForm(nestingCts, showPlateRow: true);
progressForm.PreviewPlate = CreatePreviewPlate(activeForm.PlateView.Plate);