From b65dd1ec7d312754a753ea594dc32f763de6e82c Mon Sep 17 00:00:00 2001 From: AJ Date: Wed, 9 Feb 2022 11:22:56 -0500 Subject: [PATCH] Used lower value priority bins first. --- CutList/Forms/MainForm.Designer.cs | 204 ++++++++++++++--------------- CutList/Models/BinInputItem.cs | 2 +- SawCut/MultiBin.cs | 5 +- SawCut/Nesting/MultiBinEngine.cs | 2 +- 4 files changed, 108 insertions(+), 105 deletions(-) diff --git a/CutList/Forms/MainForm.Designer.cs b/CutList/Forms/MainForm.Designer.cs index efcb291..b51da0b 100644 --- a/CutList/Forms/MainForm.Designer.cs +++ b/CutList/Forms/MainForm.Designer.cs @@ -29,14 +29,22 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.lengthDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.quantityDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.TotalLength = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.itemBindingSource = new System.Windows.Forms.BindingSource(this.components); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); + this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); + this.saveButton = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.runButton = new System.Windows.Forms.ToolStripButton(); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.textBox1 = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); @@ -45,26 +53,18 @@ this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.dataGridView2 = new System.Windows.Forms.DataGridView(); - this.TotalLengthString = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.lengthDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.quantityDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.itemBindingSource = new System.Windows.Forms.BindingSource(this.components); this.lengthInputValueDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.quantityDataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.TotalLengthString = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.priorityDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.binInputItemBindingSource = new System.Windows.Forms.BindingSource(this.components); - this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); - this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); - this.saveButton = new System.Windows.Forms.ToolStripButton(); - this.runButton = new System.Windows.Forms.ToolStripButton(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.itemBindingSource)).BeginInit(); this.toolStrip1.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tabPage2.SuspendLayout(); this.tabPage1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.itemBindingSource)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.binInputItemBindingSource)).BeginInit(); this.SuspendLayout(); // @@ -97,6 +97,31 @@ this.dataGridView1.CellValidated += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellEndEdit); this.dataGridView1.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.dataGridView1_DataError); // + // nameDataGridViewTextBoxColumn + // + this.nameDataGridViewTextBoxColumn.DataPropertyName = "Name"; + this.nameDataGridViewTextBoxColumn.HeaderText = "Name"; + this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn"; + this.nameDataGridViewTextBoxColumn.Width = 200; + // + // lengthDataGridViewTextBoxColumn + // + this.lengthDataGridViewTextBoxColumn.DataPropertyName = "LengthInputValue"; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; + this.lengthDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle1; + this.lengthDataGridViewTextBoxColumn.HeaderText = "Length"; + this.lengthDataGridViewTextBoxColumn.Name = "lengthDataGridViewTextBoxColumn"; + this.lengthDataGridViewTextBoxColumn.Width = 120; + // + // quantityDataGridViewTextBoxColumn + // + this.quantityDataGridViewTextBoxColumn.DataPropertyName = "Quantity"; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; + this.quantityDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle2; + this.quantityDataGridViewTextBoxColumn.HeaderText = "Qty"; + this.quantityDataGridViewTextBoxColumn.Name = "quantityDataGridViewTextBoxColumn"; + this.quantityDataGridViewTextBoxColumn.Width = 50; + // // TotalLength // this.TotalLength.DataPropertyName = "TotalLengthString"; @@ -109,6 +134,10 @@ this.TotalLength.ReadOnly = true; this.TotalLength.Width = 150; // + // itemBindingSource + // + this.itemBindingSource.DataSource = typeof(CutList.Models.PartInputItem); + // // toolStrip1 // this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -123,11 +152,59 @@ this.toolStrip1.TabIndex = 0; this.toolStrip1.Text = "toolStrip1"; // + // toolStripButton2 + // + this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButton2.Image = global::CutList.Properties.Resources.gnome_document_new; + this.toolStripButton2.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton2.Name = "toolStripButton2"; + this.toolStripButton2.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0); + this.toolStripButton2.Size = new System.Drawing.Size(46, 36); + this.toolStripButton2.Text = "Open"; + this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton2_Click); + // + // toolStripButton1 + // + this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButton1.Image = global::CutList.Properties.Resources.Open_Folder_32; + this.toolStripButton1.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton1.Name = "toolStripButton1"; + this.toolStripButton1.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0); + this.toolStripButton1.Size = new System.Drawing.Size(46, 36); + this.toolStripButton1.Text = "Open"; + this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click); + // + // saveButton + // + this.saveButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.saveButton.Image = global::CutList.Properties.Resources.Save_32; + this.saveButton.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.saveButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.saveButton.Name = "saveButton"; + this.saveButton.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0); + this.saveButton.Size = new System.Drawing.Size(46, 36); + this.saveButton.Text = "Save"; + this.saveButton.Click += new System.EventHandler(this.saveButton_Click); + // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Size = new System.Drawing.Size(6, 39); // + // runButton + // + this.runButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.runButton.Image = global::CutList.Properties.Resources.Circled_Play_32; + this.runButton.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.runButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.runButton.Name = "runButton"; + this.runButton.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0); + this.runButton.Size = new System.Drawing.Size(46, 36); + this.runButton.Text = "Run"; + this.runButton.Click += new System.EventHandler(this.runButton_Click); + // // comboBox1 // this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -200,10 +277,10 @@ this.tabPage1.Controls.Add(this.comboBox1); this.tabPage1.Controls.Add(this.label4); this.tabPage1.Controls.Add(this.label3); - this.tabPage1.Location = new System.Drawing.Point(4, 22); + this.tabPage1.Location = new System.Drawing.Point(4, 26); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(848, 469); + this.tabPage1.Size = new System.Drawing.Size(848, 465); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "STOCK LENGTHS"; this.tabPage1.UseVisualStyleBackColor = true; @@ -231,49 +308,11 @@ this.dataGridView2.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; this.dataGridView2.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; this.dataGridView2.RowTemplate.Height = 26; - this.dataGridView2.Size = new System.Drawing.Size(836, 339); + this.dataGridView2.Size = new System.Drawing.Size(836, 335); this.dataGridView2.TabIndex = 12; this.dataGridView2.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView2_CellContentClick); this.dataGridView2.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView2_CellEndEdit); // - // TotalLengthString - // - this.TotalLengthString.DataPropertyName = "TotalLengthString"; - dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Info; - this.TotalLengthString.DefaultCellStyle = dataGridViewCellStyle4; - this.TotalLengthString.HeaderText = "Total Length"; - this.TotalLengthString.Name = "TotalLengthString"; - this.TotalLengthString.ReadOnly = true; - // - // nameDataGridViewTextBoxColumn - // - this.nameDataGridViewTextBoxColumn.DataPropertyName = "Name"; - this.nameDataGridViewTextBoxColumn.HeaderText = "Name"; - this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn"; - this.nameDataGridViewTextBoxColumn.Width = 200; - // - // lengthDataGridViewTextBoxColumn - // - this.lengthDataGridViewTextBoxColumn.DataPropertyName = "LengthInputValue"; - dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; - this.lengthDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle1; - this.lengthDataGridViewTextBoxColumn.HeaderText = "Length"; - this.lengthDataGridViewTextBoxColumn.Name = "lengthDataGridViewTextBoxColumn"; - this.lengthDataGridViewTextBoxColumn.Width = 120; - // - // quantityDataGridViewTextBoxColumn - // - this.quantityDataGridViewTextBoxColumn.DataPropertyName = "Quantity"; - dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; - this.quantityDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle2; - this.quantityDataGridViewTextBoxColumn.HeaderText = "Qty"; - this.quantityDataGridViewTextBoxColumn.Name = "quantityDataGridViewTextBoxColumn"; - this.quantityDataGridViewTextBoxColumn.Width = 50; - // - // itemBindingSource - // - this.itemBindingSource.DataSource = typeof(CutList.Models.PartInputItem); - // // lengthInputValueDataGridViewTextBoxColumn // this.lengthInputValueDataGridViewTextBoxColumn.DataPropertyName = "LengthInputValue"; @@ -286,6 +325,15 @@ this.quantityDataGridViewTextBoxColumn1.HeaderText = "Quantity"; this.quantityDataGridViewTextBoxColumn1.Name = "quantityDataGridViewTextBoxColumn1"; // + // TotalLengthString + // + this.TotalLengthString.DataPropertyName = "TotalLengthString"; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Info; + this.TotalLengthString.DefaultCellStyle = dataGridViewCellStyle4; + this.TotalLengthString.HeaderText = "Total Length"; + this.TotalLengthString.Name = "TotalLengthString"; + this.TotalLengthString.ReadOnly = true; + // // priorityDataGridViewTextBoxColumn // this.priorityDataGridViewTextBoxColumn.DataPropertyName = "Priority"; @@ -296,54 +344,6 @@ // this.binInputItemBindingSource.DataSource = typeof(CutList.Models.BinInputItem); // - // toolStripButton2 - // - this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButton2.Image = global::CutList.Properties.Resources.gnome_document_new; - this.toolStripButton2.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButton2.Name = "toolStripButton2"; - this.toolStripButton2.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0); - this.toolStripButton2.Size = new System.Drawing.Size(46, 36); - this.toolStripButton2.Text = "Open"; - this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton2_Click); - // - // toolStripButton1 - // - this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButton1.Image = global::CutList.Properties.Resources.Open_Folder_32; - this.toolStripButton1.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButton1.Name = "toolStripButton1"; - this.toolStripButton1.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0); - this.toolStripButton1.Size = new System.Drawing.Size(46, 36); - this.toolStripButton1.Text = "Open"; - this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click); - // - // saveButton - // - this.saveButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.saveButton.Image = global::CutList.Properties.Resources.Save_32; - this.saveButton.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.saveButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.saveButton.Name = "saveButton"; - this.saveButton.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0); - this.saveButton.Size = new System.Drawing.Size(46, 36); - this.saveButton.Text = "Save"; - this.saveButton.Click += new System.EventHandler(this.saveButton_Click); - // - // runButton - // - this.runButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.runButton.Image = global::CutList.Properties.Resources.Circled_Play_32; - this.runButton.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.runButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.runButton.Name = "runButton"; - this.runButton.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0); - this.runButton.Size = new System.Drawing.Size(46, 36); - this.runButton.Text = "Run"; - this.runButton.Click += new System.EventHandler(this.runButton_Click); - // // MainForm // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; @@ -357,6 +357,7 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Cut List"; ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.itemBindingSource)).EndInit(); this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); this.tabControl1.ResumeLayout(false); @@ -364,7 +365,6 @@ this.tabPage1.ResumeLayout(false); this.tabPage1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.itemBindingSource)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.binInputItemBindingSource)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/CutList/Models/BinInputItem.cs b/CutList/Models/BinInputItem.cs index 62a64ed..7939885 100644 --- a/CutList/Models/BinInputItem.cs +++ b/CutList/Models/BinInputItem.cs @@ -10,6 +10,6 @@ namespace CutList.Models { } - public int Priority { get; set; } = 10; + public int Priority { get; set; } = 25; } } \ No newline at end of file diff --git a/SawCut/MultiBin.cs b/SawCut/MultiBin.cs index 5098990..7a6040d 100644 --- a/SawCut/MultiBin.cs +++ b/SawCut/MultiBin.cs @@ -6,6 +6,9 @@ public double Length { get; set; } - public int Priority { get; set; } + /// + /// Lower value priority with be used first. Default to 25 + /// + public int Priority { get; set; } = 25; } } \ No newline at end of file diff --git a/SawCut/Nesting/MultiBinEngine.cs b/SawCut/Nesting/MultiBinEngine.cs index 3b935cc..470f72b 100644 --- a/SawCut/Nesting/MultiBinEngine.cs +++ b/SawCut/Nesting/MultiBinEngine.cs @@ -13,7 +13,7 @@ namespace SawCut.Nesting { var bins = Bins .Where(b => b.Length > 0) - .OrderByDescending(b => b.Priority) + .OrderBy(b => b.Priority) .ThenBy(b => b.Length) .ToList();