Started results UI.

This commit is contained in:
AJ
2018-05-18 16:17:30 -04:00
parent 21e498619c
commit 4ac806d491
9 changed files with 466 additions and 6 deletions

70
CutToLength/Class1.cs Normal file
View File

@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CutToLength
{
class Class1 : Control
{
public Bin Bin { get; set; }
private const int BorderPixels = 15;
private const int BinHeightPixels = 100;
public Class1()
{
SetStyle(ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
var displayWidth = Width - BorderPixels * 2.0f;
var maxHeight = Height - BorderPixels * 2.0f;
if (displayWidth <= 0) return;
if (maxHeight <= 0) return;
var displayHeight = maxHeight < BinHeightPixels ? maxHeight : BinHeightPixels;
var x = (Width - displayWidth) / 2.0f;
var y = (Height - displayHeight) / 2.0f;
var rect = new RectangleF(x, y, displayWidth, displayHeight);
var drawX = (float)x;
var id = 1;
var scale = displayWidth / Bin.Length;
var totalLength = 0.0;
if (Bin != null)
{
foreach (var item in Bin.Items)
{
var xc = item.Length
var w = item.Length / Bin.Length * displayWidth;
var r = new RectangleF(drawX, y, (float)w, displayHeight);
e.Graphics.DrawRectangle(Pens.Blue, r.X, r.Y, r.Width, r.Height);
e.Graphics.DrawString(id++.ToString(), Font, Brushes.Blue, r, new StringFormat
{
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Center
});
drawX = r.Right;
}
}
var scrapRect = new RectangleF(drawX, y, rect.Right - drawX, displayHeight);
e.Graphics.FillRectangle(Brushes.Red, scrapRect);
e.Graphics.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height);
}
}
}

View File

@@ -50,17 +50,29 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Class1.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Form1.cs"> <Compile Include="Form1.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Form1.Designer.cs"> <Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Form2.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form2.Designer.cs">
<DependentUpon>Form2.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx"> <EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Form2.resx">
<DependentUpon>Form2.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -72,7 +84,10 @@
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
</Compile> </Compile>
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\DataSources\Bin.datasource" />
<None Include="Properties\DataSources\BinItem.datasource" />
<None Include="Properties\DataSources\Item.datasource" /> <None Include="Properties\DataSources\Item.datasource" />
<None Include="Properties\DataSources\UIItem.datasource" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>

View File

@@ -56,13 +56,17 @@ namespace CutToLength
{ {
var bins = GetResults(); var bins = GetResults();
var saveFileDialog = new SaveFileDialog(); var form = new Form2();
saveFileDialog.Filter = "Text File|*.txt"; form.Bins = bins;
form.ShowDialog();
if (saveFileDialog.ShowDialog() == DialogResult.OK) //var saveFileDialog = new SaveFileDialog();
{ //saveFileDialog.Filter = "Text File|*.txt";
SaveBins(saveFileDialog.FileName, bins);
} //if (saveFileDialog.ShowDialog() == DialogResult.OK)
//{
// SaveBins(saveFileDialog.FileName, bins);
//}
} }
private List<Bin> GetResults() private List<Bin> GetResults()

173
CutToLength/Form2.Designer.cs generated Normal file
View File

@@ -0,0 +1,173 @@
namespace CutToLength
{
partial class Form2
{
/// <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();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
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.Class1();
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();
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.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
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.Location = new System.Drawing.Point(0, 0);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.Size = new System.Drawing.Size(892, 256);
this.dataGridView1.TabIndex = 0;
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";
this.utilizationDataGridViewTextBoxColumn.HeaderText = "Utilization";
this.utilizationDataGridViewTextBoxColumn.Name = "utilizationDataGridViewTextBoxColumn";
this.utilizationDataGridViewTextBoxColumn.ReadOnly = true;
//
// binBindingSource
//
this.binBindingSource.DataSource = typeof(CutToLength.Bin);
//
// class11
//
this.class11.BackColor = System.Drawing.Color.White;
this.class11.Bin = null;
this.class11.Dock = System.Windows.Forms.DockStyle.Fill;
this.class11.Location = new System.Drawing.Point(0, 0);
this.class11.Name = "class11";
this.class11.Size = new System.Drawing.Size(892, 181);
this.class11.TabIndex = 1;
this.class11.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.class11);
this.splitContainer1.Size = new System.Drawing.Size(892, 441);
this.splitContainer1.SplitterDistance = 256;
this.splitContainer1.TabIndex = 2;
//
// uIItemBindingSource
//
this.uIItemBindingSource.DataSource = typeof(CutToLength.UIItem);
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(892, 441);
this.Controls.Add(this.splitContainer1);
this.Name = "Form2";
this.Text = "Form2";
((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 Class1 class11;
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;
private System.Windows.Forms.BindingSource binBindingSource;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.BindingSource uIItemBindingSource;
}
}

42
CutToLength/Form2.cs Normal file
View File

@@ -0,0 +1,42 @@
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
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
}
private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
{
var selectedBin = dataGridView1.Rows[e.RowIndex].DataBoundItem as Bin;
if (selectedBin == null)
return;
class11.Bin = selectedBin;
class11.Invalidate();
}
public List<Bin> Bins
{
get { return dataGridView1.DataSource as List<Bin>; }
set { dataGridView1.DataSource = value; }
}
}
}

126
CutToLength/Form2.resx Normal file
View 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>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="Bin" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>CutToLength.Bin, CutToLength, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="BinItem" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>CutToLength.BinItem, CutToLength, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="UIItem" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>CutToLength.UIItem, CutToLength, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>