mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-08 14:55:45 -05:00
feat(ui): delete plates from the Plates list's right-click menu
Add Delete Plate to the plate row menu beside Duplicate Plate, enabled when Remove Selected Plate is. Drop the Plates tab's add-plate button and the Plate menu's Add and Remove items: the list's trailing empty plate already provides new plates, and removal stays on the tab. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c8f070ea64
commit
ea540253bb
7 files changed
+24
-70
No files matched your search
@@ -68,6 +68,22 @@ public class PlateReorderTests
|
||||
Assert.NotNull(list.ContextMenuStrip);
|
||||
});
|
||||
|
||||
[Fact]
|
||||
public void DeletePlateOnTheRowMenuRemovesTheCurrentPlate() => UndoTestEnv.Run(env =>
|
||||
{
|
||||
env.Editor.PlateManager.LoadAt(0);
|
||||
var plate = env.Nest.Plates[0];
|
||||
var count = env.Nest.Plates.Count;
|
||||
var list = (ListView)Assert.Single(env.Editor.Controls.Find("platesListView", true));
|
||||
var item = Assert.IsType<ToolStripMenuItem>(list.ContextMenuStrip!.Items["deletePlateMenuItem"]);
|
||||
Assert.Equal("Delete Plate", item.Text);
|
||||
|
||||
item.PerformClick();
|
||||
|
||||
Assert.Equal(count - 1, env.Nest.Plates.Count);
|
||||
Assert.DoesNotContain(plate, env.Nest.Plates);
|
||||
});
|
||||
|
||||
[Fact]
|
||||
public void TheEmptySentinelCannotBeDuplicated() => UndoTestEnv.Run(env =>
|
||||
{
|
||||
|
||||
Generated
+1
-20
@@ -48,8 +48,6 @@
|
||||
partsColumn = new System.Windows.Forms.ColumnHeader();
|
||||
utilColumn = new System.Windows.Forms.ColumnHeader();
|
||||
toolStrip1 = new System.Windows.Forms.ToolStrip();
|
||||
toolStripLabel1 = new System.Windows.Forms.ToolStripButton();
|
||||
toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
toolStripLabel2 = new System.Windows.Forms.ToolStripButton();
|
||||
tabPage2 = new System.Windows.Forms.TabPage();
|
||||
drawingListBox1 = new OpenNest.Controls.DrawingListBox();
|
||||
@@ -159,28 +157,13 @@
|
||||
//
|
||||
toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
|
||||
toolStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripLabel1, toolStripSeparator3, toolStripLabel2 });
|
||||
toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripLabel2 });
|
||||
toolStrip1.Location = new System.Drawing.Point(4, 3);
|
||||
toolStrip1.Name = "toolStrip1";
|
||||
toolStrip1.Size = new System.Drawing.Size(265, 27);
|
||||
toolStrip1.TabIndex = 2;
|
||||
toolStrip1.Text = "toolStrip1";
|
||||
//
|
||||
// toolStripLabel1
|
||||
//
|
||||
toolStripLabel1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
toolStripLabel1.Image = Properties.Resources.plus;
|
||||
toolStripLabel1.Name = "toolStripLabel1";
|
||||
toolStripLabel1.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
||||
toolStripLabel1.Size = new System.Drawing.Size(34, 24);
|
||||
toolStripLabel1.Text = "Remove Selected Plate";
|
||||
toolStripLabel1.Click += toolStripLabel1_Click;
|
||||
//
|
||||
// toolStripSeparator3
|
||||
//
|
||||
toolStripSeparator3.Name = "toolStripSeparator3";
|
||||
toolStripSeparator3.Size = new System.Drawing.Size(6, 27);
|
||||
//
|
||||
// toolStripLabel2
|
||||
//
|
||||
toolStripLabel2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
@@ -346,8 +329,6 @@
|
||||
private System.Windows.Forms.ToolStripButton editDrawingsButton;
|
||||
private System.Windows.Forms.ToolStripButton toolStripButton3;
|
||||
private System.Windows.Forms.ToolStripButton hideNestedButton;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
|
||||
private System.Windows.Forms.ToolStripButton toolStripLabel1;
|
||||
private System.Windows.Forms.ToolStripButton toolStripLabel2;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,8 @@ using System.Windows.Forms;
|
||||
namespace OpenNest.Forms
|
||||
{
|
||||
// Reordering plates in the Plates list: drag a row to a new position, or Alt+Up/Alt+Down.
|
||||
// Ctrl+drag drops a copy of the plate instead, as does Duplicate Plate on the row's menu.
|
||||
// Ctrl+drag drops a copy of the plate instead, as does Duplicate Plate on the row's menu;
|
||||
// Delete Plate on the same menu removes it.
|
||||
// The trailing empty new-plate sentinel stays last and cannot be dragged.
|
||||
public partial class EditNestForm
|
||||
{
|
||||
@@ -46,12 +47,16 @@ namespace OpenNest.Forms
|
||||
platesListView.Controls.Add(plateDropIndicator);
|
||||
|
||||
var duplicateItem = new ToolStripMenuItem("Duplicate Plate", null, (sender, e) => DuplicateCurrentPlate());
|
||||
var deleteItem = new ToolStripMenuItem("Delete Plate", null, (sender, e) => RemoveCurrentPlate());
|
||||
deleteItem.Name = "deletePlateMenuItem";
|
||||
var menu = new ContextMenuStrip();
|
||||
menu.Items.Add(duplicateItem);
|
||||
menu.Items.Add(deleteItem);
|
||||
menu.Opening += (sender, e) =>
|
||||
{
|
||||
var index = PlateManager.CurrentIndex;
|
||||
duplicateItem.Enabled = !IsInspecting && PlateManager.CanDuplicatePlate(index, index + 1);
|
||||
deleteItem.Enabled = !IsInspecting && PlateManager.CanRemoveCurrent;
|
||||
};
|
||||
platesListView.ContextMenuStrip = menu;
|
||||
}
|
||||
|
||||
@@ -1396,11 +1396,6 @@ namespace OpenNest.Forms
|
||||
|
||||
#region Plates/Drawings Panel Events
|
||||
|
||||
private void AddPlate_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddPlate();
|
||||
}
|
||||
|
||||
private void EditSelectedPlate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (platesListView.SelectedIndices.Count != 0)
|
||||
@@ -1973,10 +1968,5 @@ namespace OpenNest.Forms
|
||||
{
|
||||
RemoveSelectedPlate_Click(sender, e);
|
||||
}
|
||||
|
||||
private void toolStripLabel1_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddPlate_Click(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+1
-28
@@ -129,9 +129,6 @@ namespace OpenNest.Forms
|
||||
mnuPlateEdit = new System.Windows.Forms.ToolStripMenuItem();
|
||||
mnuPlateSetAsDefault = new System.Windows.Forms.ToolStripMenuItem();
|
||||
toolStripMenuItem18 = new System.Windows.Forms.ToolStripSeparator();
|
||||
mnuPlateAdd = new System.Windows.Forms.ToolStripMenuItem();
|
||||
mnuPlateRemove = new System.Windows.Forms.ToolStripMenuItem();
|
||||
toolStripMenuItem16 = new System.Windows.Forms.ToolStripSeparator();
|
||||
mnuPlateRotate = new System.Windows.Forms.ToolStripMenuItem();
|
||||
mnuPlateRotateCw = new System.Windows.Forms.ToolStripMenuItem();
|
||||
mnuPlateRotateCcw = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -850,7 +847,7 @@ namespace OpenNest.Forms
|
||||
//
|
||||
// mnuPlate
|
||||
//
|
||||
mnuPlate.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuPlateEdit, mnuPlateSetAsDefault, toolStripMenuItem18, mnuPlateAdd, mnuPlateRemove, toolStripMenuItem16, mnuPlateCutOff, mnuPlateTrimExtendCutOff, mnuPlateAutomaticCutOff, mnuPlateEditClamps, mnuPlateRotate, mnuResizeToFitParts, toolStripMenuItem13, mnuPlateArrange, mnuSequenceParts, calculateCutTimeToolStripMenuItem1, mnuPlateSimulateCutting, toolStripMenuItem21, mnuPlatePlanCutting, mnuPlatePlaceLeadIn, mnuPlateRemoveLeadIns, toolStripMenuItem20, mnuPlateViewInCad });
|
||||
mnuPlate.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuPlateEdit, mnuPlateSetAsDefault, toolStripMenuItem18, mnuPlateCutOff, mnuPlateTrimExtendCutOff, mnuPlateAutomaticCutOff, mnuPlateEditClamps, mnuPlateRotate, mnuResizeToFitParts, toolStripMenuItem13, mnuPlateArrange, mnuSequenceParts, calculateCutTimeToolStripMenuItem1, mnuPlateSimulateCutting, toolStripMenuItem21, mnuPlatePlanCutting, mnuPlatePlaceLeadIn, mnuPlateRemoveLeadIns, toolStripMenuItem20, mnuPlateViewInCad });
|
||||
mnuPlate.Name = "mnuPlate";
|
||||
mnuPlate.Size = new System.Drawing.Size(45, 20);
|
||||
mnuPlate.Text = "&Plate";
|
||||
@@ -873,27 +870,6 @@ namespace OpenNest.Forms
|
||||
//
|
||||
toolStripMenuItem18.Name = "toolStripMenuItem18";
|
||||
toolStripMenuItem18.Size = new System.Drawing.Size(174, 6);
|
||||
//
|
||||
// mnuPlateAdd
|
||||
//
|
||||
mnuPlateAdd.Image = Properties.Resources.add;
|
||||
mnuPlateAdd.Name = "mnuPlateAdd";
|
||||
mnuPlateAdd.Size = new System.Drawing.Size(177, 22);
|
||||
mnuPlateAdd.Text = "Add";
|
||||
mnuPlateAdd.Click += AddPlate_Click;
|
||||
//
|
||||
// mnuPlateRemove
|
||||
//
|
||||
mnuPlateRemove.Image = Properties.Resources.remove;
|
||||
mnuPlateRemove.Name = "mnuPlateRemove";
|
||||
mnuPlateRemove.Size = new System.Drawing.Size(177, 22);
|
||||
mnuPlateRemove.Text = "Remove";
|
||||
mnuPlateRemove.Click += RemovePlate_Click;
|
||||
//
|
||||
// toolStripMenuItem16
|
||||
//
|
||||
toolStripMenuItem16.Name = "toolStripMenuItem16";
|
||||
toolStripMenuItem16.Size = new System.Drawing.Size(174, 6);
|
||||
//
|
||||
// mnuPlateCutOff
|
||||
//
|
||||
@@ -1572,7 +1548,6 @@ namespace OpenNest.Forms
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem13;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuPlateViewInCad;
|
||||
private System.Windows.Forms.ToolStripButton btnNew;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuPlateAdd;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuNestRemoveEmptyPlates;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuNestClear;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuViewZoomIn;
|
||||
@@ -1582,11 +1557,9 @@ namespace OpenNest.Forms
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuSetRotationIncrement;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem15;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuPlateSetAsDefault;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem16;
|
||||
private System.Windows.Forms.ToolStripStatusLabel statusLabel1;
|
||||
private System.Windows.Forms.ToolStripStatusLabel spacerLabel;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem18;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuPlateRemove;
|
||||
private System.Windows.Forms.ToolStripButton btnSave;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem19;
|
||||
private System.Windows.Forms.ToolStripMenuItem calculateCutTimeToolStripMenuItem;
|
||||
|
||||
@@ -30,7 +30,6 @@ namespace OpenNest.Forms
|
||||
{
|
||||
NavigationEnableCheck();
|
||||
statusBar.UpdatePlate();
|
||||
mnuPlateRemove.Enabled = activeForm?.PlateManager.CanRemoveCurrent ?? false;
|
||||
mnuNestClear.Enabled = activeForm?.PlateManager.CanClearAll ?? false;
|
||||
};
|
||||
editForm.WindowState = windowState;
|
||||
|
||||
@@ -16,18 +16,8 @@ namespace OpenNest.Forms
|
||||
SaveCurrentAsDefaults_Click(sender, e);
|
||||
}
|
||||
|
||||
private void AddPlate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.AddPlate();
|
||||
NavigationEnableCheck();
|
||||
}
|
||||
|
||||
private void EditPlate_Click(object sender, EventArgs e) => WithActive(f => f.EditPlate());
|
||||
|
||||
private void RemovePlate_Click(object sender, EventArgs e) => WithActive(f => f.RemoveCurrentPlate());
|
||||
|
||||
private void ResizeToFitParts_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
|
||||
Reference in new issue
Block a user