mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-01 06:41:42 -05:00
PlateCommands ports the WinForms nest window's plate commands, each one undo step under its WinForms label: Remove Plate, Remove Empty Plates, Duplicate Plate (the copy current, with its own cutting parameters), Move Plate and its Alt+Up/Alt+Down target, Rotate Plate (90 degrees either way or 180), Resize Plate to its parts by the auto-size factor, Set Nest Default Plate, and Edit Plate's commit, where an empty plate's new settings become the nest's defaults and the nested quantities are counted again. NewNestDefaults is what Set as Default saves for new nests: the plate, the saved common-line usage and the nest's machine. PlateEditValues is what Edit Plate edits (quantity, size, part and edge spacing, quadrant, outline), when Done applies and how it writes the plate; SheetOutlineImport reads an outline from a CAD file, and SvgScale holds the scale prompt for an SVG that does not state its size. PlateListRow is the Plates list's row text and its drag drop slots; QuadrantPick the quadrant picker's hit test and cells. The WinForms nest window, plate list, Edit Plate dialog, quadrant picker, SVG scale prompt and Save Current as Defaults delegate to them with unchanged behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.4 KiB
C#
38 lines
1.4 KiB
C#
namespace OpenNest.Desktop;
|
|
|
|
/// <summary>
|
|
/// The Edit Plate dialog's quadrant picker: a square split in four, the plate origin's
|
|
/// quadrant numbered as on a graph (1 upper right, 2 upper left, 3 lower left, 4 lower right).
|
|
/// Coordinates are the control's, y growing down.
|
|
/// </summary>
|
|
public static class QuadrantPick
|
|
{
|
|
/// <summary><paramref name="value"/> when it is 1 to 4, otherwise 1, as the picker accepts it.</summary>
|
|
public static int Normalize(int value) => value is >= 1 and <= 4 ? value : 1;
|
|
|
|
/// <summary>The quadrant a click at (<paramref name="x"/>, <paramref name="y"/>) picks.</summary>
|
|
public static int At(double x, double y, double width, double height)
|
|
{
|
|
var left = x < width / 2;
|
|
var top = y < height / 2;
|
|
return left ? (top ? 2 : 3) : (top ? 1 : 4);
|
|
}
|
|
|
|
/// <summary>
|
|
/// The highlighted cell of <paramref name="quadrant"/>: its left and top edges and size,
|
|
/// in the control's coordinates.
|
|
/// </summary>
|
|
public static (double X, double Y, double Width, double Height) Cell(int quadrant, double width, double height)
|
|
{
|
|
var midX = width / 2;
|
|
var midY = height / 2;
|
|
return Normalize(quadrant) switch
|
|
{
|
|
1 => (midX, 0, width - midX, midY),
|
|
2 => (0, 0, midX, midY),
|
|
3 => (0, midY, midX, height - midY),
|
|
_ => (midX, midY, width - midX, height - midY),
|
|
};
|
|
}
|
|
}
|