refactor: replace NestPhase switch statements with attribute-based extensions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-21 19:49:44 -04:00
parent ccd402c50f
commit 8ffdacd6c0
2 changed files with 2 additions and 25 deletions
+1 -11
View File
@@ -59,16 +59,6 @@ namespace OpenNest.Controls
} }
} }
private static string GetDisplayName(NestPhase phase)
{
switch (phase)
{
case NestPhase.RectBestFit: return "BestFit";
case NestPhase.Nfp: return "NFP";
default: return phase.ToString();
}
}
protected override void OnPaint(PaintEventArgs e) protected override void OnPaint(PaintEventArgs e)
{ {
base.OnPaint(e); base.OnPaint(e);
@@ -134,7 +124,7 @@ namespace OpenNest.Controls
} }
// Label // Label
var label = GetDisplayName(phase); var label = phase.ShortName();
var font = isVisited || isActive ? BoldLabelFont : LabelFont; var font = isVisited || isActive ? BoldLabelFont : LabelFont;
var brush = isVisited || isActive ? activeTextBrush : pendingTextBrush; var brush = isVisited || isActive ? activeTextBrush : pendingTextBrush;
var labelSize = g.MeasureString(label, font); var labelSize = g.MeasureString(label, font);
+1 -14
View File
@@ -73,7 +73,7 @@ namespace OpenNest.Forms
descriptionValue.Text = !string.IsNullOrEmpty(progress.Description) descriptionValue.Text = !string.IsNullOrEmpty(progress.Description)
? progress.Description ? progress.Description
: FormatPhase(progress.Phase); : progress.Phase.DisplayName();
} }
public void ShowCompleted() public void ShowCompleted()
@@ -196,18 +196,5 @@ namespace OpenNest.Forms
return DensityMidColor; return DensityMidColor;
return DensityHighColor; return DensityHighColor;
} }
private static string FormatPhase(NestPhase phase)
{
switch (phase)
{
case NestPhase.Linear: return "Trying rotations...";
case NestPhase.RectBestFit: return "Trying best fit...";
case NestPhase.Pairs: return "Trying pairs...";
case NestPhase.Extents: return "Trying extents...";
case NestPhase.Nfp: return "Trying NFP...";
default: return phase.ToString();
}
}
} }
} }