Cleanup classes.
This commit is contained in:
48
CutToLength/Bin.cs
Normal file
48
CutToLength/Bin.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CutToLength
|
||||
{
|
||||
public class Bin
|
||||
{
|
||||
public List<BinItem> Items;
|
||||
|
||||
public Bin(double length)
|
||||
{
|
||||
Items = new List<BinItem>();
|
||||
Length = length;
|
||||
}
|
||||
|
||||
public double Spacing { get; set; }
|
||||
|
||||
public double Length { get; set; }
|
||||
|
||||
public double UsedLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return Items.Sum(i => i.Length) + Spacing * Items.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public double RemainingLength
|
||||
{
|
||||
get { return Length - UsedLength; }
|
||||
}
|
||||
|
||||
public double Utilization
|
||||
{
|
||||
get { return (UsedLength / Length * 100.0); }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(
|
||||
"Length: {0}\", {1}\" remaining, {2} items, {3}% utilization",
|
||||
Math.Round(Length, 4),
|
||||
Math.Round(RemainingLength, 4),
|
||||
Items.Count,
|
||||
Math.Round(Utilization, 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
9
CutToLength/BinItem.cs
Normal file
9
CutToLength/BinItem.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace CutToLength
|
||||
{
|
||||
public class BinItem
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public double Length { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,8 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Bin.cs" />
|
||||
<Compile Include="BinItem.cs" />
|
||||
<Compile Include="BinLayoutView.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
@@ -67,6 +69,7 @@
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UIItem.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
@@ -184,94 +184,4 @@ namespace CutToLength
|
||||
Run();
|
||||
}
|
||||
}
|
||||
|
||||
public class Bin
|
||||
{
|
||||
public List<BinItem> Items;
|
||||
|
||||
public Bin(double length)
|
||||
{
|
||||
Items = new List<BinItem>();
|
||||
Length = length;
|
||||
}
|
||||
|
||||
public double Spacing { get; set; }
|
||||
|
||||
public double Length { get; set; }
|
||||
|
||||
public double UsedLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return Items.Sum(i => i.Length) + Spacing * Items.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public double RemainingLength
|
||||
{
|
||||
get { return Length - UsedLength; }
|
||||
}
|
||||
|
||||
public double Utilization
|
||||
{
|
||||
get { return (UsedLength / Length * 100.0); }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(
|
||||
"Length: {0}\", {1}\" remaining, {2} items, {3}% utilization",
|
||||
Math.Round(Length, 4),
|
||||
Math.Round(RemainingLength, 4),
|
||||
Items.Count,
|
||||
Math.Round(Utilization, 2));
|
||||
}
|
||||
}
|
||||
|
||||
public class BinItem
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public double Length { get; set; }
|
||||
}
|
||||
|
||||
public class UIItem
|
||||
{
|
||||
private string name;
|
||||
|
||||
public UIItem()
|
||||
{
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(name) ?
|
||||
GetDefaultName() :
|
||||
name;
|
||||
}
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
}
|
||||
}
|
||||
|
||||
public double Length { get; set; }
|
||||
|
||||
public double TotalLength
|
||||
{
|
||||
get { return Length * Quantity; }
|
||||
}
|
||||
|
||||
public int Quantity { get; set; } = 1;
|
||||
|
||||
private string GetDefaultName()
|
||||
{
|
||||
if (Length == 0)
|
||||
return "-";
|
||||
|
||||
return string.Format("{0}\" LG", Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
42
CutToLength/UIItem.cs
Normal file
42
CutToLength/UIItem.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
namespace CutToLength
|
||||
{
|
||||
public class UIItem
|
||||
{
|
||||
private string name;
|
||||
|
||||
public UIItem()
|
||||
{
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(name) ?
|
||||
GetDefaultName() :
|
||||
name;
|
||||
}
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
}
|
||||
}
|
||||
|
||||
public double Length { get; set; }
|
||||
|
||||
public double TotalLength
|
||||
{
|
||||
get { return Length * Quantity; }
|
||||
}
|
||||
|
||||
public int Quantity { get; set; } = 1;
|
||||
|
||||
private string GetDefaultName()
|
||||
{
|
||||
if (Length == 0)
|
||||
return "-";
|
||||
|
||||
return string.Format("{0}\" LG", Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user