Remember save file name.

This commit is contained in:
AJ
2021-11-15 08:46:46 -05:00
parent 24cec30bf7
commit 029414099e
10 changed files with 197 additions and 114 deletions

View File

@@ -83,7 +83,9 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Controls\BinLayoutView.cs" /> <Compile Include="Controls\BinLayoutView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Forms\DataGridViewExtensions.cs" /> <Compile Include="Forms\DataGridViewExtensions.cs" />
<Compile Include="Forms\MainForm.cs"> <Compile Include="Forms\MainForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
@@ -91,16 +93,20 @@
<Compile Include="Forms\MainForm.Designer.cs"> <Compile Include="Forms\MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon> <DependentUpon>MainForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Forms\ResultsForm.cs" /> <Compile Include="Forms\ResultsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\ResultsForm.Designer.cs"> <Compile Include="Forms\ResultsForm.Designer.cs">
<DependentUpon>ResultsForm.cs</DependentUpon> <DependentUpon>ResultsForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Helper.cs" /> <Compile Include="Helper.cs" />
<Compile Include="Models\BinInputItem.cs" /> <Compile Include="Models\BinInputItem.cs" />
<Compile Include="Models\LengthItem.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tool.cs" /> <Compile Include="Tool.cs" />
<Compile Include="Models\Item.cs" /> <Compile Include="Models\PartInputItem.cs" />
<None Include="Resources\gnome_document_new.png" />
<EmbeddedResource Include="Forms\MainForm.resx"> <EmbeddedResource Include="Forms\MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon> <DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>

View File

