From 766584633eaccd416f51de6ed5ed953fdfcbf265 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Sat, 17 Oct 2026 22:58:35 -0400 Subject: [PATCH] refactor(ui): redesign Edit Drawing dialog Rebuild the dialog as a two-column layout: a larger preview with a color swatch, a Change Color button and read-only size, area and source-file details on the left; Drawing (name, customer) and Nesting (quantity, priority, cut first) groups on the right. Quantity shows how many parts are already nested and how many remain, priority explains that lower numbers nest first, and cut first gets a short description. The form now uses Segoe UI with font auto-scaling, re-renders the preview when its size changes, selects the name on open, and is titled "Drawing Properties - ". Co-Authored-By: Claude Opus 5.5 --- OpenNest/Forms/EditDrawingForm.Designer.cs | 731 ++++++++++++++------- OpenNest/Forms/EditDrawingForm.cs | 74 ++- 2 files changed, 561 insertions(+), 244 deletions(-) diff --git a/OpenNest/Forms/EditDrawingForm.Designer.cs b/OpenNest/Forms/EditDrawingForm.Designer.cs index c4ec3f0d..b58dc06d 100644 --- a/OpenNest/Forms/EditDrawingForm.Designer.cs +++ b/OpenNest/Forms/EditDrawingForm.Designer.cs @@ -1,4 +1,7 @@ -namespace OpenNest.Forms +using System.Drawing; +using System.Windows.Forms; + +namespace OpenNest.Forms { partial class EditDrawingForm { @@ -13,9 +16,10 @@ /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { - if (disposing && (components != null)) + if (disposing) { - components.Dispose(); + pictureBox1.Image?.Dispose(); + components?.Dispose(); } base.Dispose(disposing); } @@ -28,254 +32,507 @@ /// private void InitializeComponent() { - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.label1 = new System.Windows.Forms.Label(); - this.nameBox = new System.Windows.Forms.TextBox(); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.label2 = new System.Windows.Forms.Label(); - this.qtyBox = new OpenNest.Controls.NumericUpDown(); - this.label3 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.customerBox = new System.Windows.Forms.TextBox(); - this.priorityBox = new OpenNest.Controls.NumericUpDown(); - this.cutFirstBox = new System.Windows.Forms.CheckBox(); - this.applyButton = new System.Windows.Forms.Button(); - this.cancelButton = new System.Windows.Forms.Button(); - this.bottomPanel1 = new OpenNest.Controls.BottomPanel(); - this.colorDialog1 = new System.Windows.Forms.ColorDialog(); - this.linkLabel1 = new System.Windows.Forms.LinkLabel(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.tableLayoutPanel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.qtyBox)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.priorityBox)).BeginInit(); - this.bottomPanel1.SuspendLayout(); - this.SuspendLayout(); - // + components = new System.ComponentModel.Container(); + layout = new TableLayoutPanel(); + previewPanel = new TableLayoutPanel(); + pictureBox1 = new PictureBox(); + colorPanel = new TableLayoutPanel(); + colorSwatch = new Panel(); + colorButton = new Button(); + infoPanel = new TableLayoutPanel(); + sizeCaption = new Label(); + sizeLabel = new Label(); + areaCaption = new Label(); + areaLabel = new Label(); + sourceCaption = new Label(); + sourceLabel = new Label(); + fieldsPanel = new TableLayoutPanel(); + drawingGroup = new GroupBox(); + drawingFields = new TableLayoutPanel(); + label1 = new Label(); + nameBox = new TextBox(); + label3 = new Label(); + customerBox = new TextBox(); + nestingGroup = new GroupBox(); + nestingFields = new TableLayoutPanel(); + label2 = new Label(); + qtyBox = new OpenNest.Controls.NumericUpDown(); + nestedLabel = new Label(); + label4 = new Label(); + priorityBox = new OpenNest.Controls.NumericUpDown(); + priorityHint = new Label(); + cutFirstBox = new CheckBox(); + cutFirstHint = new Label(); + bottomPanel1 = new OpenNest.Controls.BottomPanel(); + buttonsPanel = new FlowLayoutPanel(); + cancelButton = new Button(); + applyButton = new Button(); + colorDialog1 = new ColorDialog(); + toolTip = new ToolTip(components); + layout.SuspendLayout(); + previewPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); + colorPanel.SuspendLayout(); + infoPanel.SuspendLayout(); + fieldsPanel.SuspendLayout(); + drawingGroup.SuspendLayout(); + drawingFields.SuspendLayout(); + nestingGroup.SuspendLayout(); + nestingFields.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)qtyBox).BeginInit(); + ((System.ComponentModel.ISupportInitialize)priorityBox).BeginInit(); + bottomPanel1.SuspendLayout(); + buttonsPanel.SuspendLayout(); + SuspendLayout(); + // + // layout + // + layout.ColumnCount = 2; + layout.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 264F)); + layout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + layout.Controls.Add(previewPanel, 0, 0); + layout.Controls.Add(fieldsPanel, 1, 0); + layout.Dock = DockStyle.Fill; + layout.Name = "layout"; + layout.Padding = new Padding(12, 12, 12, 6); + layout.RowCount = 1; + layout.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + layout.TabIndex = 0; + // + // previewPanel + // + previewPanel.ColumnCount = 1; + previewPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + previewPanel.Controls.Add(pictureBox1, 0, 0); + previewPanel.Controls.Add(colorPanel, 0, 1); + previewPanel.Controls.Add(infoPanel, 0, 2); + previewPanel.Dock = DockStyle.Fill; + previewPanel.Margin = new Padding(0, 0, 12, 0); + previewPanel.Name = "previewPanel"; + previewPanel.RowCount = 3; + previewPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 240F)); + previewPanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); + previewPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + previewPanel.TabIndex = 1; + // // pictureBox1 - // - this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.pictureBox1.BackColor = System.Drawing.Color.White; - this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.pictureBox1.Location = new System.Drawing.Point(412, 12); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(289, 257); - this.pictureBox1.TabIndex = 1; - this.pictureBox1.TabStop = false; - // + // + pictureBox1.BackColor = Color.White; + pictureBox1.BorderStyle = BorderStyle.FixedSingle; + pictureBox1.Dock = DockStyle.Fill; + pictureBox1.Margin = new Padding(0); + pictureBox1.Name = "pictureBox1"; + pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage; + pictureBox1.TabStop = false; + // + // colorPanel + // + colorPanel.AutoSize = true; + colorPanel.ColumnCount = 2; + colorPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); + colorPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + colorPanel.Controls.Add(colorSwatch, 0, 0); + colorPanel.Controls.Add(colorButton, 1, 0); + colorPanel.Dock = DockStyle.Fill; + colorPanel.Margin = new Padding(0, 8, 0, 8); + colorPanel.Name = "colorPanel"; + colorPanel.RowCount = 1; + colorPanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); + colorPanel.TabIndex = 0; + // + // colorSwatch + // + colorSwatch.Anchor = AnchorStyles.Left; + colorSwatch.BorderStyle = BorderStyle.FixedSingle; + colorSwatch.Cursor = Cursors.Hand; + colorSwatch.Margin = new Padding(0, 0, 8, 0); + colorSwatch.Name = "colorSwatch"; + colorSwatch.Size = new Size(26, 26); + colorSwatch.Click += ChangeColor_Click; + // + // colorButton + // + colorButton.Anchor = AnchorStyles.Left; + colorButton.AutoSize = true; + colorButton.Margin = new Padding(0); + colorButton.Name = "colorButton"; + colorButton.Size = new Size(110, 27); + colorButton.TabIndex = 0; + colorButton.Text = "C&hange Color..."; + colorButton.UseVisualStyleBackColor = true; + colorButton.Click += ChangeColor_Click; + // + // infoPanel + // + infoPanel.AutoSize = true; + infoPanel.ColumnCount = 2; + infoPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); + infoPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + infoPanel.Controls.Add(sizeCaption, 0, 0); + infoPanel.Controls.Add(sizeLabel, 1, 0); + infoPanel.Controls.Add(areaCaption, 0, 1); + infoPanel.Controls.Add(areaLabel, 1, 1); + infoPanel.Controls.Add(sourceCaption, 0, 2); + infoPanel.Controls.Add(sourceLabel, 1, 2); + infoPanel.Dock = DockStyle.Top; + infoPanel.Margin = new Padding(0); + infoPanel.Name = "infoPanel"; + infoPanel.RowCount = 3; + infoPanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); + infoPanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); + infoPanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); + // + // sizeCaption + // + sizeCaption.AutoSize = true; + sizeCaption.ForeColor = SystemColors.GrayText; + sizeCaption.Margin = new Padding(0, 2, 8, 2); + sizeCaption.Name = "sizeCaption"; + sizeCaption.Text = "Size"; + // + // sizeLabel + // + sizeLabel.AutoEllipsis = true; + sizeLabel.Dock = DockStyle.Fill; + sizeLabel.Margin = new Padding(0, 2, 0, 2); + sizeLabel.Name = "sizeLabel"; + sizeLabel.Size = new Size(200, 17); + sizeLabel.Text = "-"; + // + // areaCaption + // + areaCaption.AutoSize = true; + areaCaption.ForeColor = SystemColors.GrayText; + areaCaption.Margin = new Padding(0, 2, 8, 2); + areaCaption.Name = "areaCaption"; + areaCaption.Text = "Area"; + // + // areaLabel + // + areaLabel.AutoEllipsis = true; + areaLabel.Dock = DockStyle.Fill; + areaLabel.Margin = new Padding(0, 2, 0, 2); + areaLabel.Name = "areaLabel"; + areaLabel.Size = new Size(200, 17); + areaLabel.Text = "-"; + // + // sourceCaption + // + sourceCaption.AutoSize = true; + sourceCaption.ForeColor = SystemColors.GrayText; + sourceCaption.Margin = new Padding(0, 2, 8, 2); + sourceCaption.Name = "sourceCaption"; + sourceCaption.Text = "Source"; + // + // sourceLabel + // + sourceLabel.AutoEllipsis = true; + sourceLabel.Dock = DockStyle.Fill; + sourceLabel.Margin = new Padding(0, 2, 0, 2); + sourceLabel.Name = "sourceLabel"; + sourceLabel.Size = new Size(200, 17); + sourceLabel.Text = "-"; + // + // fieldsPanel + // + fieldsPanel.ColumnCount = 1; + fieldsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + fieldsPanel.Controls.Add(drawingGroup, 0, 0); + fieldsPanel.Controls.Add(nestingGroup, 0, 1); + fieldsPanel.Dock = DockStyle.Fill; + fieldsPanel.Margin = new Padding(0); + fieldsPanel.Name = "fieldsPanel"; + fieldsPanel.RowCount = 3; + fieldsPanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); + fieldsPanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); + fieldsPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + fieldsPanel.TabIndex = 0; + // + // drawingGroup + // + drawingGroup.AutoSize = true; + drawingGroup.Controls.Add(drawingFields); + drawingGroup.Dock = DockStyle.Fill; + drawingGroup.Margin = new Padding(0, 0, 0, 10); + drawingGroup.Name = "drawingGroup"; + drawingGroup.Padding = new Padding(10, 6, 10, 8); + drawingGroup.TabIndex = 0; + drawingGroup.TabStop = false; + drawingGroup.Text = "Drawing"; + // + // drawingFields + // + drawingFields.AutoSize = true; + drawingFields.ColumnCount = 2; + drawingFields.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 80F)); + drawingFields.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + drawingFields.Controls.Add(label1, 0, 0); + drawingFields.Controls.Add(nameBox, 1, 0); + drawingFields.Controls.Add(label3, 0, 1); + drawingFields.Controls.Add(customerBox, 1, 1); + drawingFields.Dock = DockStyle.Fill; + drawingFields.Name = "drawingFields"; + drawingFields.RowCount = 2; + drawingFields.RowStyles.Add(new RowStyle(SizeType.AutoSize)); + drawingFields.RowStyles.Add(new RowStyle(SizeType.AutoSize)); + drawingFields.TabIndex = 0; + // // label1 - // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(3, 12); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(71, 16); - this.label1.TabIndex = 2; - this.label1.Text = "Name :"; - // + // + label1.Anchor = AnchorStyles.Left; + label1.AutoSize = true; + label1.Name = "label1"; + label1.Text = "&Name"; + // // nameBox - // - this.nameBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.nameBox.Location = new System.Drawing.Point(80, 9); - this.nameBox.Name = "nameBox"; - this.nameBox.Size = new System.Drawing.Size(311, 22); - this.nameBox.TabIndex = 3; - // - // tableLayoutPanel1 - // - this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tableLayoutPanel1.ColumnCount = 2; - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.Controls.Add(this.nameBox, 1, 0); - this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.label2, 0, 1); - this.tableLayoutPanel1.Controls.Add(this.qtyBox, 1, 1); - this.tableLayoutPanel1.Controls.Add(this.label3, 0, 2); - this.tableLayoutPanel1.Controls.Add(this.label4, 0, 3); - this.tableLayoutPanel1.Controls.Add(this.customerBox, 1, 2); - this.tableLayoutPanel1.Controls.Add(this.priorityBox, 1, 3); - this.tableLayoutPanel1.Controls.Add(this.cutFirstBox, 1, 4); - this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 12); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 5; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(394, 200); - this.tableLayoutPanel1.TabIndex = 4; - // - // label2 - // - this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(3, 52); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(71, 16); - this.label2.TabIndex = 2; - this.label2.Text = "Quantity :"; - // - // qtyBox - // - this.qtyBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.qtyBox.Location = new System.Drawing.Point(80, 49); - this.qtyBox.Maximum = new decimal(new int[] { - 999999, - 0, - 0, - 0}); - this.qtyBox.Name = "qtyBox"; - this.qtyBox.Size = new System.Drawing.Size(311, 22); - this.qtyBox.Suffix = ""; - this.qtyBox.TabIndex = 4; - // + // + nameBox.Dock = DockStyle.Fill; + nameBox.Margin = new Padding(3, 4, 3, 4); + nameBox.Name = "nameBox"; + nameBox.TabIndex = 0; + // // label3 - // - this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(3, 92); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(71, 16); - this.label3.TabIndex = 2; - this.label3.Text = "Customer :"; - // - // label4 - // - this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(3, 132); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(71, 16); - this.label4.TabIndex = 2; - this.label4.Text = "Priority :"; - // + // + label3.Anchor = AnchorStyles.Left; + label3.AutoSize = true; + label3.Name = "label3"; + label3.Text = "C&ustomer"; + // // customerBox - // - this.customerBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.customerBox.Location = new System.Drawing.Point(80, 89); - this.customerBox.Name = "customerBox"; - this.customerBox.Size = new System.Drawing.Size(311, 22); - this.customerBox.TabIndex = 3; - // + // + customerBox.Dock = DockStyle.Fill; + customerBox.Margin = new Padding(3, 4, 3, 4); + customerBox.Name = "customerBox"; + customerBox.TabIndex = 1; + // + // nestingGroup + // + nestingGroup.AutoSize = true; + nestingGroup.Controls.Add(nestingFields); + nestingGroup.Dock = DockStyle.Fill; + nestingGroup.Margin = new Padding(0); + nestingGroup.Name = "nestingGroup"; + nestingGroup.Padding = new Padding(10, 6, 10, 8); + nestingGroup.TabIndex = 1; + nestingGroup.TabStop = false; + nestingGroup.Text = "Nesting"; + // + // nestingFields + // + nestingFields.AutoSize = true; + nestingFields.ColumnCount = 3; + nestingFields.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 80F)); + nestingFields.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 96F)); + nestingFields.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + nestingFields.Controls.Add(label2, 0, 0); + nestingFields.Controls.Add(qtyBox, 1, 0); + nestingFields.Controls.Add(nestedLabel, 2, 0); + nestingFields.Controls.Add(label4, 0, 1); + nestingFields.Controls.Add(priorityBox, 1, 1); + nestingFields.Controls.Add(priorityHint, 2, 1); + nestingFields.Controls.Add(cutFirstBox, 1, 2); + nestingFields.Controls.Add(cutFirstHint, 1, 3); + nestingFields.SetColumnSpan(cutFirstBox, 2); + nestingFields.SetColumnSpan(cutFirstHint, 2); + nestingFields.Dock = DockStyle.Fill; + nestingFields.Name = "nestingFields"; + nestingFields.RowCount = 4; + nestingFields.RowStyles.Add(new RowStyle(SizeType.AutoSize)); + nestingFields.RowStyles.Add(new RowStyle(SizeType.AutoSize)); + nestingFields.RowStyles.Add(new RowStyle(SizeType.AutoSize)); + nestingFields.RowStyles.Add(new RowStyle(SizeType.AutoSize)); + nestingFields.TabIndex = 0; + // + // label2 + // + label2.Anchor = AnchorStyles.Left; + label2.AutoSize = true; + label2.Name = "label2"; + label2.Text = "&Quantity"; + // + // qtyBox + // + qtyBox.Dock = DockStyle.Fill; + qtyBox.Margin = new Padding(3, 4, 3, 4); + qtyBox.Maximum = new decimal(new int[] { 999999, 0, 0, 0 }); + qtyBox.Name = "qtyBox"; + qtyBox.Suffix = ""; + qtyBox.TabIndex = 0; + qtyBox.ValueChanged += QtyBox_ValueChanged; + // + // nestedLabel + // + nestedLabel.Anchor = AnchorStyles.Left; + nestedLabel.AutoSize = true; + nestedLabel.ForeColor = SystemColors.GrayText; + nestedLabel.Name = "nestedLabel"; + // + // label4 + // + label4.Anchor = AnchorStyles.Left; + label4.AutoSize = true; + label4.Name = "label4"; + label4.Text = "&Priority"; + // // priorityBox - // - this.priorityBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.priorityBox.Location = new System.Drawing.Point(80, 129); - this.priorityBox.Maximum = new decimal(new int[] { - 999999, - 0, - 0, - 0}); - this.priorityBox.Name = "priorityBox"; - this.priorityBox.Size = new System.Drawing.Size(311, 22); - this.priorityBox.Suffix = ""; - this.priorityBox.TabIndex = 4; - // + // + priorityBox.Dock = DockStyle.Fill; + priorityBox.Margin = new Padding(3, 4, 3, 4); + priorityBox.Maximum = new decimal(new int[] { 999999, 0, 0, 0 }); + priorityBox.Name = "priorityBox"; + priorityBox.Suffix = ""; + priorityBox.TabIndex = 1; + // + // priorityHint + // + priorityHint.Anchor = AnchorStyles.Left; + priorityHint.AutoSize = true; + priorityHint.ForeColor = SystemColors.GrayText; + priorityHint.Name = "priorityHint"; + priorityHint.Text = "Lower numbers nest first"; + // // cutFirstBox - // - this.cutFirstBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.cutFirstBox.AutoSize = true; - this.cutFirstBox.Name = "cutFirstBox"; - this.cutFirstBox.TabIndex = 5; - this.cutFirstBox.Text = "Cut first (sequence before other parts)"; - this.cutFirstBox.UseVisualStyleBackColor = true; - // - // applyButton - // - this.applyButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.applyButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.applyButton.Location = new System.Drawing.Point(515, 10); - this.applyButton.Name = "applyButton"; - this.applyButton.Size = new System.Drawing.Size(90, 28); - this.applyButton.TabIndex = 5; - this.applyButton.Text = "Done"; - this.applyButton.UseVisualStyleBackColor = true; - // - // cancelButton - // - this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(611, 10); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(90, 28); - this.cancelButton.TabIndex = 6; - this.cancelButton.Text = "Cancel"; - this.cancelButton.UseVisualStyleBackColor = true; - // + // + cutFirstBox.AutoSize = true; + cutFirstBox.Margin = new Padding(3, 10, 3, 0); + cutFirstBox.Name = "cutFirstBox"; + cutFirstBox.TabIndex = 2; + cutFirstBox.Text = "Cut &first"; + cutFirstBox.UseVisualStyleBackColor = true; + // + // cutFirstHint + // + cutFirstHint.AutoSize = true; + cutFirstHint.ForeColor = SystemColors.GrayText; + cutFirstHint.Margin = new Padding(20, 0, 3, 4); + cutFirstHint.Name = "cutFirstHint"; + cutFirstHint.Text = "Cut before other parts on the plate"; + // // bottomPanel1 - // - this.bottomPanel1.Controls.Add(this.applyButton); - this.bottomPanel1.Controls.Add(this.cancelButton); - this.bottomPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; - this.bottomPanel1.Location = new System.Drawing.Point(0, 298); - this.bottomPanel1.Name = "bottomPanel1"; - this.bottomPanel1.Size = new System.Drawing.Size(713, 50); - this.bottomPanel1.TabIndex = 0; - // + // + bottomPanel1.Controls.Add(buttonsPanel); + bottomPanel1.Dock = DockStyle.Bottom; + bottomPanel1.Name = "bottomPanel1"; + bottomPanel1.Padding = new Padding(12, 10, 12, 10); + bottomPanel1.Size = new Size(640, 50); + bottomPanel1.TabIndex = 1; + // + // buttonsPanel + // + buttonsPanel.Controls.Add(cancelButton); + buttonsPanel.Controls.Add(applyButton); + buttonsPanel.Dock = DockStyle.Fill; + buttonsPanel.FlowDirection = FlowDirection.RightToLeft; + buttonsPanel.Margin = new Padding(0); + buttonsPanel.Name = "buttonsPanel"; + buttonsPanel.TabIndex = 0; + buttonsPanel.WrapContents = false; + // + // cancelButton + // + cancelButton.DialogResult = DialogResult.Cancel; + cancelButton.Margin = new Padding(6, 0, 0, 0); + cancelButton.Name = "cancelButton"; + cancelButton.Size = new Size(85, 28); + cancelButton.TabIndex = 1; + cancelButton.Text = "Cancel"; + cancelButton.UseVisualStyleBackColor = true; + // + // applyButton + // + applyButton.DialogResult = DialogResult.OK; + applyButton.Margin = new Padding(0); + applyButton.Name = "applyButton"; + applyButton.Size = new Size(85, 28); + applyButton.TabIndex = 0; + applyButton.Text = "OK"; + applyButton.UseVisualStyleBackColor = true; + // // colorDialog1 - // - this.colorDialog1.AnyColor = true; - // - // linkLabel1 - // - this.linkLabel1.AutoSize = true; - this.linkLabel1.Location = new System.Drawing.Point(409, 272); - this.linkLabel1.Name = "linkLabel1"; - this.linkLabel1.Size = new System.Drawing.Size(90, 16); - this.linkLabel1.TabIndex = 5; - this.linkLabel1.TabStop = true; - this.linkLabel1.Text = "Change Color"; - this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); - // + // + colorDialog1.AnyColor = true; + colorDialog1.FullOpen = true; + // // EditDrawingForm - // - this.AcceptButton = this.applyButton; - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; - this.CancelButton = this.cancelButton; - this.ClientSize = new System.Drawing.Size(713, 348); - this.Controls.Add(this.linkLabel1); - this.Controls.Add(this.tableLayoutPanel1); - this.Controls.Add(this.pictureBox1); - this.Controls.Add(this.bottomPanel1); - this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "EditDrawingForm"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Edit Drawing"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - this.tableLayoutPanel1.ResumeLayout(false); - this.tableLayoutPanel1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.qtyBox)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.priorityBox)).EndInit(); - this.bottomPanel1.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - + // + AcceptButton = applyButton; + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + CancelButton = cancelButton; + ClientSize = new Size(640, 430); + Controls.Add(layout); + Controls.Add(bottomPanel1); + Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); + FormBorderStyle = FormBorderStyle.FixedDialog; + MaximizeBox = false; + MinimizeBox = false; + Name = "EditDrawingForm"; + ShowIcon = false; + ShowInTaskbar = false; + StartPosition = FormStartPosition.CenterParent; + Text = "Drawing Properties"; + layout.ResumeLayout(false); + previewPanel.ResumeLayout(false); + previewPanel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); + colorPanel.ResumeLayout(false); + colorPanel.PerformLayout(); + infoPanel.ResumeLayout(false); + infoPanel.PerformLayout(); + fieldsPanel.ResumeLayout(false); + fieldsPanel.PerformLayout(); + drawingGroup.ResumeLayout(false); + drawingGroup.PerformLayout(); + drawingFields.ResumeLayout(false); + drawingFields.PerformLayout(); + nestingGroup.ResumeLayout(false); + nestingGroup.PerformLayout(); + nestingFields.ResumeLayout(false); + nestingFields.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)qtyBox).EndInit(); + ((System.ComponentModel.ISupportInitialize)priorityBox).EndInit(); + bottomPanel1.ResumeLayout(false); + buttonsPanel.ResumeLayout(false); + ResumeLayout(false); } #endregion - private Controls.BottomPanel bottomPanel1; - private System.Windows.Forms.PictureBox pictureBox1; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox nameBox; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private System.Windows.Forms.Label label2; + private TableLayoutPanel layout; + private TableLayoutPanel previewPanel; + private PictureBox pictureBox1; + private TableLayoutPanel colorPanel; + private Panel colorSwatch; + private Button colorButton; + private TableLayoutPanel infoPanel; + private Label sizeCaption; + private Label sizeLabel; + private Label areaCaption; + private Label areaLabel; + private Label sourceCaption; + private Label sourceLabel; + private TableLayoutPanel fieldsPanel; + private GroupBox drawingGroup; + private TableLayoutPanel drawingFields; + private Label label1; + private TextBox nameBox; + private Label label3; + private TextBox customerBox; + private GroupBox nestingGroup; + private TableLayoutPanel nestingFields; + private Label label2; private Controls.NumericUpDown qtyBox; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.TextBox customerBox; + private Label nestedLabel; + private Label label4; private Controls.NumericUpDown priorityBox; - private System.Windows.Forms.CheckBox cutFirstBox; - private System.Windows.Forms.Button applyButton; - private System.Windows.Forms.Button cancelButton; - private System.Windows.Forms.ColorDialog colorDialog1; - private System.Windows.Forms.LinkLabel linkLabel1; + private Label priorityHint; + private CheckBox cutFirstBox; + private Label cutFirstHint; + private Controls.BottomPanel bottomPanel1; + private FlowLayoutPanel buttonsPanel; + private Button cancelButton; + private Button applyButton; + private ColorDialog colorDialog1; + private ToolTip toolTip; } -} \ No newline at end of file +} diff --git a/OpenNest/Forms/EditDrawingForm.cs b/OpenNest/Forms/EditDrawingForm.cs index 10bcdc9e..835157e8 100644 --- a/OpenNest/Forms/EditDrawingForm.cs +++ b/OpenNest/Forms/EditDrawingForm.cs @@ -1,3 +1,4 @@ +using System; using System.Drawing; using System.Windows.Forms; @@ -5,11 +6,14 @@ namespace OpenNest.Forms { public partial class EditDrawingForm : Form { + private const int PreviewInset = 24; + private Drawing drawing; public EditDrawingForm() { InitializeComponent(); + pictureBox1.SizeChanged += (_, _) => UpdateImage(); } private string DrawingName @@ -50,15 +54,59 @@ namespace OpenNest.Forms private void UpdateImage() { + if (drawing == null) + return; + + var size = pictureBox1.ClientSize; + if (size.Width <= PreviewInset || size.Height <= PreviewInset) + return; + var brush = new SolidBrush(colorDialog1.Color); var pen = new Pen(ColorScheme.Default.GetPartOutlineColor(colorDialog1.Color)); - DrawingImage?.Dispose(); - DrawingImage = drawing.Program.GetImage(pictureBox1.Size, pen, brush); + var previous = DrawingImage; + DrawingImage = drawing.Program.GetImage( + new Size(size.Width - PreviewInset, size.Height - PreviewInset), pen, brush); + previous?.Dispose(); pen.Dispose(); brush.Dispose(); } + private void UpdateColor() + { + colorSwatch.BackColor = colorDialog1.Color; + UpdateImage(); + } + + private void UpdateNestedLabel() + { + if (drawing == null) + return; + + var nested = drawing.Quantity.Nested; + var remaining = System.Math.Max(Quantity - nested, 0); + nestedLabel.Text = $"{nested} nested, {remaining} remaining"; + } + + private void LoadDetails() + { + var box = drawing.Program.BoundingBox(); + sizeLabel.Text = $"{box.Length:0.###} x {box.Width:0.###}"; + areaLabel.Text = $"{drawing.Area:0.###}"; + + var path = drawing.Source?.Path; + if (string.IsNullOrEmpty(path)) + { + sourceLabel.Text = "-"; + toolTip.SetToolTip(sourceLabel, null); + } + else + { + sourceLabel.Text = System.IO.Path.GetFileName(path); + toolTip.SetToolTip(sourceLabel, path); + } + } + public void LoadDrawing(Drawing drawing) { this.drawing = drawing; @@ -69,7 +117,12 @@ namespace OpenNest.Forms Quantity = drawing.Quantity.Required; Priority = drawing.Priority; CutFirst = drawing.CutFirst; - UpdateImage(); + Text = string.IsNullOrEmpty(drawing.Name) + ? "Drawing Properties" + : $"Drawing Properties - {drawing.Name}"; + LoadDetails(); + UpdateNestedLabel(); + UpdateColor(); } public void SaveDrawing(Drawing drawing) @@ -82,12 +135,19 @@ namespace OpenNest.Forms drawing.Color = colorDialog1.Color; } - private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + protected override void OnShown(EventArgs e) { - var result = colorDialog1.ShowDialog(); + base.OnShown(e); + nameBox.SelectAll(); + nameBox.Focus(); + } - if (result == System.Windows.Forms.DialogResult.OK) - UpdateImage(); + private void QtyBox_ValueChanged(object sender, EventArgs e) => UpdateNestedLabel(); + + private void ChangeColor_Click(object sender, EventArgs e) + { + if (colorDialog1.ShowDialog(this) == DialogResult.OK) + UpdateColor(); } } }