feat(ui): move plate navigation from toolbar to header above PlateView

Plate nav buttons (first/prev/next/last) now sit in a centered header
bar above the PlateView with a plate info label on the left, making
navigation more accessible without reaching up to the main toolbar.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-17 09:35:18 -04:00
parent d210d29554
commit 4616f077d5
3 changed files with 107 additions and 84 deletions

View File

@@ -28,6 +28,13 @@ namespace OpenNest.Forms
private readonly Timer updateDrawingListTimer; private readonly Timer updateDrawingListTimer;
private Panel plateHeaderPanel;
private Label plateInfoLabel;
private Button btnFirstPlate;
private Button btnPreviousPlate;
private Button btnNextPlate;
private Button btnLastPlate;
/// <summary> /// <summary>
/// Used to distinguish between single/double click on drawing within drawinglistbox. /// Used to distinguish between single/double click on drawing within drawinglistbox.
/// If double click, this is set to false so the single click action won't be triggered. /// If double click, this is set to false so the single click action won't be triggered.
@@ -43,8 +50,10 @@ namespace OpenNest.Forms
PlateView.Dock = DockStyle.Fill; PlateView.Dock = DockStyle.Fill;
InitializeComponent(); InitializeComponent();
CreatePlateHeader();
splitContainer.Panel2.Controls.Add(PlateView); splitContainer.Panel2.Controls.Add(PlateView);
splitContainer.Panel2.Controls.Add(plateHeaderPanel);
var renderer = new ToolStripRenderer(ToolbarTheme.Toolbar); var renderer = new ToolStripRenderer(ToolbarTheme.Toolbar);
toolStrip1.Renderer = renderer; toolStrip1.Renderer = renderer;
@@ -62,6 +71,81 @@ namespace OpenNest.Forms
}; };
} }
private void CreatePlateHeader()
{
plateHeaderPanel = new Panel
{
Dock = DockStyle.Top,
Height = 30,
BackColor = Color.FromArgb(240, 240, 240),
Padding = new Padding(4, 0, 4, 0)
};
plateInfoLabel = new Label
{
AutoSize = true,
TextAlign = ContentAlignment.MiddleLeft,
Font = new Font("Segoe UI", 12f, FontStyle.Bold),
ForeColor = Color.FromArgb(120, 120, 120),
Dock = DockStyle.Left,
Padding = new Padding(4, 4, 4, 4)
};
var btnSize = new System.Drawing.Size(28, 28);
btnFirstPlate = CreateNavButton(Resources.move_first);
btnFirstPlate.Click += (s, e) => LoadFirstPlate();
btnPreviousPlate = CreateNavButton(Resources.move_previous);
btnPreviousPlate.Click += (s, e) => LoadPreviousPlate();
btnNextPlate = CreateNavButton(Resources.move_next);
btnNextPlate.Click += (s, e) => LoadNextPlate();
btnLastPlate = CreateNavButton(Resources.move_last);
btnLastPlate.Click += (s, e) => LoadLastPlate();
// Panel that holds the nav buttons and centers itself in the header
var navPanel = new Panel
{
Width = btnSize.Width * 4,
Height = btnSize.Height,
Anchor = AnchorStyles.None
};
btnFirstPlate.Location = new Point(0, 0);
btnPreviousPlate.Location = new Point(btnSize.Width, 0);
btnNextPlate.Location = new Point(btnSize.Width * 2, 0);
btnLastPlate.Location = new Point(btnSize.Width * 3, 0);
navPanel.Controls.AddRange(new Control[] { btnFirstPlate, btnPreviousPlate, btnNextPlate, btnLastPlate });
plateHeaderPanel.Controls.Add(navPanel);
plateHeaderPanel.Controls.Add(plateInfoLabel);
// Center the nav panel on resize
CenterNavPanel(navPanel);
plateHeaderPanel.Resize += (s, e) => CenterNavPanel(navPanel);
}
private void CenterNavPanel(Panel navPanel)
{
navPanel.Left = (plateHeaderPanel.Width - navPanel.Width) / 2;
navPanel.Top = (plateHeaderPanel.Height - navPanel.Height) / 2;
}
private static Button CreateNavButton(System.Drawing.Image image)
{
return new Button
{
Image = image,
Size = new System.Drawing.Size(28, 28),
FlatStyle = FlatStyle.Flat,
FlatAppearance = { BorderSize = 0 },
Cursor = Cursors.Hand
};
}
public EditNestForm(Nest nest) public EditNestForm(Nest nest)
: this() : this()
{ {
@@ -518,10 +602,32 @@ namespace OpenNest.Forms
if (updateListView) if (updateListView)
platesListView.Items[CurrentPlateIndex].Selected = true; platesListView.Items[CurrentPlateIndex].Selected = true;
UpdatePlateHeader();
if (PlateChanged != null) if (PlateChanged != null)
PlateChanged.Invoke(this, EventArgs.Empty); PlateChanged.Invoke(this, EventArgs.Empty);
} }
private void UpdatePlateHeader()
{
var plate = Nest.Plates.Count > 0 ? Nest.Plates[CurrentPlateIndex] : null;
if (plate != null)
{
plateInfoLabel.Text = string.Format("Plate {0} of {1} | {2}",
CurrentPlateIndex + 1, Nest.Plates.Count, plate.Size);
}
else
{
plateInfoLabel.Text = "No plates";
}
btnFirstPlate.Enabled = !IsFirstPlate();
btnPreviousPlate.Enabled = !IsFirstPlate();
btnNextPlate.Enabled = !IsLastPlate();
btnLastPlate.Enabled = !IsLastPlate();
}
#region Overrides #region Overrides
protected override void OnSizeChanged(EventArgs e) protected override void OnSizeChanged(EventArgs e)

