diff --git a/OpenNest/Forms/EditNestForm.cs b/OpenNest/Forms/EditNestForm.cs index a7c600e..da25af0 100644 --- a/OpenNest/Forms/EditNestForm.cs +++ b/OpenNest/Forms/EditNestForm.cs @@ -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() diff --git a/OpenNest/Forms/MainForm.Designer.cs b/OpenNest/Forms/MainForm.Designer.cs index 1bbef6c..8515027 100644 --- a/OpenNest/Forms/MainForm.Designer.cs +++ b/OpenNest/Forms/MainForm.Designer.cs @@ -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; diff --git a/OpenNest/Forms/MainForm.cs b/OpenNest/Forms/MainForm.cs index 961ea83..c9e4753 100644 --- a/OpenNest/Forms/MainForm.cs +++ b/OpenNest/Forms/MainForm.cs @@ -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; diff --git a/README.md b/README.md index 8c39da6..c2ce36e 100644 --- a/README.md +++ b/README.md @@ -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.