mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-11 06:24:13 -04:00
Move zoom controls into centered plate view header
This commit is contained in:
1 parent
90ae3b6a84
commit
c28ccd7568
4 files changed
+61
-69
No files matched your search
@@ -104,11 +104,11 @@ namespace OpenNest.Forms
|
||||
|
||||
plateInfoLabel = new Label
|
||||
{
|
||||
AutoSize = true,
|
||||
AutoSize = false,
|
||||
AutoEllipsis = 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),
|
||||
};
|
||||
|
||||
@@ -126,10 +126,30 @@ namespace OpenNest.Forms
|
||||
btnLastPlate = CreateNavButton(Resources.move_last);
|
||||
btnLastPlate.Click += (s, e) => PlateManager.LoadLast();
|
||||
|
||||
// Panel that holds the nav buttons and centers itself in the header
|
||||
var zoomOutButton = CreateNavButton(Resources.zoom_out);
|
||||
zoomOutButton.Name = "btnZoomOut";
|
||||
zoomOutButton.AccessibleName = "Zoom Out";
|
||||
zoomOutButton.Click += (s, e) => ZoomPlateView(1.0f / 1.5f);
|
||||
|
||||
var zoomInButton = CreateNavButton(Resources.zoom_in);
|
||||
zoomInButton.Name = "btnZoomIn";
|
||||
zoomInButton.AccessibleName = "Zoom In";
|
||||
zoomInButton.Click += (s, e) => ZoomPlateView(1.5f);
|
||||
|
||||
var zoomToFitButton = CreateNavButton(Resources.zoom_all);
|
||||
zoomToFitButton.Name = "btnZoomToFit";
|
||||
zoomToFitButton.AccessibleName = "Zoom To Fit";
|
||||
zoomToFitButton.Click += (s, e) => PlateView.ZoomToFit();
|
||||
|
||||
var toolTip = new ToolTip(components);
|
||||
toolTip.SetToolTip(zoomOutButton, "Zoom Out (Ctrl+Minus)");
|
||||
toolTip.SetToolTip(zoomInButton, "Zoom In (Ctrl+Plus)");
|
||||
toolTip.SetToolTip(zoomToFitButton, "Zoom To Fit (F)");
|
||||
|
||||
// Keep navigation and zoom controls together in the header.
|
||||
var navPanel = new Panel
|
||||
{
|
||||
Width = btnSize.Width * 4,
|
||||
Width = btnSize.Width * 7 + 8,
|
||||
Height = btnSize.Height,
|
||||
Anchor = AnchorStyles.None,
|
||||
};
|
||||
@@ -139,22 +159,47 @@ namespace OpenNest.Forms
|
||||
btnNextPlate.Location = new Point(btnSize.Width * 2, 0);
|
||||
btnLastPlate.Location = new Point(btnSize.Width * 3, 0);
|
||||
|
||||
zoomOutButton.Location = new Point(btnSize.Width * 4 + 8, 0);
|
||||
zoomInButton.Location = new Point(btnSize.Width * 5 + 8, 0);
|
||||
zoomToFitButton.Location = new Point(btnSize.Width * 6 + 8, 0);
|
||||
|
||||
var separator = new Panel
|
||||
{
|
||||
Location = new Point(btnSize.Width * 4 + 3, 4),
|
||||
Size = new System.Drawing.Size(1, btnSize.Height - 8),
|
||||
BackColor = SystemColors.ControlDark,
|
||||
TabStop = false,
|
||||
};
|
||||
|
||||
navPanel.Controls.AddRange(
|
||||
new Control[] { btnFirstPlate, btnPreviousPlate, btnNextPlate, btnLastPlate }
|
||||
new Control[]
|
||||
{
|
||||
btnFirstPlate, btnPreviousPlate, btnNextPlate, btnLastPlate,
|
||||
separator, zoomOutButton, zoomInButton, zoomToFitButton
|
||||
}
|
||||
);
|
||||
|
||||
plateHeaderPanel.Controls.Add(navPanel);
|
||||
plateHeaderPanel.Controls.Add(plateInfoLabel);
|
||||
|
||||
// Center the nav panel on resize
|
||||
CenterNavPanel(navPanel);
|
||||
plateHeaderPanel.Resize += (s, e) => CenterNavPanel(navPanel);
|
||||
plateHeaderPanel.Controls.Add(navPanel);
|
||||
plateHeaderPanel.Layout += (s, e) => CenterPlateHeaderControls(navPanel);
|
||||
CenterPlateHeaderControls(navPanel);
|
||||
}
|
||||
|
||||
private void CenterNavPanel(Panel navPanel)
|
||||
private void CenterPlateHeaderControls(Panel navPanel)
|
||||
{
|
||||
navPanel.Left = (plateHeaderPanel.Width - navPanel.Width) / 2;
|
||||
navPanel.Top = (plateHeaderPanel.Height - navPanel.Height) / 2;
|
||||
navPanel.Left = (plateHeaderPanel.ClientSize.Width - navPanel.Width) / 2;
|
||||
navPanel.Top = (plateHeaderPanel.ClientSize.Height - navPanel.Height) / 2;
|
||||
|
||||
// Reserve the space before the centered buttons for the plate label.
|
||||
var labelLeft = plateHeaderPanel.Padding.Left;
|
||||
plateInfoLabel.SetBounds(labelLeft, 0,
|
||||
System.Math.Max(0, navPanel.Left - labelLeft), plateHeaderPanel.ClientSize.Height);
|
||||
}
|
||||
|
||||
private void ZoomPlateView(float factor)
|
||||
{
|
||||
var point = new Point(PlateView.Width / 2, PlateView.Height / 2);
|
||||
PlateView.ZoomToControlPoint(point, factor);
|
||||
}
|
||||
|
||||
private void CreateSidePanel()
|
||||
|
||||
Generated
+1
-53
@@ -170,10 +170,6 @@ namespace OpenNest.Forms
|
||||
btnSave = new System.Windows.Forms.ToolStripButton();
|
||||
btnSaveAs = new System.Windows.Forms.ToolStripButton();
|
||||
toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
btnZoomOut = new System.Windows.Forms.ToolStripButton();
|
||||
btnZoomIn = new System.Windows.Forms.ToolStripButton();
|
||||
btnZoomToFit = new System.Windows.Forms.ToolStripButton();
|
||||
toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
|
||||
engineLabel = new System.Windows.Forms.ToolStripLabel();
|
||||
engineComboBox = new System.Windows.Forms.ToolStripComboBox();
|
||||
btnAutoNest = new System.Windows.Forms.ToolStripButton();
|
||||
@@ -1141,7 +1137,7 @@ namespace OpenNest.Forms
|
||||
// toolStrip1
|
||||
//
|
||||
toolStrip1.AutoSize = false;
|
||||
toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { btnNew, btnOpen, btnSave, btnSaveAs, toolStripSeparator1, btnZoomOut, btnZoomIn, btnZoomToFit, toolStripSeparator4, engineLabel, engineComboBox, btnAutoNest, btnShowRemnants, toolStripSeparator5, btnCutOff });
|
||||
toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { btnNew, btnOpen, btnSave, btnSaveAs, toolStripSeparator1, engineLabel, engineComboBox, btnAutoNest, btnShowRemnants, toolStripSeparator5, btnCutOff });
|
||||
toolStrip1.Location = new System.Drawing.Point(0, 24);
|
||||
toolStrip1.Name = "toolStrip1";
|
||||
toolStrip1.Size = new System.Drawing.Size(1281, 40);
|
||||
@@ -1201,50 +1197,6 @@ namespace OpenNest.Forms
|
||||
toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
toolStripSeparator1.Size = new System.Drawing.Size(6, 40);
|
||||
//
|
||||
// btnZoomOut
|
||||
//
|
||||
btnZoomOut.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
btnZoomOut.Image = Properties.Resources.zoom_out;
|
||||
btnZoomOut.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
|
||||
btnZoomOut.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
btnZoomOut.Name = "btnZoomOut";
|
||||
btnZoomOut.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
||||
btnZoomOut.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||
btnZoomOut.Size = new System.Drawing.Size(38, 37);
|
||||
btnZoomOut.Text = "Zoom Out";
|
||||
btnZoomOut.Click += ZoomOut_Click;
|
||||
//
|
||||
// btnZoomIn
|
||||
//
|
||||
btnZoomIn.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
btnZoomIn.Image = Properties.Resources.zoom_in;
|
||||
btnZoomIn.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
|
||||
btnZoomIn.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
btnZoomIn.Name = "btnZoomIn";
|
||||
btnZoomIn.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
||||
btnZoomIn.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||
btnZoomIn.Size = new System.Drawing.Size(38, 37);
|
||||
btnZoomIn.Text = "Zoom In";
|
||||
btnZoomIn.Click += ZoomIn_Click;
|
||||
//
|
||||
// btnZoomToFit
|
||||
//
|
||||
btnZoomToFit.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
btnZoomToFit.Image = Properties.Resources.zoom_all;
|
||||
btnZoomToFit.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
|
||||
btnZoomToFit.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
btnZoomToFit.Name = "btnZoomToFit";
|
||||
btnZoomToFit.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
||||
btnZoomToFit.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||
btnZoomToFit.Size = new System.Drawing.Size(38, 37);
|
||||
btnZoomToFit.Text = "Zoom To Fit";
|
||||
btnZoomToFit.Click += ZoomToFit_Click;
|
||||
//
|
||||
// toolStripSeparator4
|
||||
//
|
||||
toolStripSeparator4.Name = "toolStripSeparator4";
|
||||
toolStripSeparator4.Size = new System.Drawing.Size(6, 40);
|
||||
//
|
||||
// engineLabel
|
||||
//
|
||||
engineLabel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
|
||||
@@ -1434,7 +1386,6 @@ namespace OpenNest.Forms
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuPlateViewInCad;
|
||||
private System.Windows.Forms.ToolStripButton btnNew;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuPlateAdd;
|
||||
private System.Windows.Forms.ToolStripButton btnZoomToFit;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuNestRemoveEmptyPlates;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuViewZoomIn;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuViewZoomOut;
|
||||
@@ -1444,8 +1395,6 @@ namespace OpenNest.Forms
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem15;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuPlateSetAsDefault;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem16;
|
||||
private System.Windows.Forms.ToolStripButton btnZoomOut;
|
||||
private System.Windows.Forms.ToolStripButton btnZoomIn;
|
||||
private System.Windows.Forms.ToolStripStatusLabel statusLabel1;
|
||||
private System.Windows.Forms.ToolStripStatusLabel spacerLabel;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem18;
|
||||
@@ -1469,7 +1418,6 @@ namespace OpenNest.Forms
|
||||
private System.Windows.Forms.ToolStripMenuItem centerPartsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripStatusLabel gpuStatusLabel;
|
||||
private System.Windows.Forms.ToolStripStatusLabel selectionStatusLabel;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
|
||||
private System.Windows.Forms.ToolStripLabel engineLabel;
|
||||
private System.Windows.Forms.ToolStripComboBox engineComboBox;
|
||||
private System.Windows.Forms.ToolStripButton btnAutoNest;
|
||||
|
||||
@@ -219,7 +219,6 @@ namespace OpenNest.Forms
|
||||
|
||||
var hasValue = activeForm != null;
|
||||
|
||||
btnZoomToFit.Enabled = hasValue;
|
||||
mnuFileSave.Enabled = hasValue && !databaseSaveInProgress;
|
||||
btnSave.Enabled = hasValue && !databaseSaveInProgress;
|
||||
btnSaveAs.Enabled = hasValue && !databaseSaveInProgress;
|
||||
@@ -228,8 +227,6 @@ namespace OpenNest.Forms
|
||||
mnuFileExport.Enabled = hasValue;
|
||||
mnuFileExportAll.Enabled = hasValue;
|
||||
mnuFileExportNestReport.Enabled = hasValue && !databaseSaveInProgress;
|
||||
btnZoomOut.Enabled = hasValue;
|
||||
btnZoomIn.Enabled = hasValue;
|
||||
mnuEdit.Visible = hasValue;
|
||||
mnuView.Visible = hasValue;
|
||||
mnuNest.Visible = hasValue;
|
||||
|
||||
@@ -115,6 +115,8 @@ Which engine suits which jobs, renamed engine names, and the rules for changing
|
||||
| G-code | No | Yes (post-processors) |
|
||||
| `.nest` | Yes | Yes |
|
||||
|
||||
Zoom Out, Zoom In, and Zoom to Fit are centered together with the plate navigation buttons in the plate-view header.
|
||||
|
||||
## Keyboard Shortcuts
|
||||
|
||||
`Ctrl+F` fill area · `F` zoom to fit · `Shift+wheel` / middle-click rotate · `X`/`Y` push · arrows nudge · `Shift+arrow` push.
|
||||
|
||||
Reference in new issue
Block a user