View File

@@ -137,11 +137,6 @@
btnSave = new System.Windows.Forms.ToolStripButton(); btnSave = new System.Windows.Forms.ToolStripButton();
btnSaveAs = new System.Windows.Forms.ToolStripButton(); btnSaveAs = new System.Windows.Forms.ToolStripButton();
toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
btnFirstPlate = new System.Windows.Forms.ToolStripButton();
btnPreviousPlate = new System.Windows.Forms.ToolStripButton();
btnNextPlate = new System.Windows.Forms.ToolStripButton();
btnLastPlate = new System.Windows.Forms.ToolStripButton();
toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
btnZoomOut = new System.Windows.Forms.ToolStripButton(); btnZoomOut = new System.Windows.Forms.ToolStripButton();
btnZoomIn = new System.Windows.Forms.ToolStripButton(); btnZoomIn = new System.Windows.Forms.ToolStripButton();
btnZoomToFit = new System.Windows.Forms.ToolStripButton(); btnZoomToFit = new System.Windows.Forms.ToolStripButton();
@@ -889,7 +884,7 @@
// toolStrip1 // toolStrip1
// //
toolStrip1.AutoSize = false; toolStrip1.AutoSize = false;
toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { btnNew, btnOpen, btnSave, btnSaveAs, toolStripSeparator1, btnFirstPlate, btnPreviousPlate, btnNextPlate, btnLastPlate, toolStripSeparator3, btnZoomOut, btnZoomIn, btnZoomToFit, toolStripSeparator4, engineLabel, engineComboBox, btnAutoNest, btnShowRemnants }); toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { btnNew, btnOpen, btnSave, btnSaveAs, toolStripSeparator1, btnZoomOut, btnZoomIn, btnZoomToFit, toolStripSeparator4, engineLabel, engineComboBox, btnAutoNest, btnShowRemnants });
toolStrip1.Location = new System.Drawing.Point(0, 24); toolStrip1.Location = new System.Drawing.Point(0, 24);
toolStrip1.Name = "toolStrip1"; toolStrip1.Name = "toolStrip1";
toolStrip1.Size = new System.Drawing.Size(1281, 40); toolStrip1.Size = new System.Drawing.Size(1281, 40);
@@ -949,61 +944,6 @@
toolStripSeparator1.Name = "toolStripSeparator1"; toolStripSeparator1.Name = "toolStripSeparator1";
toolStripSeparator1.Size = new System.Drawing.Size(6, 40); toolStripSeparator1.Size = new System.Drawing.Size(6, 40);
// //
// btnFirstPlate
//
btnFirstPlate.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
btnFirstPlate.Image = Properties.Resources.move_first;
btnFirstPlate.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
btnFirstPlate.ImageTransparentColor = System.Drawing.Color.Magenta;
btnFirstPlate.Name = "btnFirstPlate";
btnFirstPlate.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0);
btnFirstPlate.Size = new System.Drawing.Size(38, 37);
btnFirstPlate.Text = "Go to First Plate";
btnFirstPlate.Click += LoadFirstPlate_Click;
//
// btnPreviousPlate
//
btnPreviousPlate.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
btnPreviousPlate.Image = Properties.Resources.move_previous;
btnPreviousPlate.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
btnPreviousPlate.ImageTransparentColor = System.Drawing.Color.Magenta;
btnPreviousPlate.Name = "btnPreviousPlate";
btnPreviousPlate.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0);
btnPreviousPlate.Size = new System.Drawing.Size(38, 37);
btnPreviousPlate.Text = "Go to Previous Plate";
btnPreviousPlate.Click += LoadPreviousPlate_Click;
//
// btnNextPlate
//
btnNextPlate.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
btnNextPlate.Image = Properties.Resources.move_next;
btnNextPlate.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
btnNextPlate.ImageTransparentColor = System.Drawing.Color.Magenta;
btnNextPlate.Name = "btnNextPlate";
btnNextPlate.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0);
btnNextPlate.RightToLeft = System.Windows.Forms.RightToLeft.No;
btnNextPlate.Size = new System.Drawing.Size(38, 37);
btnNextPlate.Text = "Go to Next Plate";
btnNextPlate.Click += LoadNextPlate_Click;
//
// btnLastPlate
//
btnLastPlate.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
btnLastPlate.Image = Properties.Resources.move_last;
btnLastPlate.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
btnLastPlate.ImageTransparentColor = System.Drawing.Color.Magenta;
btnLastPlate.Name = "btnLastPlate";
btnLastPlate.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0);
btnLastPlate.RightToLeft = System.Windows.Forms.RightToLeft.No;
btnLastPlate.Size = new System.Drawing.Size(38, 37);
btnLastPlate.Text = "Go to Last Plate";
btnLastPlate.Click += LoadLastPlate_Click;
//
// toolStripSeparator3
//
toolStripSeparator3.Name = "toolStripSeparator3";
toolStripSeparator3.Size = new System.Drawing.Size(6, 40);
//
// btnZoomOut // btnZoomOut
// //
btnZoomOut.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; btnZoomOut.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
@@ -1165,8 +1105,6 @@
private System.Windows.Forms.ToolStripButton btnOpen; private System.Windows.Forms.ToolStripButton btnOpen;
private System.Windows.Forms.ToolStripStatusLabel plateIndexStatusLabel; private System.Windows.Forms.ToolStripStatusLabel plateIndexStatusLabel;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripButton btnPreviousPlate;
private System.Windows.Forms.ToolStripButton btnNextPlate;
private System.Windows.Forms.ToolStripMenuItem mnuWindow; private System.Windows.Forms.ToolStripMenuItem mnuWindow;
private System.Windows.Forms.ToolStripMenuItem mnuWindowCascade; private System.Windows.Forms.ToolStripMenuItem mnuWindowCascade;
private System.Windows.Forms.ToolStripMenuItem mnuWindowTileVertical; private System.Windows.Forms.ToolStripMenuItem mnuWindowTileVertical;
@@ -1200,13 +1138,10 @@
private System.Windows.Forms.ToolStripMenuItem mnuPlateViewInCad; private System.Windows.Forms.ToolStripMenuItem mnuPlateViewInCad;
private System.Windows.Forms.ToolStripButton btnNew; private System.Windows.Forms.ToolStripButton btnNew;
private System.Windows.Forms.ToolStripMenuItem mnuPlateAdd; private System.Windows.Forms.ToolStripMenuItem mnuPlateAdd;
private System.Windows.Forms.ToolStripButton btnFirstPlate;
private System.Windows.Forms.ToolStripButton btnLastPlate;
private System.Windows.Forms.ToolStripButton btnZoomToFit; private System.Windows.Forms.ToolStripButton btnZoomToFit;
private System.Windows.Forms.ToolStripMenuItem mnuNestRemoveEmptyPlates; private System.Windows.Forms.ToolStripMenuItem mnuNestRemoveEmptyPlates;
private System.Windows.Forms.ToolStripMenuItem mnuViewZoomIn; private System.Windows.Forms.ToolStripMenuItem mnuViewZoomIn;
private System.Windows.Forms.ToolStripMenuItem mnuViewZoomOut; private System.Windows.Forms.ToolStripMenuItem mnuViewZoomOut;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem14; private System.Windows.Forms.ToolStripSeparator toolStripMenuItem14;
private System.Windows.Forms.ToolStripMenuItem mnuSetOffsetIncrement; private System.Windows.Forms.ToolStripMenuItem mnuSetOffsetIncrement;
private System.Windows.Forms.ToolStripMenuItem mnuSetRotationIncrement; private System.Windows.Forms.ToolStripMenuItem mnuSetRotationIncrement;