@@ -29,16 +29,14 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.TotalLength = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.toolStrip1 = new System.Windows.Forms.ToolStrip(); 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.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.runButton = new System.Windows.Forms.ToolStripButton();
this.comboBox1 = new System.Windows.Forms.ComboBox(); this.comboBox1 = new System.Windows.Forms.ComboBox();
this.textBox1 = new System.Windows.Forms.TextBox(); this.textBox1 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
@@ -48,15 +46,18 @@
this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabPage1 = new System.Windows.Forms.TabPage();
this.dataGridView2 = new System.Windows.Forms.DataGridView(); this.dataGridView2 = new System.Windows.Forms.DataGridView();
this.TotalLengthString = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.TotalLengthString = new System.Windows.Forms.DataGridViewTextBoxColumn();
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.itemBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.lengthInputValueDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.lengthInputValueDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.quantityDataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.quantityDataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.priorityDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.priorityDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.binInputItemBindingSource = new System.Windows.Forms.BindingSource(this.components); this.binInputItemBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
this.lengthDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
this.quantityDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.saveButton = new System.Windows.Forms.ToolStripButton();
this.TotalLength = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.runButton = new System.Windows.Forms.ToolStripButton();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.toolStrip1.SuspendLayout(); this.toolStrip1.SuspendLayout();
this.tabControl1.SuspendLayout(); this.tabControl1.SuspendLayout();
@@ -96,9 +97,22 @@
this.dataGridView1.CellValidated += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellEndEdit); this.dataGridView1.CellValidated += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellEndEdit);
this.dataGridView1.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.dataGridView1_DataError); this.dataGridView1.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.dataGridView1_DataError);
// //
// TotalLength
//
this.TotalLength.DataPropertyName = "TotalLengthString";
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Info;
dataGridViewCellStyle3.Format = "N3";
this.TotalLength.DefaultCellStyle = dataGridViewCellStyle3;
this.TotalLength.HeaderText = "Total Length";
this.TotalLength.Name = "TotalLength";
this.TotalLength.ReadOnly = true;
this.TotalLength.Width = 150;
//
// toolStrip1 // toolStrip1
// //
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripButton2,
this.toolStripButton1, this.toolStripButton1,
this.saveButton, this.saveButton,
this.toolStripSeparator1, this.toolStripSeparator1,
@@ -109,47 +123,11 @@
this.toolStrip1.TabIndex = 0; this.toolStrip1.TabIndex = 0;
this.toolStrip1.Text = "toolStrip1"; this.toolStrip1.Text = "toolStrip1";
// //
// toolStripButton1
//
this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripButton1.Image = global::CutList.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::CutList.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 // toolStripSeparator1
// //
this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 39); this.toolStripSeparator1.Size = new System.Drawing.Size(6, 39);
// //
// runButton
//
this.runButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.runButton.Image = global::CutList.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 // comboBox1
// //
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
@@ -199,6 +177,7 @@
this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Location = new System.Drawing.Point(12, 42); this.tabControl1.Location = new System.Drawing.Point(12, 42);
this.tabControl1.Name = "tabControl1"; this.tabControl1.Name = "tabControl1";
this.tabControl1.Padding = new System.Drawing.Point(20, 3);
this.tabControl1.SelectedIndex = 0; this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(856, 495); this.tabControl1.Size = new System.Drawing.Size(856, 495);
this.tabControl1.TabIndex = 12; this.tabControl1.TabIndex = 12;
@@ -252,7 +231,7 @@
this.dataGridView2.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; this.dataGridView2.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
this.dataGridView2.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; this.dataGridView2.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
this.dataGridView2.RowTemplate.Height = 26; this.dataGridView2.RowTemplate.Height = 26;
this.dataGridView2.Size = new System.Drawing.Size(836, 343); this.dataGridView2.Size = new System.Drawing.Size(836, 339);
this.dataGridView2.TabIndex = 12; this.dataGridView2.TabIndex = 12;
this.dataGridView2.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView2_CellContentClick); this.dataGridView2.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView2_CellContentClick);
this.dataGridView2.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView2_CellEndEdit); this.dataGridView2.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView2_CellEndEdit);
@@ -266,32 +245,6 @@
this.TotalLengthString.Name = "TotalLengthString"; this.TotalLengthString.Name = "TotalLengthString";
this.TotalLengthString.ReadOnly = true; this.TotalLengthString.ReadOnly = true;
// //
// itemBindingSource
//
this.itemBindingSource.DataSource = typeof(CutList.Models.Item);
//
// lengthInputValueDataGridViewTextBoxColumn
//
this.lengthInputValueDataGridViewTextBoxColumn.DataPropertyName = "LengthInputValue";
this.lengthInputValueDataGridViewTextBoxColumn.HeaderText = "Length";
this.lengthInputValueDataGridViewTextBoxColumn.Name = "lengthInputValueDataGridViewTextBoxColumn";
//
// quantityDataGridViewTextBoxColumn1
//
this.quantityDataGridViewTextBoxColumn1.DataPropertyName = "Quantity";
this.quantityDataGridViewTextBoxColumn1.HeaderText = "Quantity";
this.quantityDataGridViewTextBoxColumn1.Name = "quantityDataGridViewTextBoxColumn1";
//
// priorityDataGridViewTextBoxColumn
//
this.priorityDataGridViewTextBoxColumn.DataPropertyName = "Priority";
this.priorityDataGridViewTextBoxColumn.HeaderText = "Priority";
this.priorityDataGridViewTextBoxColumn.Name = "priorityDataGridViewTextBoxColumn";
//
// binInputItemBindingSource
//
this.binInputItemBindingSource.DataSource = typeof(CutList.Models.BinInputItem);
//
// nameDataGridViewTextBoxColumn // nameDataGridViewTextBoxColumn
// //
this.nameDataGridViewTextBoxColumn.DataPropertyName = "Name"; this.nameDataGridViewTextBoxColumn.DataPropertyName = "Name";
@@ -317,17 +270,79 @@
this.quantityDataGridViewTextBoxColumn.Name = "quantityDataGridViewTextBoxColumn"; this.quantityDataGridViewTextBoxColumn.Name = "quantityDataGridViewTextBoxColumn";
this.quantityDataGridViewTextBoxColumn.Width = 50; this.quantityDataGridViewTextBoxColumn.Width = 50;
// //
// TotalLength // itemBindingSource
// //
this.TotalLength.DataPropertyName = "TotalLengthString"; this.itemBindingSource.DataSource = typeof(CutList.Models.PartInputItem);
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; //
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Info; // lengthInputValueDataGridViewTextBoxColumn
dataGridViewCellStyle3.Format = "N3"; //
this.TotalLength.DefaultCellStyle = dataGridViewCellStyle3; this.lengthInputValueDataGridViewTextBoxColumn.DataPropertyName = "LengthInputValue";
this.TotalLength.HeaderText = "Total Length"; this.lengthInputValueDataGridViewTextBoxColumn.HeaderText = "Length";
this.TotalLength.Name = "TotalLength"; this.lengthInputValueDataGridViewTextBoxColumn.Name = "lengthInputValueDataGridViewTextBoxColumn";
this.TotalLength.ReadOnly = true; //
this.TotalLength.Width = 150; // quantityDataGridViewTextBoxColumn1
//
this.quantityDataGridViewTextBoxColumn1.DataPropertyName = "Quantity";
this.quantityDataGridViewTextBoxColumn1.HeaderText = "Quantity";
this.quantityDataGridViewTextBoxColumn1.Name = "quantityDataGridViewTextBoxColumn1";
//
// priorityDataGridViewTextBoxColumn
//
this.priorityDataGridViewTextBoxColumn.DataPropertyName = "Priority";
this.priorityDataGridViewTextBoxColumn.HeaderText = "Priority";
this.priorityDataGridViewTextBoxColumn.Name = "priorityDataGridViewTextBoxColumn";
//
// binInputItemBindingSource
//
this.binInputItemBindingSource.DataSource = typeof(CutList.Models.BinInputItem);
//
// toolStripButton2
//
this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripButton2.Image = global::CutList.Properties.Resources.gnome_document_new;
this.toolStripButton2.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton2.Name = "toolStripButton2";
this.toolStripButton2.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.toolStripButton2.Size = new System.Drawing.Size(46, 36);
this.toolStripButton2.Text = "Open";
this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton2_Click);
//
// toolStripButton1
//
this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripButton1.Image = global::CutList.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::CutList.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);
//
// runButton
//
this.runButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.runButton.Image = global::CutList.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);
// //
// MainForm // MainForm
// //
@@ -381,6 +396,7 @@
private System.Windows.Forms.DataGridViewTextBoxColumn lengthDataGridViewTextBoxColumn; private System.Windows.Forms.DataGridViewTextBoxColumn lengthDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn quantityDataGridViewTextBoxColumn; private System.Windows.Forms.DataGridViewTextBoxColumn quantityDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn TotalLength; private System.Windows.Forms.DataGridViewTextBoxColumn TotalLength;
private System.Windows.Forms.ToolStripButton toolStripButton2;
} }
} }

