diff --git a/CutToLength/CutToLength.csproj b/CutToLength/CutToLength.csproj
index 70f05d5..8b0b61f 100644
--- a/CutToLength/CutToLength.csproj
+++ b/CutToLength/CutToLength.csproj
@@ -69,6 +69,7 @@
+
MainForm.cs
@@ -100,6 +101,9 @@
Settings.settings
True
+
+ PreserveNewest
+
diff --git a/CutToLength/MainForm.Designer.cs b/CutToLength/MainForm.Designer.cs
index 2cfaa84..4fbccb1 100644
--- a/CutToLength/MainForm.Designer.cs
+++ b/CutToLength/MainForm.Designer.cs
@@ -33,33 +33,34 @@
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.label3 = new System.Windows.Forms.Label();
- this.numericUpDown2 = 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();
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.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.label3 = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
((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
//
this.dataGridView1.AllowUserToResizeRows = false;
- this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
+ this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView1.AutoGenerateColumns = false;
this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
@@ -82,46 +83,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";
- dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
- this.lengthDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle4;
- this.lengthDataGridViewTextBoxColumn.HeaderText = "Length";
- this.lengthDataGridViewTextBoxColumn.Name = "lengthDataGridViewTextBoxColumn";
- this.lengthDataGridViewTextBoxColumn.Width = 120;
- //
- // quantityDataGridViewTextBoxColumn
- //
- this.quantityDataGridViewTextBoxColumn.DataPropertyName = "Quantity";
- dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
- this.quantityDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle5;
- this.quantityDataGridViewTextBoxColumn.HeaderText = "Qty";
- this.quantityDataGridViewTextBoxColumn.Name = "quantityDataGridViewTextBoxColumn";
- this.quantityDataGridViewTextBoxColumn.Width = 50;
- //
// TotalLength
//
this.TotalLength.DataPropertyName = "TotalLength";
- dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
- dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Info;
- dataGridViewCellStyle6.Format = "N3";
- this.TotalLength.DefaultCellStyle = dataGridViewCellStyle6;
+ 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;
@@ -161,35 +133,6 @@
0,
0});
//
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.label3.ForeColor = System.Drawing.Color.Blue;
- this.label3.Location = new System.Drawing.Point(282, 50);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(67, 17);
- this.label3.TabIndex = 2;
- this.label3.Text = "Cut width";
- //
- // numericUpDown2
- //
- this.numericUpDown2.DecimalPlaces = 4;
- this.numericUpDown2.Location = new System.Drawing.Point(355, 48);
- this.numericUpDown2.Maximum = new decimal(new int[] {
- 999999,
- 0,
- 0,
- 0});
- this.numericUpDown2.Name = "numericUpDown2";
- this.numericUpDown2.Size = new System.Drawing.Size(139, 25);
- this.numericUpDown2.TabIndex = 3;
- this.numericUpDown2.Value = new decimal(new int[] {
- 125,
- 0,
- 0,
- 196608});
- //
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -244,14 +187,85 @@
this.runButton.Text = "Run";
this.runButton.Click += new System.EventHandler(this.runButton_Click);
//
+ // comboBox1
+ //
+ this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBox1.FormattingEnabled = true;
+ this.comboBox1.Location = new System.Drawing.Point(409, 42);
+ this.comboBox1.Name = "comboBox1";
+ this.comboBox1.Size = new System.Drawing.Size(184, 25);
+ this.comboBox1.TabIndex = 8;
+ this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
+ //
+ // textBox1
+ //
+ this.textBox1.Location = new System.Drawing.Point(409, 73);
+ this.textBox1.Name = "textBox1";
+ this.textBox1.Size = new System.Drawing.Size(184, 25);
+ this.textBox1.TabIndex = 9;
+ this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
+ //
+ // 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);
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label3.ForeColor = System.Drawing.Color.Blue;
+ this.label3.Location = new System.Drawing.Point(322, 45);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(81, 17);
+ this.label3.TabIndex = 0;
+ this.label3.Text = "Cut method";
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label4.ForeColor = System.Drawing.Color.Blue;
+ this.label4.Location = new System.Drawing.Point(333, 76);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(70, 17);
+ this.label4.TabIndex = 0;
+ this.label4.Text = "Kerf width";
+ //
// MainForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(787, 496);
+ this.Controls.Add(this.textBox1);
+ this.Controls.Add(this.comboBox1);
this.Controls.Add(this.toolStrip1);
- this.Controls.Add(this.numericUpDown2);
- this.Controls.Add(this.label3);
this.Controls.Add(this.numericUpDown1);
+ this.Controls.Add(this.label4);
+ this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.dataGridView1);
@@ -262,11 +276,10 @@
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();
@@ -278,8 +291,6 @@
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.NumericUpDown numericUpDown1;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.NumericUpDown numericUpDown2;
private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripButton toolStripButton1;
private System.Windows.Forms.ToolStripButton saveButton;
@@ -289,6 +300,10 @@
private System.Windows.Forms.DataGridViewTextBoxColumn lengthDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn quantityDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn TotalLength;
+ private System.Windows.Forms.ComboBox comboBox1;
+ private System.Windows.Forms.TextBox textBox1;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label4;
}
}
diff --git a/CutToLength/MainForm.cs b/CutToLength/MainForm.cs
index 8a52509..94de19f 100644
--- a/CutToLength/MainForm.cs
+++ b/CutToLength/MainForm.cs
@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
+using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
@@ -19,9 +20,25 @@ namespace CutToLength
items = new List();
-
itemBindingSource.DataSource = items;
itemBindingSource.CurrentChanged += ItemBindingSource_CurrentChanged;
+
+ if (!File.Exists(ToolsFilePath))
+ {
+ var tools = new List
+ {
+ new Tool { Name = "Shear", Kerf = 0.0 },
+ new Tool { Name = "Saw", Kerf = 0.125 }
+ };
+
+ SaveTools(tools);
+
+ comboBox1.DataSource = tools;
+ }
+ else
+ {
+ comboBox1.DataSource = GetTools();
+ }
}
protected override void OnLoad(EventArgs e)
@@ -51,6 +68,8 @@ namespace CutToLength
{
var data = File.ReadAllText(openFileDialog.FileName);
items = JsonConvert.DeserializeObject>(data);
+
+ dataGridView1.ClearSelection();
itemBindingSource.DataSource = items;
}
}
@@ -133,7 +152,7 @@ namespace CutToLength
private Bin CreateBin()
{
var length = (double)numericUpDown1.Value;
- var spacing = (double)numericUpDown2.Value;
+ var spacing = GetSelectedTool().Kerf;
return new Bin(length)
{
@@ -141,6 +160,11 @@ namespace CutToLength
};
}
+ public Tool GetSelectedTool()
+ {
+ return comboBox1.SelectedItem as Tool;
+ }
+
private void SaveBins(string file, IEnumerable bins)
{
var writer = new StreamWriter(file);
@@ -202,5 +226,70 @@ namespace CutToLength
{
Run();
}
+
+ private string ToolsFilePath
+ {
+ get { return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Tools.json"); }
+ }
+
+ private List GetTools()
+ {
+ var json = File.ReadAllText(ToolsFilePath);
+ var list = JsonConvert.DeserializeObject>(json);
+
+ return list;
+ }
+
+ private void SaveTools(IEnumerable tools)
+ {
+ var json = JsonConvert.SerializeObject(tools);
+ File.WriteAllText(ToolsFilePath, json);
+ }
+
+ private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ var tool = comboBox1.SelectedItem as Tool;
+
+ if (tool == null)
+ return;
+
+ textBox1.Text = tool.Kerf.ToString();
+
+ if (tool.AllowUserToChange)
+ {
+ textBox1.ReadOnly = false;
+ textBox1.BackColor = Color.White;
+ }
+ else
+ {
+ textBox1.ReadOnly = true;
+ textBox1.BackColor = SystemColors.Info;
+ }
+ }
+
+ private void textBox1_TextChanged(object sender, EventArgs e)
+ {
+ double value;
+
+ if (!double.TryParse(textBox1.Text, out value))
+ return;
+
+ var tool = comboBox1.SelectedItem as Tool;
+
+ if (tool == null)
+ return;
+
+ if (!tool.AllowUserToChange)
+ return;
+
+ tool.Kerf = value;
+
+ var tools = comboBox1.DataSource as List;
+
+ if (tools != null)
+ {
+ SaveTools(tools);
+ }
+ }
}
}
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/Tool.cs b/CutToLength/Tool.cs
new file mode 100644
index 0000000..c63e25a
--- /dev/null
+++ b/CutToLength/Tool.cs
@@ -0,0 +1,14 @@
+namespace CutToLength
+{
+ public class Tool
+ {
+ public string Name { get; set; }
+ public double Kerf { get; set; }
+ public bool AllowUserToChange { get; set; }
+
+ public override string ToString()
+ {
+ return Name;
+ }
+ }
+}
diff --git a/CutToLength/Tools.json b/CutToLength/Tools.json
new file mode 100644
index 0000000..2778d72
--- /dev/null
+++ b/CutToLength/Tools.json
@@ -0,0 +1,17 @@
+[
+ {
+ "Name": "Shear",
+ "Kerf": 0.0,
+ "AllowUserToChange": false
+ },
+ {
+ "Name": "Saw",
+ "Kerf": 0.125,
+ "AllowUserToChange": false
+ },
+ {
+ "Name": "Custom",
+ "Kerf": 0.125,
+ "AllowUserToChange": true
+ }
+]
\ No newline at end of file