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:
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace OpenNest.Forms
|
namespace OpenNest.Forms
|
||||||
@@ -76,6 +77,22 @@ namespace OpenNest.Forms
|
|||||||
plateOptionsGrid.DataSource = items;
|
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)
|
private void optimizePlateSizeBox_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
plateOptionsPanel.Visible = optimizePlateSizeBox.Checked;
|
plateOptionsPanel.Visible = optimizePlateSizeBox.Checked;
|
||||||
|
|||||||
@@ -900,6 +900,9 @@ namespace OpenNest.Forms
|
|||||||
var form = new AutoNestForm(activeForm.Nest);
|
var form = new AutoNestForm(activeForm.Nest);
|
||||||
form.AllowPlateCreation = true;
|
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)
|
if (form.ShowDialog() != System.Windows.Forms.DialogResult.OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -912,6 +915,12 @@ namespace OpenNest.Forms
|
|||||||
var plateOptions = optimizePlateSize ? form.GetPlateOptions() : null;
|
var plateOptions = optimizePlateSize ? form.GetPlateOptions() : null;
|
||||||
var salvageRate = form.SalvageRate;
|
var salvageRate = form.SalvageRate;
|
||||||
|
|
||||||
|
if (optimizePlateSize)
|
||||||
|
{
|
||||||
|
activeForm.Nest.PlateOptions = plateOptions;
|
||||||
|
activeForm.Nest.SalvageRate = salvageRate;
|
||||||
|
}
|
||||||
|
|
||||||
nestingCts = new CancellationTokenSource();
|
nestingCts = new CancellationTokenSource();
|
||||||
var progressForm = new NestProgressForm(nestingCts, showPlateRow: true);
|
var progressForm = new NestProgressForm(nestingCts, showPlateRow: true);
|
||||||
progressForm.PreviewPlate = CreatePreviewPlate(activeForm.PlateView.Plate);
|
progressForm.PreviewPlate = CreatePreviewPlate(activeForm.PlateView.Plate);
|
||||||
|
|||||||
Reference in New Issue
Block a user