feat: add Edit Drawings in Converter button to reopen nest drawings in CadConverterForm

Adds a toolbar button on the Drawings tab that opens the CAD converter
pre-populated with the current nest drawings, allowing users to revisit
layer filtering, quantities, and other settings without re-importing.

Also fixes PlateView stealing focus from text inputs on mouse enter
and FilterPanel crashing when loaded before form handle is created.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-08 08:37:20 -04:00
parent b2a723ca60
commit 7c28a35ad8
6 changed files with 1027 additions and 813 deletions

View File

@@ -154,7 +154,10 @@ namespace OpenNest.Controls
Font = new Font("Segoe UI", 9f)
};
list.ItemCheck += (s, e) =>
BeginInvoke((Action)(() => FilterChanged?.Invoke(this, EventArgs.Empty)));
{
if (IsHandleCreated)
BeginInvoke((Action)(() => FilterChanged?.Invoke(this, EventArgs.Empty)));
};
return list;
}

View File

@@ -225,7 +225,6 @@ namespace OpenNest.Controls
protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter(e);
if (!Focused) Focus();
}
protected override void OnDragEnter(DragEventArgs drgevent)
@@ -249,6 +248,8 @@ namespace OpenNest.Controls
protected override void OnMouseDown(MouseEventArgs e)
{
if (!Focused) Focus();
if (e.Button == MouseButtons.Middle)
middleMouseDownPoint = e.Location;

View File

@@ -604,6 +604,44 @@ namespace OpenNest.Forms
#endregion
#region Load Existing Drawings
public void LoadDrawings(IEnumerable<Drawing> drawings)
{
foreach (var drawing in drawings)
{
var entities = ConvertProgram.ToGeometry(drawing.Program);
// Re-apply source offset so entities appear in their natural position
if (drawing.Source?.Offset != null && drawing.Source.Offset != Vector.Zero)
{
foreach (var entity in entities)
entity.Offset(drawing.Source.Offset);
}
// Remove rapid traversals — they aren't part of the cut geometry
entities.RemoveAll(e => e.Layer == SpecialLayers.Rapid);
var bounds = entities.GetBoundingBox();
var item = new FileListItem
{
Name = drawing.Name,
Entities = entities,
Path = drawing.Source?.Path,
Quantity = drawing.Quantity.Required,
Customer = drawing.Customer ?? string.Empty,
Bends = drawing.Bends?.ToList() ?? new List<Bend>(),
Bounds = bounds,
EntityCount = entities.Count
};
fileList.AddItem(item);
}
}
#endregion
#region Output
public List<Drawing> GetDrawings()

View File

@@ -47,6 +47,8 @@
drawingListBox1 = new OpenNest.Controls.DrawingListBox();
toolStrip2 = new System.Windows.Forms.ToolStrip();
toolStripButton2 = new System.Windows.Forms.ToolStripButton();
toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
editDrawingsButton = new System.Windows.Forms.ToolStripButton();
toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
toolStripButton3 = new System.Windows.Forms.ToolStripButton();
toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
@@ -217,7 +219,7 @@
//
toolStrip2.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
toolStrip2.ImageScalingSize = new System.Drawing.Size(20, 20);
toolStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripButton2, toolStripSeparator1, toolStripButton3, toolStripSeparator2, hideNestedButton });
toolStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripButton2, toolStripSeparator4, editDrawingsButton, toolStripSeparator1, toolStripButton3, toolStripSeparator2, hideNestedButton });
toolStrip2.Location = new System.Drawing.Point(4, 3);
toolStrip2.Name = "toolStrip2";
toolStrip2.Size = new System.Drawing.Size(265, 27);
@@ -236,6 +238,21 @@
toolStripButton2.Text = "Import Drawings";
toolStripButton2.Click += ImportDrawings_Click;
//
// toolStripSeparator4
//
toolStripSeparator4.Name = "toolStripSeparator4";
toolStripSeparator4.Size = new System.Drawing.Size(6, 27);
//
// editDrawingsButton
//
editDrawingsButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
editDrawingsButton.Image = (System.Drawing.Image)resources.GetObject("editDrawingsButton.Image");
editDrawingsButton.Name = "editDrawingsButton";
editDrawingsButton.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0);
editDrawingsButton.Size = new System.Drawing.Size(34, 24);
editDrawingsButton.Text = "Edit Drawings in Converter";
editDrawingsButton.Click += EditDrawingsInConverter_Click;
//
// toolStripSeparator1
//
toolStripSeparator1.Name = "toolStripSeparator1";
@@ -312,6 +329,8 @@
private System.Windows.Forms.ColumnHeader utilColumn;
private System.Windows.Forms.ToolStrip toolStrip2;
private System.Windows.Forms.ToolStripButton toolStripButton2;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
private System.Windows.Forms.ToolStripButton editDrawingsButton;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripButton toolStripButton3;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;

View File

@@ -52,6 +52,7 @@ namespace OpenNest.Forms
private EditNestForm()
{
PlateView = new PlateView();
PlateView.MouseEnter += PlateView_MouseEnter;
PlateView.Enter += PlateView_Enter;
PlateView.PartAdded += PlateView_PartAdded;
PlateView.PartRemoved += PlateView_PartRemoved;
@@ -862,6 +863,24 @@ namespace OpenNest.Forms
Import();
}
private void EditDrawingsInConverter_Click(object sender, EventArgs e)
{
if (Nest.Drawings.Count == 0)
return;
var converter = new CadConverterForm();
converter.LoadDrawings(Nest.Drawings);
if (converter.ShowDialog() != DialogResult.OK)
return;
var drawings = converter.GetDrawings();
// Replace all drawings — clear existing and add new ones
Nest.Drawings.Clear();
drawings.ForEach(d => Nest.Drawings.Add(d));
}
private void CleanUnusedDrawings_Click(object sender, EventArgs e)
{
var result = MessageBox.Show(
@@ -1026,6 +1045,12 @@ namespace OpenNest.Forms
addPart = true;
}
private void PlateView_MouseEnter(object sender, EventArgs e)
{
if (!PlateView.Focused)
PlateView.Focus();
}
private void PlateView_Enter(object sender, EventArgs e)
{
if (!addPart)

File diff suppressed because it is too large Load Diff