Restructured files
This commit is contained in:
303
CutToLength/Forms/MainForm.Designer.cs
generated
Normal file
303
CutToLength/Forms/MainForm.Designer.cs
generated
Normal file
@@ -0,0 +1,303 @@
|
||||
namespace CutToLength.Forms
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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();
|
||||
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.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.label3 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.stockLengthBox = new System.Windows.Forms.TextBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.itemBindingSource)).BeginInit();
|
||||
this.toolStrip1.SuspendLayout();
|
||||
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)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.dataGridView1.AutoGenerateColumns = false;
|
||||
this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
|
||||
this.dataGridView1.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
|
||||
this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
|
||||
this.dataGridView1.ColumnHeadersHeight = 30;
|
||||
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.nameDataGridViewTextBoxColumn,
|
||||
this.lengthDataGridViewTextBoxColumn,
|
||||
this.quantityDataGridViewTextBoxColumn,
|
||||
this.TotalLength});
|
||||
this.dataGridView1.DataSource = this.itemBindingSource;
|
||||
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.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.dataGridView1.Name = "dataGridView1";
|
||||
this.dataGridView1.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
|
||||
this.dataGridView1.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
|
||||
this.dataGridView1.RowTemplate.Height = 26;
|
||||
this.dataGridView1.Size = new System.Drawing.Size(822, 349);
|
||||
this.dataGridView1.TabIndex = 11;
|
||||
this.dataGridView1.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellEndEdit);
|
||||
this.dataGridView1.CellValidated += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridView1_CellValidated);
|
||||
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 = "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 (in)";
|
||||
this.TotalLength.Name = "TotalLength";
|
||||
this.TotalLength.ReadOnly = true;
|
||||
this.TotalLength.Width = 150;
|
||||
//
|
||||
// itemBindingSource
|
||||
//
|
||||
this.itemBindingSource.DataSource = typeof(CutToLength.UIItem);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label1.ForeColor = System.Drawing.Color.Blue;
|
||||
this.label1.Location = new System.Drawing.Point(21, 101);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(300, 17);
|
||||
this.label1.TabIndex = 10;
|
||||
this.label1.Text = "Enter the lengths that will be cut from the stock";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
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(20, 45);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(84, 17);
|
||||
this.label2.TabIndex = 1;
|
||||
this.label2.Text = "Stock length";
|
||||
//
|
||||
// toolStrip1
|
||||
//
|
||||
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripButton1,
|
||||
this.saveButton,
|
||||
this.toolStripSeparator1,
|
||||
this.runButton});
|
||||
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.toolStrip1.Name = "toolStrip1";
|
||||
this.toolStrip1.Size = new System.Drawing.Size(846, 39);
|
||||
this.toolStrip1.TabIndex = 0;
|
||||
this.toolStrip1.Text = "toolStrip1";
|
||||
//
|
||||
// toolStripButton1
|
||||
//
|
||||
this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.toolStripButton1.Image = global::CutToLength.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::CutToLength.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::CutToLength.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;
|
||||
this.comboBox1.FormattingEnabled = true;
|
||||
this.comboBox1.Location = new System.Drawing.Point(478, 42);
|
||||
this.comboBox1.Name = "comboBox1";
|
||||
this.comboBox1.Size = new System.Drawing.Size(184, 25);
|
||||
this.comboBox1.TabIndex = 7;
|
||||
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
this.textBox1.Location = new System.Drawing.Point(478, 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);
|
||||
//
|
||||
// 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(391, 45);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(81, 17);
|
||||
this.label3.TabIndex = 6;
|
||||
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(405, 76);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(67, 17);
|
||||
this.label4.TabIndex = 8;
|
||||
this.label4.Text = "Cut width";
|
||||
//
|
||||
// stockLengthBox
|
||||
//
|
||||
this.stockLengthBox.Location = new System.Drawing.Point(110, 42);
|
||||
this.stockLengthBox.Name = "stockLengthBox";
|
||||
this.stockLengthBox.Size = new System.Drawing.Size(142, 25);
|
||||
this.stockLengthBox.TabIndex = 2;
|
||||
this.stockLengthBox.Text = "12ft 0in";
|
||||
this.stockLengthBox.TextChanged += new System.EventHandler(this.StockLengthBox_TextChanged);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.ClientSize = new System.Drawing.Size(846, 484);
|
||||
this.Controls.Add(this.stockLengthBox);
|
||||
this.Controls.Add(this.textBox1);
|
||||
this.Controls.Add(this.comboBox1);
|
||||
this.Controls.Add(this.toolStrip1);
|
||||
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);
|
||||
this.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.MinimumSize = new System.Drawing.Size(570, 457);
|
||||
this.Name = "MainForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Cut To Length";
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.itemBindingSource)).EndInit();
|
||||
this.toolStrip1.ResumeLayout(false);
|
||||
this.toolStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.DataGridView dataGridView1;
|
||||
private System.Windows.Forms.BindingSource itemBindingSource;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.ToolStrip toolStrip1;
|
||||
private System.Windows.Forms.ToolStripButton toolStripButton1;
|
||||
private System.Windows.Forms.ToolStripButton saveButton;
|
||||
private System.Windows.Forms.ToolStripButton runButton;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ComboBox comboBox1;
|
||||
private System.Windows.Forms.TextBox textBox1;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.TextBox stockLengthBox;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn nameDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn lengthDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn quantityDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn TotalLength;
|
||||
}
|
||||
}
|
||||
|
||||
352
CutToLength/Forms/MainForm.cs
Normal file
352
CutToLength/Forms/MainForm.cs
Normal file
@@ -0,0 +1,352 @@
|
||||
using CutToLength.Nesting;
|
||||
using Newtonsoft.Json;
|
||||
using SimpleExpressionEvaluator;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CutToLength.Forms
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
private BindingList<UIItem> items;
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
items = new BindingList<UIItem>();
|
||||
items.ListChanged += Items_ListChanged;
|
||||
|
||||
itemBindingSource.DataSource = items;
|
||||
itemBindingSource.ListChanged += ItemBindingSource_ListChanged;
|
||||
|
||||
if (!File.Exists(ToolsFilePath))
|
||||
{
|
||||
var tools = new List<Tool>
|
||||
{
|
||||
new Tool { Name = "Shear", Kerf = 0.0 },
|
||||
new Tool { Name = "Saw", Kerf = 0.125 }
|
||||
};
|
||||
|
||||
SaveTools(tools);
|
||||
|
||||
comboBox1.DataSource = tools;
|
||||
}
|
||||
else
|
||||
{
|
||||
comboBox1.DataSource = GetTools();
|
||||
}
|
||||
}
|
||||
|
||||
private void ItemBindingSource_ListChanged(object sender, ListChangedEventArgs e)
|
||||
{
|
||||
UpdateRunButtonState();
|
||||
}
|
||||
|
||||
private void Items_ListChanged(object sender, ListChangedEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
UpdateRunButtonState();
|
||||
}
|
||||
|
||||
private void UpdateRunButtonState()
|
||||
{
|
||||
var isValid = IsValid();
|
||||
|
||||
runButton.Enabled = isValid;
|
||||
saveButton.Enabled = isValid;
|
||||
}
|
||||
|
||||
private bool IsValid()
|
||||
{
|
||||
if (!items.Any(i => i.Length > 0 && i.Quantity > 0))
|
||||
return false;
|
||||
|
||||
if (Double.IsNaN(StockLengthInches))
|
||||
return false;
|
||||
|
||||
for (int rowIndex = 0; rowIndex < dataGridView1.Rows.Count; rowIndex++)
|
||||
{
|
||||
var row = dataGridView1.Rows[rowIndex];
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(row.ErrorText))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void Open()
|
||||
{
|
||||
var openFileDialog = new OpenFileDialog();
|
||||
openFileDialog.Multiselect = true;
|
||||
openFileDialog.Filter = "Json File|*.json";
|
||||
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var data = File.ReadAllText(openFileDialog.FileName);
|
||||
items = JsonConvert.DeserializeObject<BindingList<UIItem>>(data);
|
||||
|
||||
dataGridView1.ClearSelection();
|
||||
itemBindingSource.DataSource = items;
|
||||
}
|
||||
}
|
||||
|
||||
private void Save()
|
||||
{
|
||||
var itemsToSave = items;
|
||||
|
||||
if (dataGridView1.Rows[items.Count - 1].IsNewRow == true)
|
||||
itemsToSave.RemoveAt(itemsToSave.Count - 1);
|
||||
|
||||
var json = JsonConvert.SerializeObject(itemsToSave, Formatting.Indented);
|
||||
|
||||
var saveFileDialog = new SaveFileDialog();
|
||||
saveFileDialog.Filter = "Json File|*.json";
|
||||
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
File.WriteAllText(saveFileDialog.FileName, json);
|
||||
}
|
||||
|
||||
private double StockLengthInches
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetLengthInches(stockLengthBox);
|
||||
}
|
||||
}
|
||||
|
||||
private double GetLengthInches(TextBox tb)
|
||||
{
|
||||
try
|
||||
{
|
||||
double d;
|
||||
|
||||
if (double.TryParse(tb.Text, out d))
|
||||
{
|
||||
return d;
|
||||
}
|
||||
|
||||
var x = ArchUnits.ParseToInches(tb.Text);
|
||||
tb.ForeColor = SystemColors.WindowText;
|
||||
return x;
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
tb.ForeColor = Color.Red;
|
||||
return double.NaN;
|
||||
}
|
||||
}
|
||||
|
||||
private void Run()
|
||||
{
|
||||
var cutTool = GetSelectedTool();
|
||||
|
||||
var engine = new Engine2();
|
||||
engine.Spacing = cutTool.Kerf;
|
||||
engine.StockLength = StockLengthInches;
|
||||
|
||||
var items = GetItems();
|
||||
var result = engine.Pack(items);
|
||||
|
||||
var form = new ResultsForm();
|
||||
form.Bins = result.Bins;
|
||||
form.ShowDialog();
|
||||
|
||||
//var saveFileDialog = new SaveFileDialog();
|
||||
//saveFileDialog.Filter = "Text File|*.txt";
|
||||
|
||||
//if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
//{
|
||||
// SaveBins(saveFileDialog.FileName, bins);
|
||||
//}
|
||||
}
|
||||
|
||||
private List<BinItem> GetItems()
|
||||
{
|
||||
var items2 = new List<BinItem>();
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (item.Length == null || item.Length == 0)
|
||||
continue;
|
||||
|
||||
for (int i = 0; i < item.Quantity; i++)
|
||||
{
|
||||
items2.Add(new BinItem
|
||||
{
|
||||
Name = item.Name,
|
||||
Length = item.Length.Value
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return items2;
|
||||
}
|
||||
|
||||
public Tool GetSelectedTool()
|
||||
{
|
||||
return comboBox1.SelectedItem as Tool;
|
||||
}
|
||||
|
||||
private void SaveBins(string file, IEnumerable<Bin> bins)
|
||||
{
|
||||
var writer = new StreamWriter(file);
|
||||
writer.AutoFlush = true;
|
||||
|
||||
var max = bins.Max(b => b.Items.Max(i => i.Length.ToString().Length));
|
||||
var id = 1;
|
||||
|
||||
foreach (var bin in bins)
|
||||
{
|
||||
writer.WriteLine(id++.ToString() + ". " + bin.ToString());
|
||||
|
||||
var groups = bin.Items.GroupBy(i => i.Name);
|
||||
|
||||
foreach (var group in groups)
|
||||
{
|
||||
writer.WriteLine(" {0} {1}\" - {2}", ("(" + group.Count() + ")").PadRight(5), group.First().Length.ToString().PadLeft(max + 2), group.Key);
|
||||
}
|
||||
|
||||
writer.WriteLine("---------------------------------------------------------------------");
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
writer.Close();
|
||||
|
||||
Process.Start(file);
|
||||
}
|
||||
|
||||
private void toolStripButton1_Click(object sender, EventArgs e)
|
||||
{
|
||||
Open();
|
||||
}
|
||||
|
||||
private void saveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Save();
|
||||
}
|
||||
|
||||
private void runButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Run();
|
||||
}
|
||||
|
||||
private string ToolsFilePath
|
||||
{
|
||||
get { return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data\\Tools.json"); }
|
||||
}
|
||||
|
||||
private List<Tool> GetTools()
|
||||
{
|
||||
var json = File.ReadAllText(ToolsFilePath);
|
||||
var list = JsonConvert.DeserializeObject<List<Tool>>(json);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private void SaveTools(IEnumerable<Tool> tools)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(tools, Formatting.Indented);
|
||||
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<Tool>;
|
||||
|
||||
if (tools != null)
|
||||
{
|
||||
SaveTools(tools);
|
||||
}
|
||||
}
|
||||
|
||||
private void DataGridView1_CellValidated(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex == lengthDataGridViewTextBoxColumn.Index)
|
||||
{
|
||||
var item = dataGridView1.Rows[e.RowIndex].DataBoundItem as UIItem;
|
||||
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
var errorText = string.Empty;
|
||||
|
||||
if (item.Length == null)
|
||||
{
|
||||
errorText = "Length is not in a valid format.";
|
||||
}
|
||||
|
||||
dataGridView1.Rows[e.RowIndex].ErrorText = errorText;
|
||||
}
|
||||
|
||||
UpdateRunButtonState();
|
||||
}
|
||||
|
||||
private void StockLengthBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateRunButtonState();
|
||||
}
|
||||
|
||||
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex == lengthDataGridViewTextBoxColumn.Index)
|
||||
dataGridView1.Refresh();
|
||||
}
|
||||
|
||||
private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
|
||||
{
|
||||
dataGridView1.Rows[e.RowIndex].ErrorText = e.Exception.InnerException?.Message;
|
||||
e.ThrowException = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
129
CutToLength/Forms/MainForm.resx
Normal file
129
CutToLength/Forms/MainForm.resx
Normal file
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</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">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>172, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
185
CutToLength/Forms/ResultsForm.Designer.cs
generated
Normal file
185
CutToLength/Forms/ResultsForm.Designer.cs
generated
Normal file
@@ -0,0 +1,185 @@
|
||||
namespace CutToLength.Forms
|
||||
{
|
||||
partial class ResultsForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
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.binLayoutView1 = new CutToLength.Controls.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();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.binBindingSource)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
this.splitContainer1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.uIItemBindingSource)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView1
|
||||
//
|
||||
this.dataGridView1.AutoGenerateColumns = false;
|
||||
this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
|
||||
this.dataGridView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
|
||||
this.dataGridView1.ColumnHeadersHeight = 30;
|
||||
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.spacingDataGridViewTextBoxColumn,
|
||||
this.lengthDataGridViewTextBoxColumn,
|
||||
this.usedLengthDataGridViewTextBoxColumn,
|
||||
this.remainingLengthDataGridViewTextBoxColumn,
|
||||
this.utilizationDataGridViewTextBoxColumn});
|
||||
this.dataGridView1.DataSource = this.binBindingSource;
|
||||
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGridView1.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
|
||||
this.dataGridView1.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGridView1.Name = "dataGridView1";
|
||||
this.dataGridView1.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
|
||||
this.dataGridView1.RowTemplate.Height = 25;
|
||||
this.dataGridView1.Size = new System.Drawing.Size(892, 256);
|
||||
this.dataGridView1.TabIndex = 0;
|
||||
this.dataGridView1.RowEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_RowEnter);
|
||||
//
|
||||
// binBindingSource
|
||||
//
|
||||
this.binBindingSource.DataSource = typeof(CutToLength.Bin);
|
||||
//
|
||||
// class11
|
||||
//
|
||||
this.binLayoutView1.BackColor = System.Drawing.Color.White;
|
||||
this.binLayoutView1.Bin = null;
|
||||
this.binLayoutView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.binLayoutView1.Location = new System.Drawing.Point(0, 0);
|
||||
this.binLayoutView1.Name = "class11";
|
||||
this.binLayoutView1.Size = new System.Drawing.Size(892, 181);
|
||||
this.binLayoutView1.TabIndex = 1;
|
||||
this.binLayoutView1.Text = "class11";
|
||||
//
|
||||
// splitContainer1
|
||||
//
|
||||
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
|
||||
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
|
||||
this.splitContainer1.Name = "splitContainer1";
|
||||
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
//
|
||||
// splitContainer1.Panel1
|
||||
//
|
||||
this.splitContainer1.Panel1.Controls.Add(this.dataGridView1);
|
||||
//
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.binLayoutView1);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(892, 441);
|
||||
this.splitContainer1.SplitterDistance = 256;
|
||||
this.splitContainer1.TabIndex = 2;
|
||||
//
|
||||
// uIItemBindingSource
|
||||
//
|
||||
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 = "Used Length";
|
||||
this.usedLengthDataGridViewTextBoxColumn.Name = "usedLengthDataGridViewTextBoxColumn";
|
||||
this.usedLengthDataGridViewTextBoxColumn.ReadOnly = true;
|
||||
//
|
||||
// remainingLengthDataGridViewTextBoxColumn
|
||||
//
|
||||
this.remainingLengthDataGridViewTextBoxColumn.DataPropertyName = "RemainingLength";
|
||||
this.remainingLengthDataGridViewTextBoxColumn.HeaderText = "Remaining Length";
|
||||
this.remainingLengthDataGridViewTextBoxColumn.Name = "remainingLengthDataGridViewTextBoxColumn";
|
||||
this.remainingLengthDataGridViewTextBoxColumn.ReadOnly = true;
|
||||
this.remainingLengthDataGridViewTextBoxColumn.Width = 150;
|
||||
//
|
||||
// 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.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.ClientSize = new System.Drawing.Size(892, 441);
|
||||
this.Controls.Add(this.splitContainer1);
|
||||
this.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.Name = "ResultsForm";
|
||||
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);
|
||||
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
|
||||
this.splitContainer1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.uIItemBindingSource)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.DataGridView dataGridView1;
|
||||
private Controls.BinLayoutView binLayoutView1;
|
||||
private System.Windows.Forms.BindingSource binBindingSource;
|
||||
private System.Windows.Forms.SplitContainer splitContainer1;
|
||||
private System.Windows.Forms.BindingSource uIItemBindingSource;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn spacingDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn lengthDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn usedLengthDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn remainingLengthDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn utilizationDataGridViewTextBoxColumn;
|
||||
}
|
||||
}
|
||||
54
CutToLength/Forms/ResultsForm.cs
Normal file
54
CutToLength/Forms/ResultsForm.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CutToLength.Forms
|
||||
{
|
||||
public partial class ResultsForm : Form
|
||||
{
|
||||
public ResultsForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
dataGridView1.RowPostPaint += DataGridView1_RowPostPaint;
|
||||
}
|
||||
|
||||
private void DataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
|
||||
{
|
||||
var grid = sender as DataGridView;
|
||||
var rowIdx = (e.RowIndex + 1).ToString();
|
||||
|
||||
var centerFormat = new StringFormat()
|
||||
{
|
||||
Alignment = StringAlignment.Far,
|
||||
LineAlignment = StringAlignment.Center
|
||||
};
|
||||
|
||||
var headerBounds = new Rectangle(e.RowBounds.Left, e.RowBounds.Top, grid.RowHeadersWidth - 4, e.RowBounds.Height);
|
||||
e.Graphics.DrawString(rowIdx, this.Font, Brushes.Blue, headerBounds, centerFormat);
|
||||
}
|
||||
|
||||
private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
var selectedBin = dataGridView1.Rows[e.RowIndex].DataBoundItem as Bin;
|
||||
|
||||
if (selectedBin == null)
|
||||
return;
|
||||
|
||||
binLayoutView1.Bin = selectedBin;
|
||||
binLayoutView1.Invalidate();
|
||||
}
|
||||
|
||||
public List<Bin> Bins
|
||||
{
|
||||
get { return dataGridView1.DataSource as List<Bin>; }
|
||||
set { dataGridView1.DataSource = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
126
CutToLength/Forms/ResultsForm.resx
Normal file
126
CutToLength/Forms/ResultsForm.resx
Normal file
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="binBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="uIItemBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>165, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
Reference in New Issue
Block a user