Files
OpenNest/OpenNest.Desktop/Interaction/SelectionStatus.cs
T
ajandClaude Opus 5.5 313b5f57d6 feat(desktop): add a toolkit-neutral plate tool and selection model
PlateToolManager keeps one active tool with the WinForms action rules
(Escape cancels, then returns to Select, then resumes the ended tool) and
status text. SelectTool selects by click, Ctrl+click and window
(contains/intersect), takes common-line groups together and picks
cut-offs by their strokes. PlateHitTester hit-tests the shared display
geometry; PlateSelection reads and sets by part index.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 19:30:47 -05:00

23 lines
925 B
C#

using System.Collections.Generic;
using System.Linq;
using OpenNest.Geometry;
namespace OpenNest.Desktop.Interaction;
/// <summary>The status bar's selection text, worded as the WinForms main window words it.</summary>
public static class SelectionStatus
{
/// <summary>
/// "Selected: [x, y] w x l" for one part, "Selected (n): [x, y] w x l" around several, or an
/// empty string when no part is selected. Numbers are in the current culture, to four places.
/// </summary>
public static string Text(IReadOnlyCollection<Part> parts)
{
if (parts == null || parts.Count == 0)
return string.Empty;
var box = parts.Count == 1 ? parts.First().BoundingBox : parts.ToList().GetBoundingBox();
var where = $"[{box.X:n4}, {box.Y:n4}] {box.Width:n4} x {box.Length:n4}";
return parts.Count == 1 ? $"Selected: {where}" : $"Selected ({parts.Count}): {where}";
}
}