mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-14 11:25:09 -05:00
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>
23 lines
925 B
C#
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}";
|
|
}
|
|
}
|