feat: add context menu to delete drawings from the drawing list

Adds a right-click "Delete" option on the drawings tab that removes the
selected drawing and all its placed parts from every plate.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-05 13:34:18 -04:00
parent 81c167320d
commit 6f19fe1822
2 changed files with 46 additions and 1 deletions
+27
View File
@@ -225,6 +225,7 @@ namespace OpenNest.Forms
Text = Nest.Name;
drawingListBox1.Units = Nest.Units;
drawingListBox1.DeleteRequested += drawingListBox1_DeleteRequested;
}
public string LastSavePath { get; private set; }
@@ -1026,6 +1027,32 @@ namespace OpenNest.Forms
}
}
private void drawingListBox1_DeleteRequested(object sender, Drawing drawing)
{
var result = MessageBox.Show(
$"Delete drawing '{drawing.Name}' and all its parts from every plate?",
"Delete Drawing",
MessageBoxButtons.YesNo,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button2);
if (result != DialogResult.Yes)
return;
foreach (var plate in Nest.Plates)
{
for (var i = plate.Parts.Count - 1; i >= 0; i--)
{
if (plate.Parts[i].BaseDrawing == drawing)
plate.Parts.RemoveAt(i);
}
}
Nest.Drawings.Remove(drawing);
UpdateDrawingList();
PlateView.Invalidate();
}
private void drawingListBox1_Click(object sender, EventArgs e)
{
addPart = true;