mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-12 20:31:10 -05:00
feat(status-bar): show the material grade in the material label
The status bar showed only the material name and thickness, so nests of the same material in different grades looked identical there. The grade now follows the name, e.g. "Material: Steel A36 · 0.25 in". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
698b91d256
commit
890cbc486b
2 files changed
+31
-10
No files matched your search
@@ -12,11 +12,28 @@ public class MainStatusBarTests
|
||||
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
|
||||
try
|
||||
{
|
||||
Assert.Equal("Material: A36 · 0.25 in", MainStatusBar.FormatMaterial("A36", 0.25, Units.Inches));
|
||||
Assert.Equal("Material: 304 SS · 3 mm", MainStatusBar.FormatMaterial(" 304 SS ", 3, Units.Millimeters));
|
||||
Assert.Equal("Material: A36", MainStatusBar.FormatMaterial("A36", 0, Units.Inches));
|
||||
Assert.Equal("Material: 0.1875 in", MainStatusBar.FormatMaterial(null, 0.1875, Units.Inches));
|
||||
Assert.Equal("Material: (none)", MainStatusBar.FormatMaterial("", 0, Units.Inches));
|
||||
Assert.Equal("Material: A36 · 0.25 in", MainStatusBar.FormatMaterial("A36", null, 0.25, Units.Inches));
|
||||
Assert.Equal("Material: 304 SS · 3 mm", MainStatusBar.FormatMaterial(" 304 SS ", "", 3, Units.Millimeters));
|
||||
Assert.Equal("Material: A36", MainStatusBar.FormatMaterial("A36", null, 0, Units.Inches));
|
||||
Assert.Equal("Material: 0.1875 in", MainStatusBar.FormatMaterial(null, null, 0.1875, Units.Inches));
|
||||
Assert.Equal("Material: (none)", MainStatusBar.FormatMaterial("", " ", 0, Units.Inches));
|
||||
}
|
||||
finally
|
||||
{
|
||||
CultureInfo.CurrentCulture = previous;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FormatMaterial_ShowsGradeAfterName()
|
||||
{
|
||||
var previous = CultureInfo.CurrentCulture;
|
||||
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
|
||||
try
|
||||
{
|
||||
Assert.Equal("Material: Steel A36 · 0.25 in", MainStatusBar.FormatMaterial("Steel", " A36 ", 0.25, Units.Inches));
|
||||
Assert.Equal("Material: Aluminum 5052", MainStatusBar.FormatMaterial("Aluminum", "5052", 0, Units.Inches));
|
||||
Assert.Equal("Material: 304 · 3 mm", MainStatusBar.FormatMaterial(null, "304", 3, Units.Millimeters));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace OpenNest.Forms
|
||||
|
||||
var nest = form.Nest;
|
||||
machine.Text = FormatMachine(nest.Machine);
|
||||
material.Text = FormatMaterial(nest.Material?.Name, nest.Thickness, nest.Units);
|
||||
material.Text = FormatMaterial(nest.Material?.Name, nest.Material?.Grade, nest.Thickness, nest.Units);
|
||||
|
||||
plateUtil.Text = string.Format(
|
||||
"Util: {0:P1}",
|
||||
@@ -240,12 +240,16 @@ namespace OpenNest.Forms
|
||||
return "Machine: " + (string.IsNullOrWhiteSpace(machine.Name) ? "(unnamed)" : machine.Name.Trim());
|
||||
}
|
||||
|
||||
/// <summary>Status text for the nest's material and thickness, e.g. "Material: A36 · 0.25 in".</summary>
|
||||
internal static string FormatMaterial(string name, double thickness, Units units)
|
||||
/// <summary>
|
||||
/// Status text for the nest's material, grade and thickness, e.g. "Material: Steel A36 · 0.25 in".
|
||||
/// </summary>
|
||||
internal static string FormatMaterial(string name, string grade, double thickness, Units units)
|
||||
{
|
||||
var parts = new List<string>();
|
||||
if (!string.IsNullOrWhiteSpace(name))
|
||||
parts.Add(name.Trim());
|
||||
var description = string.Join(" ", new[] { name?.Trim(), grade?.Trim() }
|
||||
.Where(s => !string.IsNullOrEmpty(s)));
|
||||
if (description.Length > 0)
|
||||
parts.Add(description);
|
||||
if (thickness > 0)
|
||||
parts.Add(thickness.ToString("0.####", CultureInfo.CurrentCulture) + " " + UnitsHelper.GetShortString(units));
|
||||
|
||||
|
||||
Reference in new issue
Block a user