fix: improve program editor formatting, file switching, and entity colors

- Replace Program.ToString() with Cincinnati-style formatter (spaced
  coordinates, blank lines between contours, trailing zero suppression)
- Fix empty Program tab when switching files while on the tab by
  loading immediately instead of only marking stale
- Set contour-type colors on entities at load time and restore base
  colors before selection highlight to prevent color bleed to CAD view

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-31 21:56:53 -04:00
parent 5d824a1aff
commit 0cae9e88e7
2 changed files with 91 additions and 18 deletions
+29 -9
View File
@@ -137,7 +137,10 @@ namespace OpenNest.Forms
LoadItem(item);
staleProgram = true;
programEditor.Clear();
if (viewTabs.SelectedTab == tabProgram)
LoadProgramTab();
else
programEditor.Clear();
}
private void LoadItem(FileListItem item)
@@ -240,17 +243,34 @@ namespace OpenNest.Forms
private void OnViewTabChanged(object sender, EventArgs e)
{
if (viewTabs.SelectedTab == tabProgram && staleProgram)
LoadProgramTab();
}
private void LoadProgramTab()
{
var item = CurrentItem;
if (item == null)
{
var item = CurrentItem;
if (item == null) return;
var entities = item.Entities.Where(en => en.Layer.IsVisible && en.IsVisible).ToList();
if (entities.Count == 0) return;
var normalized = ShapeProfile.NormalizeEntities(entities);
programEditor.LoadEntities(normalized);
programEditor.Clear();
staleProgram = false;
return;
}
var entities = item.Entities.Where(en => en.Layer.IsVisible && en.IsVisible).ToList();
if (entities.Count == 0)
{
programEditor.Clear();
staleProgram = false;
return;
}
var normalized = ShapeProfile.NormalizeEntities(entities);
programEditor.LoadEntities(normalized);
staleProgram = false;
// Refresh CAD view to show contour-type colors
entityView1.ClearPenCache();
entityView1.Invalidate();
}
private void OnBendLineSelected(object sender, int index)