View File

@@ -14,20 +14,21 @@ namespace CutList.Forms
{ {
public partial class MainForm : Form public partial class MainForm : Form
{ {
private BindingList<Item> items; private BindingList<PartInputItem> parts;
private BindingList<BinInputItem> bins; private BindingList<BinInputItem> bins;
private string documentPath;
public MainForm() public MainForm()
{ {
InitializeComponent(); InitializeComponent();
items = new BindingList<Item>(); parts = new BindingList<PartInputItem>();
bins = new BindingList<BinInputItem>(); bins = new BindingList<BinInputItem>();
dataGridView1.DrawingRowNumbers(); dataGridView1.DrawingRowNumbers();
dataGridView2.DrawingRowNumbers(); dataGridView2.DrawingRowNumbers();
itemBindingSource.DataSource = items; itemBindingSource.DataSource = parts;
itemBindingSource.ListChanged += ItemBindingSource_ListChanged; itemBindingSource.ListChanged += ItemBindingSource_ListChanged;
binInputItemBindingSource.DataSource = bins; binInputItemBindingSource.DataSource = bins;
@@ -66,7 +67,7 @@ namespace CutList.Forms
private bool IsValid() private bool IsValid()
{ {
if (!items.Any(i => i.Length > 0 && i.Quantity > 0)) if (!parts.Any(i => i.Length > 0 && i.Quantity > 0))
return false; return false;
if (!bins.Any(i => i.Length > 0 && i.Quantity > 0)) if (!bins.Any(i => i.Length > 0 && i.Quantity > 0))
@@ -93,19 +94,21 @@ namespace CutList.Forms
if (openFileDialog.ShowDialog() == DialogResult.OK) if (openFileDialog.ShowDialog() == DialogResult.OK)
{ {
var data = File.ReadAllText(openFileDialog.FileName); documentPath = openFileDialog.FileName;
items = JsonConvert.DeserializeObject<BindingList<Item>>(data); var data = File.ReadAllText(documentPath);
parts = JsonConvert.DeserializeObject<BindingList<PartInputItem>>(data);
dataGridView1.ClearSelection(); dataGridView1.ClearSelection();
itemBindingSource.DataSource = items; itemBindingSource.DataSource = parts;
UpdateRunButtonState();
} }
} }
private void Save() private void Save()
{ {
var itemsToSave = items; var itemsToSave = parts;
if (dataGridView1.Rows[items.Count - 1].IsNewRow == true) if (dataGridView1.Rows[parts.Count - 1].IsNewRow == true)
itemsToSave.RemoveAt(itemsToSave.Count - 1); itemsToSave.RemoveAt(itemsToSave.Count - 1);
var json = JsonConvert.SerializeObject(itemsToSave, Formatting.Indented); var json = JsonConvert.SerializeObject(itemsToSave, Formatting.Indented);
@@ -139,11 +142,26 @@ namespace CutList.Forms
var items = GetItems(); var items = GetItems();
var result = engine.Pack(items); var result = engine.Pack(items);
var form = new ResultsForm(); var filename = GetResultsSaveName();
var form = new ResultsForm(filename);
form.Bins = result.Bins; form.Bins = result.Bins;
form.ShowDialog(); form.ShowDialog();
} }
private string GetResultsSaveName()
{
if (documentPath != null)
return Path.GetFileNameWithoutExtension(documentPath);
var today = DateTime.Today;
var year = today.Year.ToString();
var month = today.Month.ToString().PadLeft(2, '0');
var day = today.Day.ToString().PadLeft(2, '0');
var name = $"Cut List {year}-{month}-{day}";
return name;
}
private string ToolsFilePath private string ToolsFilePath
{ {
get { return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data\\Tools.json"); } get { return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data\\Tools.json"); }
@@ -161,7 +179,7 @@ namespace CutList.Forms
{ {
var items2 = new List<BinItem>(); var items2 = new List<BinItem>();
foreach (var item in items) foreach (var item in parts)
{ {
if (item.Length == null || item.Length == 0) if (item.Length == null || item.Length == 0)
continue; continue;
@@ -288,5 +306,33 @@ namespace CutList.Forms
{ {
UpdateRunButtonState(); UpdateRunButtonState();
} }
private void toolStripButton2_Click(object sender, EventArgs e)
{
documentPath = null;
parts = new BindingList<PartInputItem>();
bins = new BindingList<BinInputItem>();
dataGridView1.DataSource = parts;
dataGridView2.DataSource = bins;
UpdateRunButtonState();
}
}
public class Document
{
public Document()
{
}
[JsonIgnore]
public string SavePath { get; set; }
public List<Tool> Tools { get; set; }
public List<PartInputItem> PartsToNest { get; set; }
public List<BinInputItem> StockBins { get; set; }
} }
} }

View File

@@ -202,7 +202,7 @@
// //
// uIItemBindingSource // uIItemBindingSource
// //
this.uIItemBindingSource.DataSource = typeof(CutList.Models.Item); this.uIItemBindingSource.DataSource = typeof(CutList.Models.PartInputItem);
// //
// menuStrip1 // menuStrip1
// //

View File

@@ -10,10 +10,13 @@ namespace CutList.Forms
{ {
public partial class ResultsForm : Form public partial class ResultsForm : Form
{ {
public ResultsForm() private string filename;
public ResultsForm(string filename)
{ {
InitializeComponent(); InitializeComponent();
dataGridView1.DrawingRowNumbers(); dataGridView1.DrawingRowNumbers();
this.filename = filename;
} }
private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e) private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
@@ -39,10 +42,7 @@ namespace CutList.Forms
{ {
var s = new SaveFileDialog(); var s = new SaveFileDialog();
var today = DateTime.Today; s.FileName = filename;
var name = $"{today.Year}-{today.Month.ToString().PadLeft(2, '0')}-{today.Day.ToString().PadLeft(2, '0')} cut list.txt";
s.FileName = name;
s.Filter = "Text File|*.txt"; s.Filter = "Text File|*.txt";
if (s.ShowDialog() != DialogResult.OK) if (s.ShowDialog() != DialogResult.OK)

View File

@@ -4,15 +4,6 @@ using System;
namespace CutList.Models namespace CutList.Models
{ {
public class Item : LengthItem
{
public Item()
{
}
public string Name { get; set; }
}
public class LengthItem public class LengthItem
{ {
public int Quantity { get; set; } = 1; public int Quantity { get; set; } = 1;

View File

@@ -0,0 +1,11 @@
namespace CutList.Models
{
public class PartInputItem : LengthItem
{
public PartInputItem()
{
}
public string Name { get; set; }
}
}

View File

@@ -70,6 +70,16 @@ namespace CutList.Properties {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap gnome_document_new {
get {
object obj = ResourceManager.GetObject("gnome_document_new", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>

View File

@@ -118,13 +118,16 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Save-32" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="Circled Play-32" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Save-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\Circled Play-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="Open Folder-32" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="Open Folder-32" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Open Folder-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\Open Folder-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="Circled Play-32" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="Save-32" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Circled Play-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\Save-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="gnome_document_new" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\gnome_document_new.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
</root> </root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB