From 8ffdacd6c052c9312ff8c3d1dd2f621b4fd59c33 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Sat, 21 Mar 2026 19:49:44 -0400 Subject: [PATCH] refactor: replace NestPhase switch statements with attribute-based extensions Co-Authored-By: Claude Sonnet 4.6 --- OpenNest/Controls/PhaseStepperControl.cs | 12 +----------- OpenNest/Forms/NestProgressForm.cs | 15 +-------------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/OpenNest/Controls/PhaseStepperControl.cs b/OpenNest/Controls/PhaseStepperControl.cs index a0f8e92..7e4a0ee 100644 --- a/OpenNest/Controls/PhaseStepperControl.cs +++ b/OpenNest/Controls/PhaseStepperControl.cs @@ -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) { base.OnPaint(e); @@ -134,7 +124,7 @@ namespace OpenNest.Controls } // Label - var label = GetDisplayName(phase); + var label = phase.ShortName(); var font = isVisited || isActive ? BoldLabelFont : LabelFont; var brush = isVisited || isActive ? activeTextBrush : pendingTextBrush; var labelSize = g.MeasureString(label, font); diff --git a/OpenNest/Forms/NestProgressForm.cs b/OpenNest/Forms/NestProgressForm.cs index d95e856..ec3fd12 100644 --- a/OpenNest/Forms/NestProgressForm.cs +++ b/OpenNest/Forms/NestProgressForm.cs @@ -73,7 +73,7 @@ namespace OpenNest.Forms descriptionValue.Text = !string.IsNullOrEmpty(progress.Description) ? progress.Description - : FormatPhase(progress.Phase); + : progress.Phase.DisplayName(); } public void ShowCompleted() @@ -196,18 +196,5 @@ namespace OpenNest.Forms return DensityMidColor; 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(); - } - } } }