Format total length

This commit is contained in:
aj
2018-05-31 23:13:14 -04:00
parent 09fa851367
commit a7b0f90a32
3 changed files with 21 additions and 18 deletions

View File

@@ -29,9 +29,9 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = 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 dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
@@ -43,11 +43,11 @@
this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripButton3 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton3 = new System.Windows.Forms.ToolStripButton();
this.itemBindingSource = new System.Windows.Forms.BindingSource(this.components); this.TotalLength = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.lengthDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.lengthDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.quantityDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.quantityDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.totalLengthDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.itemBindingSource = new System.Windows.Forms.BindingSource(this.components);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
@@ -70,7 +70,7 @@
this.nameDataGridViewTextBoxColumn, this.nameDataGridViewTextBoxColumn,
this.lengthDataGridViewTextBoxColumn, this.lengthDataGridViewTextBoxColumn,
this.quantityDataGridViewTextBoxColumn, this.quantityDataGridViewTextBoxColumn,
this.totalLengthDataGridViewTextBoxColumn}); this.TotalLength});
this.dataGridView1.DataSource = this.itemBindingSource; this.dataGridView1.DataSource = this.itemBindingSource;
this.dataGridView1.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); this.dataGridView1.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.dataGridView1.Location = new System.Drawing.Point(12, 122); this.dataGridView1.Location = new System.Drawing.Point(12, 122);
@@ -204,9 +204,16 @@
this.toolStripButton3.Text = "Run"; this.toolStripButton3.Text = "Run";
this.toolStripButton3.Click += new System.EventHandler(this.toolStripButton3_Click); this.toolStripButton3.Click += new System.EventHandler(this.toolStripButton3_Click);
// //
// itemBindingSource // TotalLength
// //
this.itemBindingSource.DataSource = typeof(CutToLength.UIItem); this.TotalLength.DataPropertyName = "TotalLength";
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Info;
dataGridViewCellStyle3.Format = "N3";
this.TotalLength.DefaultCellStyle = dataGridViewCellStyle3;
this.TotalLength.HeaderText = "Total Length";
this.TotalLength.Name = "TotalLength";
this.TotalLength.ReadOnly = true;
// //
// nameDataGridViewTextBoxColumn // nameDataGridViewTextBoxColumn
// //
@@ -233,17 +240,9 @@
this.quantityDataGridViewTextBoxColumn.Name = "quantityDataGridViewTextBoxColumn"; this.quantityDataGridViewTextBoxColumn.Name = "quantityDataGridViewTextBoxColumn";
this.quantityDataGridViewTextBoxColumn.Width = 50; this.quantityDataGridViewTextBoxColumn.Width = 50;
// //
// totalLengthDataGridViewTextBoxColumn // itemBindingSource
// //
this.totalLengthDataGridViewTextBoxColumn.DataPropertyName = "TotalLength"; this.itemBindingSource.DataSource = typeof(CutToLength.UIItem);
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Info;
dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.totalLengthDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle3;
this.totalLengthDataGridViewTextBoxColumn.HeaderText = "Total Length";
this.totalLengthDataGridViewTextBoxColumn.Name = "totalLengthDataGridViewTextBoxColumn";
this.totalLengthDataGridViewTextBoxColumn.ReadOnly = true;
this.totalLengthDataGridViewTextBoxColumn.Width = 120;
// //
// Form1 // Form1
// //
@@ -289,7 +288,7 @@
private System.Windows.Forms.DataGridViewTextBoxColumn nameDataGridViewTextBoxColumn; private System.Windows.Forms.DataGridViewTextBoxColumn nameDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn lengthDataGridViewTextBoxColumn; private System.Windows.Forms.DataGridViewTextBoxColumn lengthDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn quantityDataGridViewTextBoxColumn; private System.Windows.Forms.DataGridViewTextBoxColumn quantityDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn totalLengthDataGridViewTextBoxColumn; private System.Windows.Forms.DataGridViewTextBoxColumn TotalLength;
} }
} }

View File

@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="TotalLength.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="itemBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="itemBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using System;
namespace CutToLength namespace CutToLength
{ {
@@ -15,7 +16,7 @@ namespace CutToLength
[JsonIgnore] [JsonIgnore]
public double TotalLength public double TotalLength
{ {
get { return Length * Quantity; } get { return Math.Round(Length * Quantity, 8); }
} }
public int Quantity { get; set; } = 1; public int Quantity { get; set; } = 1;