View File

@@ -155,30 +155,16 @@ namespace OpenNest.Forms
if (activeForm == null) if (activeForm == null)
{ {
mnuNestPreviousPlate.Enabled = false; mnuNestPreviousPlate.Enabled = false;
btnPreviousPlate.Enabled = false;
mnuNestNextPlate.Enabled = false; mnuNestNextPlate.Enabled = false;
btnNextPlate.Enabled = false;
mnuNestFirstPlate.Enabled = false; mnuNestFirstPlate.Enabled = false;
btnFirstPlate.Enabled = false;
mnuNestLastPlate.Enabled = false; mnuNestLastPlate.Enabled = false;
btnLastPlate.Enabled = false;
} }
else else
{ {
mnuNestPreviousPlate.Enabled = !activeForm.IsFirstPlate(); mnuNestPreviousPlate.Enabled = !activeForm.IsFirstPlate();
btnPreviousPlate.Enabled = !activeForm.IsFirstPlate();
mnuNestNextPlate.Enabled = !activeForm.IsLastPlate(); mnuNestNextPlate.Enabled = !activeForm.IsLastPlate();
btnNextPlate.Enabled = !activeForm.IsLastPlate();
mnuNestFirstPlate.Enabled = activeForm.PlateCount > 0 && !activeForm.IsFirstPlate(); mnuNestFirstPlate.Enabled = activeForm.PlateCount > 0 && !activeForm.IsFirstPlate();
btnFirstPlate.Enabled = activeForm.PlateCount > 0 && !activeForm.IsFirstPlate();
mnuNestLastPlate.Enabled = activeForm.PlateCount > 0 && !activeForm.IsLastPlate(); mnuNestLastPlate.Enabled = activeForm.PlateCount > 0 && !activeForm.IsLastPlate();
btnLastPlate.Enabled = activeForm.PlateCount > 0 && !activeForm.IsLastPlate();
} }
} }
@@ -192,13 +178,9 @@ namespace OpenNest.Forms
// Lock plate navigation // Lock plate navigation
mnuNestPreviousPlate.Enabled = !locked && activeForm != null && !activeForm.IsFirstPlate(); mnuNestPreviousPlate.Enabled = !locked && activeForm != null && !activeForm.IsFirstPlate();
btnPreviousPlate.Enabled = mnuNestPreviousPlate.Enabled;
mnuNestNextPlate.Enabled = !locked && activeForm != null && !activeForm.IsLastPlate(); mnuNestNextPlate.Enabled = !locked && activeForm != null && !activeForm.IsLastPlate();
btnNextPlate.Enabled = mnuNestNextPlate.Enabled;
mnuNestFirstPlate.Enabled = !locked && activeForm != null && activeForm.PlateCount > 0 && !activeForm.IsFirstPlate(); mnuNestFirstPlate.Enabled = !locked && activeForm != null && activeForm.PlateCount > 0 && !activeForm.IsFirstPlate();
btnFirstPlate.Enabled = mnuNestFirstPlate.Enabled;
mnuNestLastPlate.Enabled = !locked && activeForm != null && activeForm.PlateCount > 0 && !activeForm.IsLastPlate(); mnuNestLastPlate.Enabled = !locked && activeForm != null && activeForm.PlateCount > 0 && !activeForm.IsLastPlate();
btnLastPlate.Enabled = mnuNestLastPlate.Enabled;
} }
private void UpdateLocationStatus() private void UpdateLocationStatus()