From 09fa8513675f535799605f804d9750dec86ca924 Mon Sep 17 00:00:00 2001 From: aj Date: Thu, 31 May 2018 22:50:09 -0400 Subject: [PATCH] Removed automatic naming for items --- CutToLength/Bin.cs | 1 + CutToLength/Form1.Designer.cs | 14 +++++++------- CutToLength/UIItem.cs | 21 +++++---------------- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/CutToLength/Bin.cs b/CutToLength/Bin.cs index ba8b0b1..382e971 100644 --- a/CutToLength/Bin.cs +++ b/CutToLength/Bin.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; namespace CutToLength { diff --git a/CutToLength/Form1.Designer.cs b/CutToLength/Form1.Designer.cs index ede0fe5..97324f7 100644 --- a/CutToLength/Form1.Designer.cs +++ b/CutToLength/Form1.Designer.cs @@ -33,7 +33,6 @@ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); - this.itemBindingSource = new System.Windows.Forms.BindingSource(this.components); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); @@ -44,15 +43,16 @@ this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripButton3 = new System.Windows.Forms.ToolStripButton(); + this.itemBindingSource = new System.Windows.Forms.BindingSource(this.components); this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.lengthDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.quantityDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.totalLengthDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.itemBindingSource)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit(); this.toolStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.itemBindingSource)).BeginInit(); this.SuspendLayout(); // // dataGridView1 @@ -82,10 +82,6 @@ this.dataGridView1.Size = new System.Drawing.Size(763, 361); this.dataGridView1.TabIndex = 5; // - // itemBindingSource - // - this.itemBindingSource.DataSource = typeof(CutToLength.UIItem); - // // label1 // this.label1.AutoSize = true; @@ -208,6 +204,10 @@ this.toolStripButton3.Text = "Run"; this.toolStripButton3.Click += new System.EventHandler(this.toolStripButton3_Click); // + // itemBindingSource + // + this.itemBindingSource.DataSource = typeof(CutToLength.UIItem); + // // nameDataGridViewTextBoxColumn // this.nameDataGridViewTextBoxColumn.DataPropertyName = "Name"; @@ -263,11 +263,11 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Cut To Length"; ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.itemBindingSource)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit(); this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.itemBindingSource)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/CutToLength/UIItem.cs b/CutToLength/UIItem.cs index 1c3e038..ad4e5cb 100644 --- a/CutToLength/UIItem.cs +++ b/CutToLength/UIItem.cs @@ -1,29 +1,18 @@ -namespace CutToLength +using Newtonsoft.Json; + +namespace CutToLength { public class UIItem { - private string name; - public UIItem() { } - public string Name - { - get - { - return string.IsNullOrWhiteSpace(name) ? - GetDefaultName() : - name; - } - set - { - name = value; - } - } + public string Name { get; set; } public double Length { get; set; } + [JsonIgnore] public double TotalLength { get { return Length * Quantity; }