diff --git a/CutToLength/CutToLength.csproj b/CutToLength/CutToLength.csproj
index e41da39..10db75b 100644
--- a/CutToLength/CutToLength.csproj
+++ b/CutToLength/CutToLength.csproj
@@ -36,6 +36,9 @@
..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll
+
+ ..\packages\Math-Expression-Evaluator.1.3.2\lib\netstandard2.0\SimpleExpressionEvaluator.dll
+
diff --git a/CutToLength/MainForm.Designer.cs b/CutToLength/MainForm.Designer.cs
index ca33a3a..98e4e66 100644
--- a/CutToLength/MainForm.Designer.cs
+++ b/CutToLength/MainForm.Designer.cs
@@ -29,18 +29,13 @@
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
- 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();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = 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.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
- this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
this.saveButton = new System.Windows.Forms.ToolStripButton();
@@ -50,10 +45,14 @@
this.textBox1 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
+ 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.textBox2 = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.itemBindingSource)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.toolStrip1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.itemBindingSource)).BeginInit();
this.SuspendLayout();
//
// dataGridView1
@@ -83,46 +82,17 @@
this.dataGridView1.Size = new System.Drawing.Size(763, 361);
this.dataGridView1.TabIndex = 5;
//
- // nameDataGridViewTextBoxColumn
- //
- this.nameDataGridViewTextBoxColumn.DataPropertyName = "Name";
- this.nameDataGridViewTextBoxColumn.HeaderText = "Name";
- this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn";
- this.nameDataGridViewTextBoxColumn.Width = 200;
- //
- // lengthDataGridViewTextBoxColumn
- //
- this.lengthDataGridViewTextBoxColumn.DataPropertyName = "Length";
- 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 = "TotalLength";
- dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
- dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Info;
- dataGridViewCellStyle3.Format = "N3";
- this.TotalLength.DefaultCellStyle = dataGridViewCellStyle3;
+ dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
+ dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Info;
+ dataGridViewCellStyle4.Format = "N3";
+ this.TotalLength.DefaultCellStyle = dataGridViewCellStyle4;
this.TotalLength.HeaderText = "Total Length";
this.TotalLength.Name = "TotalLength";
this.TotalLength.ReadOnly = true;
//
- // itemBindingSource
- //
- this.itemBindingSource.DataSource = typeof(CutToLength.UIItem);
- //
// label1
//
this.label1.AutoSize = true;
@@ -139,29 +109,12 @@
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.ForeColor = System.Drawing.Color.Blue;
- this.label2.Location = new System.Drawing.Point(21, 50);
+ this.label2.Location = new System.Drawing.Point(20, 45);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(84, 17);
this.label2.TabIndex = 0;
this.label2.Text = "Stock length";
//
- // numericUpDown1
- //
- this.numericUpDown1.Location = new System.Drawing.Point(111, 48);
- this.numericUpDown1.Maximum = new decimal(new int[] {
- 999999,
- 0,
- 0,
- 0});
- this.numericUpDown1.Name = "numericUpDown1";
- this.numericUpDown1.Size = new System.Drawing.Size(139, 25);
- this.numericUpDown1.TabIndex = 1;
- this.numericUpDown1.Value = new decimal(new int[] {
- 240,
- 0,
- 0,
- 0});
- //
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -256,14 +209,52 @@
this.label4.TabIndex = 0;
this.label4.Text = "Cut width";
//
+ // nameDataGridViewTextBoxColumn
+ //
+ this.nameDataGridViewTextBoxColumn.DataPropertyName = "Name";
+ this.nameDataGridViewTextBoxColumn.HeaderText = "Name";
+ this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn";
+ this.nameDataGridViewTextBoxColumn.Width = 200;
+ //
+ // lengthDataGridViewTextBoxColumn
+ //
+ this.lengthDataGridViewTextBoxColumn.DataPropertyName = "Length";
+ dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
+ this.lengthDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle5;
+ this.lengthDataGridViewTextBoxColumn.HeaderText = "Length";
+ this.lengthDataGridViewTextBoxColumn.Name = "lengthDataGridViewTextBoxColumn";
+ this.lengthDataGridViewTextBoxColumn.Width = 120;
+ //
+ // quantityDataGridViewTextBoxColumn
+ //
+ this.quantityDataGridViewTextBoxColumn.DataPropertyName = "Quantity";
+ dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
+ this.quantityDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle6;
+ this.quantityDataGridViewTextBoxColumn.HeaderText = "Qty";
+ this.quantityDataGridViewTextBoxColumn.Name = "quantityDataGridViewTextBoxColumn";
+ this.quantityDataGridViewTextBoxColumn.Width = 50;
+ //
+ // itemBindingSource
+ //
+ this.itemBindingSource.DataSource = typeof(CutToLength.UIItem);
+ //
+ // textBox2
+ //
+ this.textBox2.Location = new System.Drawing.Point(110, 42);
+ this.textBox2.Name = "textBox2";
+ this.textBox2.Size = new System.Drawing.Size(184, 25);
+ this.textBox2.TabIndex = 9;
+ this.textBox2.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
+ this.textBox2.Validating += new System.ComponentModel.CancelEventHandler(this.TextBox2_Validating);
+ //
// MainForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(787, 496);
+ this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.toolStrip1);
- this.Controls.Add(this.numericUpDown1);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
@@ -276,10 +267,9 @@
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();
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.itemBindingSource)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -290,7 +280,6 @@
private System.Windows.Forms.BindingSource itemBindingSource;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
- private System.Windows.Forms.NumericUpDown numericUpDown1;
private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripButton toolStripButton1;
private System.Windows.Forms.ToolStripButton saveButton;
@@ -304,6 +293,7 @@
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.TextBox textBox2;
}
}
diff --git a/CutToLength/MainForm.cs b/CutToLength/MainForm.cs
index fb1169f..e042350 100644
--- a/CutToLength/MainForm.cs
+++ b/CutToLength/MainForm.cs
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
+using SimpleExpressionEvaluator;
using System;
using System.Collections.Generic;
using System.Data;
@@ -90,6 +91,11 @@ namespace CutToLength
File.WriteAllText(saveFileDialog.FileName, json);
}
+ private double StockLength
+ {
+ get { return double.Parse(textBox2.Text); }
+ }
+
private void Run()
{
var bins = GetResults();
@@ -111,7 +117,7 @@ namespace CutToLength
{
var items2 = GetItems().OrderByDescending(i => i.Length);
var bins = new List();
- var length = (double)numericUpDown1.Value;
+ var length = StockLength;
foreach (var item in items2)
{
@@ -156,7 +162,7 @@ namespace CutToLength
private Bin CreateBin()
{
- var length = (double)numericUpDown1.Value;
+ var length = StockLength;
var spacing = GetSelectedTool().Kerf;
return new Bin(length)
@@ -296,5 +302,20 @@ namespace CutToLength
SaveTools(tools);
}
}
+
+ private void TextBox2_Validating(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ try
+ {
+ var ee = new ExpressionEvaluator();
+ var x = ee.Evaluate(textBox2.Text);
+ textBox2.Text = x.ToString();
+ textBox2.ForeColor = SystemColors.WindowText;
+ }
+ catch
+ {
+ textBox2.ForeColor = Color.Red;
+ }
+ }
}
}
diff --git a/CutToLength/MainForm.resx b/CutToLength/MainForm.resx
index 2ae7c58..4353a46 100644
--- a/CutToLength/MainForm.resx
+++ b/CutToLength/MainForm.resx
@@ -123,7 +123,13 @@
17, 17
+
+ True
+
172, 17
+
+ 17, 17
+
\ No newline at end of file
diff --git a/CutToLength/ResultsForm.Designer.cs b/CutToLength/ResultsForm.Designer.cs
index bba2c8e..05b1e63 100644
--- a/CutToLength/ResultsForm.Designer.cs
+++ b/CutToLength/ResultsForm.Designer.cs
@@ -31,15 +31,15 @@
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
- this.binBindingSource = new System.Windows.Forms.BindingSource(this.components);
- this.class11 = new CutToLength.BinLayoutView();
- this.splitContainer1 = new System.Windows.Forms.SplitContainer();
- this.uIItemBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.spacingDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.lengthDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.usedLengthDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.remainingLengthDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.utilizationDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.binBindingSource = new System.Windows.Forms.BindingSource(this.components);
+ this.class11 = new CutToLength.BinLayoutView();
+ this.splitContainer1 = new System.Windows.Forms.SplitContainer();
+ this.uIItemBindingSource = new System.Windows.Forms.BindingSource(this.components);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.binBindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@@ -74,6 +74,41 @@
this.dataGridView1.RowEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_RowEnter);
this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged);
//
+ // spacingDataGridViewTextBoxColumn
+ //
+ this.spacingDataGridViewTextBoxColumn.DataPropertyName = "Spacing";
+ this.spacingDataGridViewTextBoxColumn.HeaderText = "Spacing";
+ this.spacingDataGridViewTextBoxColumn.Name = "spacingDataGridViewTextBoxColumn";
+ //
+ // lengthDataGridViewTextBoxColumn
+ //
+ this.lengthDataGridViewTextBoxColumn.DataPropertyName = "Length";
+ this.lengthDataGridViewTextBoxColumn.HeaderText = "Length";
+ this.lengthDataGridViewTextBoxColumn.Name = "lengthDataGridViewTextBoxColumn";
+ //
+ // usedLengthDataGridViewTextBoxColumn
+ //
+ this.usedLengthDataGridViewTextBoxColumn.DataPropertyName = "UsedLength";
+ this.usedLengthDataGridViewTextBoxColumn.HeaderText = "UsedLength";
+ this.usedLengthDataGridViewTextBoxColumn.Name = "usedLengthDataGridViewTextBoxColumn";
+ this.usedLengthDataGridViewTextBoxColumn.ReadOnly = true;
+ //
+ // remainingLengthDataGridViewTextBoxColumn
+ //
+ this.remainingLengthDataGridViewTextBoxColumn.DataPropertyName = "RemainingLength";
+ this.remainingLengthDataGridViewTextBoxColumn.HeaderText = "RemainingLength";
+ this.remainingLengthDataGridViewTextBoxColumn.Name = "remainingLengthDataGridViewTextBoxColumn";
+ this.remainingLengthDataGridViewTextBoxColumn.ReadOnly = true;
+ //
+ // utilizationDataGridViewTextBoxColumn
+ //
+ this.utilizationDataGridViewTextBoxColumn.DataPropertyName = "Utilization";
+ dataGridViewCellStyle1.Format = "P2";
+ this.utilizationDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle1;
+ this.utilizationDataGridViewTextBoxColumn.HeaderText = "Utilization";
+ this.utilizationDataGridViewTextBoxColumn.Name = "utilizationDataGridViewTextBoxColumn";
+ this.utilizationDataGridViewTextBoxColumn.ReadOnly = true;
+ //
// binBindingSource
//
this.binBindingSource.DataSource = typeof(CutToLength.Bin);
@@ -112,49 +147,16 @@
//
this.uIItemBindingSource.DataSource = typeof(CutToLength.UIItem);
//
- // spacingDataGridViewTextBoxColumn
- //
- this.spacingDataGridViewTextBoxColumn.DataPropertyName = "Spacing";
- this.spacingDataGridViewTextBoxColumn.HeaderText = "Spacing";
- this.spacingDataGridViewTextBoxColumn.Name = "spacingDataGridViewTextBoxColumn";
- //
- // lengthDataGridViewTextBoxColumn
- //
- this.lengthDataGridViewTextBoxColumn.DataPropertyName = "Length";
- this.lengthDataGridViewTextBoxColumn.HeaderText = "Length";
- this.lengthDataGridViewTextBoxColumn.Name = "lengthDataGridViewTextBoxColumn";
- //
- // usedLengthDataGridViewTextBoxColumn
- //
- this.usedLengthDataGridViewTextBoxColumn.DataPropertyName = "UsedLength";
- this.usedLengthDataGridViewTextBoxColumn.HeaderText = "UsedLength";
- this.usedLengthDataGridViewTextBoxColumn.Name = "usedLengthDataGridViewTextBoxColumn";
- this.usedLengthDataGridViewTextBoxColumn.ReadOnly = true;
- //
- // remainingLengthDataGridViewTextBoxColumn
- //
- this.remainingLengthDataGridViewTextBoxColumn.DataPropertyName = "RemainingLength";
- this.remainingLengthDataGridViewTextBoxColumn.HeaderText = "RemainingLength";
- this.remainingLengthDataGridViewTextBoxColumn.Name = "remainingLengthDataGridViewTextBoxColumn";
- this.remainingLengthDataGridViewTextBoxColumn.ReadOnly = true;
- //
- // utilizationDataGridViewTextBoxColumn
- //
- this.utilizationDataGridViewTextBoxColumn.DataPropertyName = "Utilization";
- dataGridViewCellStyle1.Format = "P2";
- this.utilizationDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle1;
- this.utilizationDataGridViewTextBoxColumn.HeaderText = "Utilization";
- this.utilizationDataGridViewTextBoxColumn.Name = "utilizationDataGridViewTextBoxColumn";
- this.utilizationDataGridViewTextBoxColumn.ReadOnly = true;
- //
// ResultsForm
//
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(892, 441);
this.Controls.Add(this.splitContainer1);
this.Name = "ResultsForm";
- this.Text = "Form2";
+ this.ShowIcon = false;
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Results";
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.binBindingSource)).EndInit();
this.splitContainer1.Panel1.ResumeLayout(false);
diff --git a/CutToLength/packages.config b/CutToLength/packages.config
index 466ab76..b957692 100644
--- a/CutToLength/packages.config
+++ b/CutToLength/packages.config
@@ -1,4 +1,5 @@
+
\ No newline at end of file