feat(ui): redesign the Nest Defaults dialog

The flat ten-row list squeezed the quadrant picker to 120x28 and gave no
hint of units or where the defaults are saved. Group the fields (General,
Plate Size, Quadrant, Spacing), lay the edge spacings out around a plate,
show in/mm suffixes, and convert the values when the units switch so a
48 in plate does not silently become 48 mm.

The footer says whether Save writes to this PC or the shared nest server,
and Save is disabled while the shared copy is read-only instead of
failing after the click.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Opus 5.5 committed 2026-10-26 09:46:42 -04:00
1 parent 7f1c5a3854
commit e5e2c268b8
6 files changed
+427 -294

No files matched your search

@@ -0,0 +1,61 @@
using System.Windows.Forms;
using OpenNest.Data;
using OpenNest.Forms;
using OpenNest.Geometry;
namespace OpenNest.WinForms.Tests.Forms;
public class NestDefaultsFormTests
{
[Fact]
public void SwitchingUnitsConvertsTheShownValues()
{
RunSta(() =>
{
var machine = new MachineConfig { Name = "Laser" };
var defaults = new NestDefaults
{
Units = Units.Inches,
Size = new Size(48, 96),
Quadrant = 3,
PartSpacing = 0.25,
EdgeSpacing = new Spacing(0.5, 1, 1.5, 2),
MachineId = machine.Id,
};
using var form = new NestDefaultsForm(defaults, new[] { machine }, ("Saved on this PC.", false));
Assert.Equal("in", Control<OpenNest.Controls.NumericUpDown>(form, "widthBox").Suffix);
Control<RadioButton>(form, "millimetersRadio").Checked = true;
var converted = form.GetDefaults();
Assert.Equal(Units.Millimeters, converted.Units);
Assert.Equal(new Size(1219.2, 2438.4), converted.Size);
Assert.Equal(6.35, converted.PartSpacing);
Assert.Equal(new Spacing(12.7, 25.4, 38.1, 50.8), converted.EdgeSpacing);
Assert.Equal(3, converted.Quadrant);
Assert.Equal(machine.Id, converted.MachineId);
Assert.Equal("mm", Control<OpenNest.Controls.NumericUpDown>(form, "edgeTopBox").Suffix);
Control<RadioButton>(form, "inchesRadio").Checked = true;
Assert.Equal(new Size(48, 96), form.GetDefaults().Size);
});
}
[Fact]
public void ReadOnlySourceDisablesSave()
{
RunSta(() =>
{
using var form = new NestDefaultsForm(new NestDefaults(), Array.Empty<MachineConfig>(),
("Shared, read-only: the server cannot be reached.", true));
Assert.False(Control<Button>(form, "saveButton").Enabled);
Assert.Equal("Shared, read-only: the server cannot be reached.", Control<Label>(form, "sourceLabel").Text);
});
}
private static T Control<T>(NestDefaultsForm form, string name) where T : Control =>
Assert.IsType<T>(form.Controls.Find(name, true).Single());
private static void RunSta(System.Action action) =>
StaTestThread.Run(action, Timeout.InfiniteTimeSpan, "The STA test did not complete.");
}
+3 -1
View File
@@ -172,7 +172,9 @@ namespace OpenNest.Forms
private void NestDefaults_Click(object sender, EventArgs e)
{
using (var form = new NestDefaultsForm(MachineSettings.LoadSavedNestDefaults(out _), MachineSettings.LoadMachines()))
var defaults = MachineSettings.LoadSavedNestDefaults(out _);
SharedSettings.WarnIfOffline(this);
using (var form = new NestDefaultsForm(defaults, MachineSettings.LoadMachines(), SharedSettings.NestDefaultsSource()))
{
if (form.ShowDialog(this) == DialogResult.OK)
SaveNestDefaults(form.GetDefaults());
+305 -279
View File
@@ -28,307 +28,320 @@ namespace OpenNest.Forms
/// </summary>
private void InitializeComponent()
{
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.components = new System.ComponentModel.Container();
this.generalGroup = new System.Windows.Forms.GroupBox();
this.machineLabel = new System.Windows.Forms.Label();
this.machineCombo = new System.Windows.Forms.ComboBox();
this.unitsLabel = new System.Windows.Forms.Label();
this.unitsCombo = new System.Windows.Forms.ComboBox();
this.inchesRadio = new System.Windows.Forms.RadioButton();
this.millimetersRadio = new System.Windows.Forms.RadioButton();
this.plateGroup = new System.Windows.Forms.GroupBox();
this.widthLabel = new System.Windows.Forms.Label();
this.widthBox = new OpenNest.Controls.NumericUpDown();
this.lengthLabel = new System.Windows.Forms.Label();
this.lengthBox = new OpenNest.Controls.NumericUpDown();
this.quadrantGroup = new System.Windows.Forms.GroupBox();
this.quadrantSelect1 = new OpenNest.Controls.QuadrantSelect();
this.quadrantHintLabel = new System.Windows.Forms.Label();
this.spacingGroup = new System.Windows.Forms.GroupBox();
this.partSpacingLabel = new System.Windows.Forms.Label();
this.partSpacingBox = new OpenNest.Controls.NumericUpDown();
this.edgeLeftLabel = new System.Windows.Forms.Label();
this.edgeLeftBox = new OpenNest.Controls.NumericUpDown();
this.edgeBottomLabel = new System.Windows.Forms.Label();
this.edgeBottomBox = new OpenNest.Controls.NumericUpDown();
this.edgeRightLabel = new System.Windows.Forms.Label();
this.edgeRightBox = new OpenNest.Controls.NumericUpDown();
this.edgeTopLabel = new System.Windows.Forms.Label();
this.edgeSpacingLabel = new System.Windows.Forms.Label();
this.edgeTopBox = new OpenNest.Controls.NumericUpDown();
this.quadrantLabel = new System.Windows.Forms.Label();
this.quadrantSelect1 = new OpenNest.Controls.QuadrantSelect();
this.machineLabel = new System.Windows.Forms.Label();
this.machineCombo = new System.Windows.Forms.ComboBox();
this.edgeLeftBox = new OpenNest.Controls.NumericUpDown();
this.edgePlateLabel = new System.Windows.Forms.Label();
this.edgeRightBox = new OpenNest.Controls.NumericUpDown();
this.edgeBottomBox = new OpenNest.Controls.NumericUpDown();
this.sourceLabel = new System.Windows.Forms.Label();
this.saveButton = new System.Windows.Forms.Button();
this.cancelButton = new System.Windows.Forms.Button();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
((System.ComponentModel.ISupportInitialize)(this.widthBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.lengthBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.partSpacingBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.edgeLeftBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.edgeBottomBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.edgeRightBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.edgeTopBox)).BeginInit();
this.tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.edgeLeftBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.edgeRightBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.edgeBottomBox)).BeginInit();
this.generalGroup.SuspendLayout();
this.plateGroup.SuspendLayout();
this.quadrantGroup.SuspendLayout();
this.spacingGroup.SuspendLayout();
this.SuspendLayout();
//
// tableLayoutPanel1
// generalGroup
//
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Controls.Add(this.unitsLabel, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.unitsCombo, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.widthLabel, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.widthBox, 1, 1);
this.tableLayoutPanel1.Controls.Add(this.lengthLabel, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.lengthBox, 1, 2);
this.tableLayoutPanel1.Controls.Add(this.partSpacingLabel, 0, 3);
this.tableLayoutPanel1.Controls.Add(this.partSpacingBox, 1, 3);
this.tableLayoutPanel1.Controls.Add(this.edgeLeftLabel, 0, 4);
this.tableLayoutPanel1.Controls.Add(this.edgeLeftBox, 1, 4);
this.tableLayoutPanel1.Controls.Add(this.edgeBottomLabel, 0, 5);
this.tableLayoutPanel1.Controls.Add(this.edgeBottomBox, 1, 5);
this.tableLayoutPanel1.Controls.Add(this.edgeRightLabel, 0, 6);
this.tableLayoutPanel1.Controls.Add(this.edgeRightBox, 1, 6);
this.tableLayoutPanel1.Controls.Add(this.edgeTopLabel, 0, 7);
this.tableLayoutPanel1.Controls.Add(this.edgeTopBox, 1, 7);
this.tableLayoutPanel1.Controls.Add(this.quadrantLabel, 0, 8);
this.tableLayoutPanel1.Controls.Add(this.quadrantSelect1, 1, 8);
this.tableLayoutPanel1.Controls.Add(this.machineLabel, 0, 9);
this.tableLayoutPanel1.Controls.Add(this.machineCombo, 1, 9);
this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 12);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 10;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(410, 288);
this.tableLayoutPanel1.TabIndex = 0;
//
// unitsLabel
//
this.unitsLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.unitsLabel.AutoSize = true;
this.unitsLabel.Location = new System.Drawing.Point(3, 9);
this.unitsLabel.Name = "unitsLabel";
this.unitsLabel.Size = new System.Drawing.Size(100, 16);
this.unitsLabel.TabIndex = 0;
this.unitsLabel.Text = "Units:";
//
// unitsCombo
//
this.unitsCombo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.unitsCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.unitsCombo.Items.AddRange(new object[] { "Inches", "Millimeters" });
this.unitsCombo.Location = new System.Drawing.Point(109, 5);
this.unitsCombo.Name = "unitsCombo";
this.unitsCombo.Size = new System.Drawing.Size(298, 24);
this.unitsCombo.TabIndex = 1;
//
// widthLabel
//
this.widthLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.widthLabel.AutoSize = true;
this.widthLabel.Location = new System.Drawing.Point(3, 37);
this.widthLabel.Name = "widthLabel";
this.widthLabel.Size = new System.Drawing.Size(100, 16);
this.widthLabel.TabIndex = 2;
this.widthLabel.Text = "Plate width:";
//
// widthBox
//
this.widthBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.widthBox.DecimalPlaces = 4;
this.widthBox.Location = new System.Drawing.Point(109, 33);
this.widthBox.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
this.widthBox.Minimum = new decimal(new int[] { 1, 0, 0, 196608 });
this.widthBox.Name = "widthBox";
this.widthBox.Size = new System.Drawing.Size(298, 22);
this.widthBox.Suffix = "";
this.widthBox.TabIndex = 3;
//
// lengthLabel
//
this.lengthLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.lengthLabel.AutoSize = true;
this.lengthLabel.Location = new System.Drawing.Point(3, 65);
this.lengthLabel.Name = "lengthLabel";
this.lengthLabel.Size = new System.Drawing.Size(100, 16);
this.lengthLabel.TabIndex = 4;
this.lengthLabel.Text = "Plate length:";
//
// lengthBox
//
this.lengthBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.lengthBox.DecimalPlaces = 4;
this.lengthBox.Location = new System.Drawing.Point(109, 61);
this.lengthBox.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
this.lengthBox.Minimum = new decimal(new int[] { 1, 0, 0, 196608 });
this.lengthBox.Name = "lengthBox";
this.lengthBox.Size = new System.Drawing.Size(298, 22);
this.lengthBox.Suffix = "";
this.lengthBox.TabIndex = 5;
//
// partSpacingLabel
//
this.partSpacingLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.partSpacingLabel.AutoSize = true;
this.partSpacingLabel.Location = new System.Drawing.Point(3, 93);
this.partSpacingLabel.Name = "partSpacingLabel";
this.partSpacingLabel.Size = new System.Drawing.Size(100, 16);
this.partSpacingLabel.TabIndex = 6;
this.partSpacingLabel.Text = "Part spacing:";
//
// partSpacingBox
//
this.partSpacingBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.partSpacingBox.DecimalPlaces = 4;
this.partSpacingBox.Location = new System.Drawing.Point(109, 89);
this.partSpacingBox.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
this.partSpacingBox.Name = "partSpacingBox";
this.partSpacingBox.Size = new System.Drawing.Size(298, 22);
this.partSpacingBox.Suffix = "";
this.partSpacingBox.TabIndex = 7;
//
// edgeLeftLabel
//
this.edgeLeftLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.edgeLeftLabel.AutoSize = true;
this.edgeLeftLabel.Location = new System.Drawing.Point(3, 121);
this.edgeLeftLabel.Name = "edgeLeftLabel";
this.edgeLeftLabel.Size = new System.Drawing.Size(100, 16);
this.edgeLeftLabel.TabIndex = 8;
this.edgeLeftLabel.Text = "Edge left:";
//
// edgeLeftBox
//
this.edgeLeftBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.edgeLeftBox.DecimalPlaces = 4;
this.edgeLeftBox.Location = new System.Drawing.Point(109, 117);
this.edgeLeftBox.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
this.edgeLeftBox.Name = "edgeLeftBox";
this.edgeLeftBox.Size = new System.Drawing.Size(298, 22);
this.edgeLeftBox.Suffix = "";
this.edgeLeftBox.TabIndex = 9;
//
// edgeBottomLabel
//
this.edgeBottomLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.edgeBottomLabel.AutoSize = true;
this.edgeBottomLabel.Location = new System.Drawing.Point(3, 149);
this.edgeBottomLabel.Name = "edgeBottomLabel";
this.edgeBottomLabel.Size = new System.Drawing.Size(100, 16);
this.edgeBottomLabel.TabIndex = 10;
this.edgeBottomLabel.Text = "Edge bottom:";
//
// edgeBottomBox
//
this.edgeBottomBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.edgeBottomBox.DecimalPlaces = 4;
this.edgeBottomBox.Location = new System.Drawing.Point(109, 145);
this.edgeBottomBox.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
this.edgeBottomBox.Name = "edgeBottomBox";
this.edgeBottomBox.Size = new System.Drawing.Size(298, 22);
this.edgeBottomBox.Suffix = "";
this.edgeBottomBox.TabIndex = 11;
//
// edgeRightLabel
//
this.edgeRightLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.edgeRightLabel.AutoSize = true;
this.edgeRightLabel.Location = new System.Drawing.Point(3, 177);
this.edgeRightLabel.Name = "edgeRightLabel";
this.edgeRightLabel.Size = new System.Drawing.Size(100, 16);
this.edgeRightLabel.TabIndex = 12;
this.edgeRightLabel.Text = "Edge right:";
//
// edgeRightBox
//
this.edgeRightBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.edgeRightBox.DecimalPlaces = 4;
this.edgeRightBox.Location = new System.Drawing.Point(109, 173);
this.edgeRightBox.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
this.edgeRightBox.Name = "edgeRightBox";
this.edgeRightBox.Size = new System.Drawing.Size(298, 22);
this.edgeRightBox.Suffix = "";
this.edgeRightBox.TabIndex = 13;
//
// edgeTopLabel
//
this.edgeTopLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.edgeTopLabel.AutoSize = true;
this.edgeTopLabel.Location = new System.Drawing.Point(3, 205);
this.edgeTopLabel.Name = "edgeTopLabel";
this.edgeTopLabel.Size = new System.Drawing.Size(100, 16);
this.edgeTopLabel.TabIndex = 14;
this.edgeTopLabel.Text = "Edge top:";
//
// edgeTopBox
//
this.edgeTopBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.edgeTopBox.DecimalPlaces = 4;
this.edgeTopBox.Location = new System.Drawing.Point(109, 201);
this.edgeTopBox.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
this.edgeTopBox.Name = "edgeTopBox";
this.edgeTopBox.Size = new System.Drawing.Size(298, 22);
this.edgeTopBox.Suffix = "";
this.edgeTopBox.TabIndex = 15;
//
// quadrantLabel
//
this.quadrantLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.quadrantLabel.AutoSize = true;
this.quadrantLabel.Location = new System.Drawing.Point(3, 233);
this.quadrantLabel.Name = "quadrantLabel";
this.quadrantLabel.Size = new System.Drawing.Size(100, 16);
this.quadrantLabel.TabIndex = 16;
this.quadrantLabel.Text = "Quadrant:";
//
// quadrantSelect1
//
this.quadrantSelect1.Anchor = System.Windows.Forms.AnchorStyles.None;
this.quadrantSelect1.BackColor = System.Drawing.Color.White;
this.quadrantSelect1.Location = new System.Drawing.Point(198, 225);
this.quadrantSelect1.Name = "quadrantSelect1";
this.quadrantSelect1.Quadrant = 1;
this.quadrantSelect1.Size = new System.Drawing.Size(120, 28);
this.quadrantSelect1.TabIndex = 17;
this.generalGroup.Controls.Add(this.machineLabel);
this.generalGroup.Controls.Add(this.machineCombo);
this.generalGroup.Controls.Add(this.unitsLabel);
this.generalGroup.Controls.Add(this.inchesRadio);
this.generalGroup.Controls.Add(this.millimetersRadio);
this.generalGroup.Location = new System.Drawing.Point(12, 12);
this.generalGroup.Name = "generalGroup";
this.generalGroup.Size = new System.Drawing.Size(340, 90);
this.generalGroup.TabIndex = 0;
this.generalGroup.TabStop = false;
this.generalGroup.Text = "General";
//
// machineLabel
//
this.machineLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.machineLabel.AutoSize = true;
this.machineLabel.Location = new System.Drawing.Point(3, 263);
this.machineLabel.Location = new System.Drawing.Point(12, 27);
this.machineLabel.Name = "machineLabel";
this.machineLabel.Size = new System.Drawing.Size(100, 16);
this.machineLabel.TabIndex = 18;
this.machineLabel.Size = new System.Drawing.Size(56, 15);
this.machineLabel.TabIndex = 0;
this.machineLabel.Text = "Machine:";
//
// machineCombo
//
this.machineCombo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.machineCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.machineCombo.Location = new System.Drawing.Point(109, 259);
this.machineCombo.Location = new System.Drawing.Point(90, 23);
this.machineCombo.Name = "machineCombo";
this.machineCombo.Size = new System.Drawing.Size(298, 24);
this.machineCombo.TabIndex = 19;
this.machineCombo.Size = new System.Drawing.Size(236, 23);
this.machineCombo.TabIndex = 1;
//
// unitsLabel
//
this.unitsLabel.AutoSize = true;
this.unitsLabel.Location = new System.Drawing.Point(12, 59);
this.unitsLabel.Name = "unitsLabel";
this.unitsLabel.Size = new System.Drawing.Size(37, 15);
this.unitsLabel.TabIndex = 2;
this.unitsLabel.Text = "Units:";
//
// inchesRadio
//
this.inchesRadio.AutoSize = true;
this.inchesRadio.Location = new System.Drawing.Point(90, 57);
this.inchesRadio.Name = "inchesRadio";
this.inchesRadio.Size = new System.Drawing.Size(61, 19);
this.inchesRadio.TabIndex = 3;
this.inchesRadio.TabStop = true;
this.inchesRadio.Text = "Inches";
this.inchesRadio.UseVisualStyleBackColor = true;
//
// millimetersRadio
//
this.millimetersRadio.AutoSize = true;
this.millimetersRadio.Location = new System.Drawing.Point(170, 57);
this.millimetersRadio.Name = "millimetersRadio";
this.millimetersRadio.Size = new System.Drawing.Size(85, 19);
this.millimetersRadio.TabIndex = 4;
this.millimetersRadio.Text = "Millimeters";
this.millimetersRadio.UseVisualStyleBackColor = true;
this.millimetersRadio.CheckedChanged += new System.EventHandler(this.UnitsChanged);
//
// plateGroup
//
this.plateGroup.Controls.Add(this.widthLabel);
this.plateGroup.Controls.Add(this.widthBox);
this.plateGroup.Controls.Add(this.lengthLabel);
this.plateGroup.Controls.Add(this.lengthBox);
this.plateGroup.Location = new System.Drawing.Point(12, 110);
this.plateGroup.Name = "plateGroup";
this.plateGroup.Size = new System.Drawing.Size(340, 90);
this.plateGroup.TabIndex = 1;
this.plateGroup.TabStop = false;
this.plateGroup.Text = "Plate Size";
//
// widthLabel
//
this.widthLabel.AutoSize = true;
this.widthLabel.Location = new System.Drawing.Point(12, 27);
this.widthLabel.Name = "widthLabel";
this.widthLabel.Size = new System.Drawing.Size(42, 15);
this.widthLabel.TabIndex = 0;
this.widthLabel.Text = "Width:";
//
// widthBox
//
this.widthBox.DecimalPlaces = 4;
this.widthBox.Location = new System.Drawing.Point(90, 24);
this.widthBox.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
this.widthBox.Minimum = new decimal(new int[] { 1, 0, 0, 196608 });
this.widthBox.Name = "widthBox";
this.widthBox.Size = new System.Drawing.Size(130, 23);
this.widthBox.Suffix = "";
this.widthBox.TabIndex = 1;
//
// lengthLabel
//
this.lengthLabel.AutoSize = true;
this.lengthLabel.Location = new System.Drawing.Point(12, 59);
this.lengthLabel.Name = "lengthLabel";
this.lengthLabel.Size = new System.Drawing.Size(47, 15);
this.lengthLabel.TabIndex = 2;
this.lengthLabel.Text = "Length:";
//
// lengthBox
//
this.lengthBox.DecimalPlaces = 4;
this.lengthBox.Location = new System.Drawing.Point(90, 56);
this.lengthBox.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
this.lengthBox.Minimum = new decimal(new int[] { 1, 0, 0, 196608 });
this.lengthBox.Name = "lengthBox";
this.lengthBox.Size = new System.Drawing.Size(130, 23);
this.lengthBox.Suffix = "";
this.lengthBox.TabIndex = 3;
//
// quadrantGroup
//
this.quadrantGroup.Controls.Add(this.quadrantSelect1);
this.quadrantGroup.Controls.Add(this.quadrantHintLabel);
this.quadrantGroup.Location = new System.Drawing.Point(364, 12);
this.quadrantGroup.Name = "quadrantGroup";
this.quadrantGroup.Size = new System.Drawing.Size(224, 188);
this.quadrantGroup.TabIndex = 2;
this.quadrantGroup.TabStop = false;
this.quadrantGroup.Text = "Quadrant";
//
// quadrantSelect1
//
this.quadrantSelect1.BackColor = System.Drawing.Color.White;
this.quadrantSelect1.Cursor = System.Windows.Forms.Cursors.Hand;
this.quadrantSelect1.Location = new System.Drawing.Point(12, 24);
this.quadrantSelect1.Name = "quadrantSelect1";
this.quadrantSelect1.Quadrant = 1;
this.quadrantSelect1.Size = new System.Drawing.Size(200, 126);
this.quadrantSelect1.TabIndex = 0;
//
// quadrantHintLabel
//
this.quadrantHintLabel.ForeColor = System.Drawing.SystemColors.GrayText;
this.quadrantHintLabel.Location = new System.Drawing.Point(12, 156);
this.quadrantHintLabel.Name = "quadrantHintLabel";
this.quadrantHintLabel.Size = new System.Drawing.Size(200, 20);
this.quadrantHintLabel.TabIndex = 1;
this.quadrantHintLabel.Text = "Click a quadrant to select it.";
this.quadrantHintLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// spacingGroup
//
this.spacingGroup.Controls.Add(this.partSpacingLabel);
this.spacingGroup.Controls.Add(this.partSpacingBox);
this.spacingGroup.Controls.Add(this.edgeSpacingLabel);
this.spacingGroup.Controls.Add(this.edgeTopBox);
this.spacingGroup.Controls.Add(this.edgeLeftBox);
this.spacingGroup.Controls.Add(this.edgePlateLabel);
this.spacingGroup.Controls.Add(this.edgeRightBox);
this.spacingGroup.Controls.Add(this.edgeBottomBox);
this.spacingGroup.Location = new System.Drawing.Point(12, 208);
this.spacingGroup.Name = "spacingGroup";
this.spacingGroup.Size = new System.Drawing.Size(576, 136);
this.spacingGroup.TabIndex = 3;
this.spacingGroup.TabStop = false;
this.spacingGroup.Text = "Spacing";
//
// partSpacingLabel
//
this.partSpacingLabel.AutoSize = true;
this.partSpacingLabel.Location = new System.Drawing.Point(12, 30);
this.partSpacingLabel.Name = "partSpacingLabel";
this.partSpacingLabel.Size = new System.Drawing.Size(77, 15);
this.partSpacingLabel.TabIndex = 0;
this.partSpacingLabel.Text = "Between parts:";
//
// partSpacingBox
//
this.partSpacingBox.DecimalPlaces = 4;
this.partSpacingBox.Location = new System.Drawing.Point(12, 50);
this.partSpacingBox.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
this.partSpacingBox.Name = "partSpacingBox";
this.partSpacingBox.Size = new System.Drawing.Size(130, 23);
this.partSpacingBox.Suffix = "";
this.partSpacingBox.TabIndex = 1;
//
// edgeSpacingLabel
//
this.edgeSpacingLabel.AutoSize = true;
this.edgeSpacingLabel.Location = new System.Drawing.Point(178, 30);
this.edgeSpacingLabel.Name = "edgeSpacingLabel";
this.edgeSpacingLabel.Size = new System.Drawing.Size(67, 15);
this.edgeSpacingLabel.TabIndex = 2;
this.edgeSpacingLabel.Text = "Plate edges:";
//
// edgeTopBox
//
this.edgeTopBox.DecimalPlaces = 4;
this.edgeTopBox.Location = new System.Drawing.Point(355, 22);
this.edgeTopBox.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
this.edgeTopBox.Name = "edgeTopBox";
this.edgeTopBox.Size = new System.Drawing.Size(100, 23);
this.edgeTopBox.Suffix = "";
this.edgeTopBox.TabIndex = 3;
this.toolTip.SetToolTip(this.edgeTopBox, "Top edge spacing");
//
// edgeLeftBox
//
this.edgeLeftBox.DecimalPlaces = 4;
this.edgeLeftBox.Location = new System.Drawing.Point(250, 61);
this.edgeLeftBox.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
this.edgeLeftBox.Name = "edgeLeftBox";
this.edgeLeftBox.Size = new System.Drawing.Size(100, 23);
this.edgeLeftBox.Suffix = "";
this.edgeLeftBox.TabIndex = 4;
this.toolTip.SetToolTip(this.edgeLeftBox, "Left edge spacing");
//
// edgePlateLabel
//
this.edgePlateLabel.BackColor = System.Drawing.Color.AliceBlue;
this.edgePlateLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.edgePlateLabel.ForeColor = System.Drawing.SystemColors.GrayText;
this.edgePlateLabel.Location = new System.Drawing.Point(358, 50);
this.edgePlateLabel.Name = "edgePlateLabel";
this.edgePlateLabel.Size = new System.Drawing.Size(94, 45);
this.edgePlateLabel.TabIndex = 5;
this.edgePlateLabel.Text = "Plate";
this.edgePlateLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// edgeRightBox
//
this.edgeRightBox.DecimalPlaces = 4;
this.edgeRightBox.Location = new System.Drawing.Point(460, 61);
this.edgeRightBox.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
this.edgeRightBox.Name = "edgeRightBox";
this.edgeRightBox.Size = new System.Drawing.Size(100, 23);
this.edgeRightBox.Suffix = "";
this.edgeRightBox.TabIndex = 6;
this.toolTip.SetToolTip(this.edgeRightBox, "Right edge spacing");
//
// edgeBottomBox
//
this.edgeBottomBox.DecimalPlaces = 4;
this.edgeBottomBox.Location = new System.Drawing.Point(355, 100);
this.edgeBottomBox.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
this.edgeBottomBox.Name = "edgeBottomBox";
this.edgeBottomBox.Size = new System.Drawing.Size(100, 23);
this.edgeBottomBox.Suffix = "";
this.edgeBottomBox.TabIndex = 7;
this.toolTip.SetToolTip(this.edgeBottomBox, "Bottom edge spacing");
//
// sourceLabel
//
this.sourceLabel.ForeColor = System.Drawing.SystemColors.GrayText;
this.sourceLabel.Location = new System.Drawing.Point(12, 356);
this.sourceLabel.Name = "sourceLabel";
this.sourceLabel.Size = new System.Drawing.Size(380, 28);
this.sourceLabel.TabIndex = 4;
this.sourceLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// saveButton
//
this.saveButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.saveButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.saveButton.Location = new System.Drawing.Point(243, 313);
this.saveButton.Location = new System.Drawing.Point(402, 356);
this.saveButton.Name = "saveButton";
this.saveButton.Size = new System.Drawing.Size(90, 28);
this.saveButton.TabIndex = 1;
this.saveButton.TabIndex = 5;
this.saveButton.Text = "Save";
this.saveButton.UseVisualStyleBackColor = true;
//
// cancelButton
//
this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Location = new System.Drawing.Point(339, 313);
this.cancelButton.Location = new System.Drawing.Point(498, 356);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(90, 28);
this.cancelButton.TabIndex = 2;
this.cancelButton.TabIndex = 6;
this.cancelButton.Text = "Cancel";
this.cancelButton.UseVisualStyleBackColor = true;
//
@@ -337,8 +350,12 @@ namespace OpenNest.Forms
this.AcceptButton = this.saveButton;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.CancelButton = this.cancelButton;
this.ClientSize = new System.Drawing.Size(434, 350);
this.Controls.Add(this.tableLayoutPanel1);
this.ClientSize = new System.Drawing.Size(600, 396);
this.Controls.Add(this.generalGroup);
this.Controls.Add(this.plateGroup);
this.Controls.Add(this.quadrantGroup);
this.Controls.Add(this.spacingGroup);
this.Controls.Add(this.sourceLabel);
this.Controls.Add(this.saveButton);
this.Controls.Add(this.cancelButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
@@ -352,39 +369,48 @@ namespace OpenNest.Forms
((System.ComponentModel.ISupportInitialize)(this.widthBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.lengthBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.partSpacingBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.edgeLeftBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.edgeBottomBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.edgeRightBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.edgeTopBox)).EndInit();
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.edgeLeftBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.edgeRightBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.edgeBottomBox)).EndInit();
this.generalGroup.ResumeLayout(false);
this.generalGroup.PerformLayout();
this.plateGroup.ResumeLayout(false);
this.plateGroup.PerformLayout();
this.quadrantGroup.ResumeLayout(false);
this.spacingGroup.ResumeLayout(false);
this.spacingGroup.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.GroupBox generalGroup;
private System.Windows.Forms.Label machineLabel;
private System.Windows.Forms.ComboBox machineCombo;
private System.Windows.Forms.Label unitsLabel;
private System.Windows.Forms.ComboBox unitsCombo;
private System.Windows.Forms.RadioButton inchesRadio;
private System.Windows.Forms.RadioButton millimetersRadio;
private System.Windows.Forms.GroupBox plateGroup;
private System.Windows.Forms.Label widthLabel;
private OpenNest.Controls.NumericUpDown widthBox;
private System.Windows.Forms.Label lengthLabel;
private OpenNest.Controls.NumericUpDown lengthBox;
private System.Windows.Forms.GroupBox quadrantGroup;
private OpenNest.Controls.QuadrantSelect quadrantSelect1;
private System.Windows.Forms.Label quadrantHintLabel;
private System.Windows.Forms.GroupBox spacingGroup;
private System.Windows.Forms.Label partSpacingLabel;
private OpenNest.Controls.NumericUpDown partSpacingBox;
private System.Windows.Forms.Label edgeLeftLabel;
private OpenNest.Controls.NumericUpDown edgeLeftBox;
private System.Windows.Forms.Label edgeBottomLabel;
private OpenNest.Controls.NumericUpDown edgeBottomBox;
private System.Windows.Forms.Label edgeRightLabel;
private OpenNest.Controls.NumericUpDown edgeRightBox;
private System.Windows.Forms.Label edgeTopLabel;
private System.Windows.Forms.Label edgeSpacingLabel;
private OpenNest.Controls.NumericUpDown edgeTopBox;
private System.Windows.Forms.Label quadrantLabel;
private OpenNest.Controls.QuadrantSelect quadrantSelect1;
private System.Windows.Forms.Label machineLabel;
private System.Windows.Forms.ComboBox machineCombo;
private OpenNest.Controls.NumericUpDown edgeLeftBox;
private System.Windows.Forms.Label edgePlateLabel;
private OpenNest.Controls.NumericUpDown edgeRightBox;
private OpenNest.Controls.NumericUpDown edgeBottomBox;
private System.Windows.Forms.Label sourceLabel;
private System.Windows.Forms.Button saveButton;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.ToolTip toolTip;
}
}
+43 -13
View File
@@ -19,9 +19,11 @@ namespace OpenNest.Forms
}
private readonly Guid? savedMachineId;
private Units shownUnits;
/// <param name="machines">The machines new nests can be assigned.</param>
public NestDefaultsForm(NestDefaults defaults, IEnumerable<MachineConfig> machines)
/// <param name="source">Where the defaults are saved, and whether they can be saved there now.</param>
public NestDefaultsForm(NestDefaults defaults, IEnumerable<MachineConfig> machines, (string Text, bool ReadOnly) source)
{
InitializeComponent();
@@ -33,24 +35,25 @@ namespace OpenNest.Forms
machineCombo.SelectedItem = machineCombo.Items.Cast<MachineChoice>().FirstOrDefault(c => c.Machine == selected);
machineCombo.Enabled = machineCombo.Items.Count > 0;
unitsCombo.SelectedIndex = defaults.Units == Units.Millimeters ? 1 : 0;
widthBox.Value = Clamp(widthBox, defaults.Size.Width);
lengthBox.Value = Clamp(lengthBox, defaults.Size.Length);
partSpacingBox.Value = Clamp(partSpacingBox, defaults.PartSpacing);
edgeLeftBox.Value = Clamp(edgeLeftBox, defaults.EdgeSpacing.Left);
edgeBottomBox.Value = Clamp(edgeBottomBox, defaults.EdgeSpacing.Bottom);
edgeRightBox.Value = Clamp(edgeRightBox, defaults.EdgeSpacing.Right);
edgeTopBox.Value = Clamp(edgeTopBox, defaults.EdgeSpacing.Top);
quadrantSelect1.Quadrant = defaults.Quadrant;
shownUnits = defaults.Units;
(defaults.Units == Units.Millimeters ? millimetersRadio : inchesRadio).Checked = true;
ShowValues(defaults);
sourceLabel.Text = source.Text;
saveButton.Enabled = !source.ReadOnly;
}
public Units Units => unitsCombo.SelectedIndex == 1 ? Units.Millimeters : Units.Inches;
private NestDefaultsForm() => InitializeComponent();
public NestDefaults GetDefaults()
public Units Units => millimetersRadio.Checked ? Units.Millimeters : Units.Inches;
public NestDefaults GetDefaults() => ReadValues(Units);
private NestDefaults ReadValues(Units units)
{
return new NestDefaults
{
Units = Units,
Units = units,
Size = new Size((double)widthBox.Value, (double)lengthBox.Value),
Quadrant = quadrantSelect1.Quadrant,
PartSpacing = (double)partSpacingBox.Value,
@@ -65,6 +68,33 @@ namespace OpenNest.Forms
};
}
private void ShowValues(NestDefaults defaults)
{
widthBox.Value = Clamp(widthBox, defaults.Size.Width);
lengthBox.Value = Clamp(lengthBox, defaults.Size.Length);
partSpacingBox.Value = Clamp(partSpacingBox, defaults.PartSpacing);
edgeLeftBox.Value = Clamp(edgeLeftBox, defaults.EdgeSpacing.Left);
edgeBottomBox.Value = Clamp(edgeBottomBox, defaults.EdgeSpacing.Bottom);
edgeRightBox.Value = Clamp(edgeRightBox, defaults.EdgeSpacing.Right);
edgeTopBox.Value = Clamp(edgeTopBox, defaults.EdgeSpacing.Top);
quadrantSelect1.Quadrant = defaults.Quadrant;
quadrantSelect1.Invalidate();
var suffix = defaults.Units == Units.Millimeters ? "mm" : "in";
foreach (var box in new[] { widthBox, lengthBox, partSpacingBox, edgeLeftBox, edgeBottomBox, edgeRightBox, edgeTopBox })
box.Suffix = suffix;
}
/// <summary>Switching units converts the values shown, so a 48 in plate stays 1219.2 mm.</summary>
private void UnitsChanged(object sender, EventArgs e)
{
if (Units == shownUnits)
return;
ShowValues(ReadValues(shownUnits).ConvertedTo(Units));
shownUnits = Units;
}
private static decimal Clamp(NumericUpDown box, double value)
{
if (double.IsNaN(value) || double.IsInfinity(value))
+13
View File
@@ -112,6 +112,19 @@ namespace OpenNest.Forms
return store?.IsOffline == true ? "shared, read-only: the server cannot be reached" : "shared on the nest server";
}
/// <summary>
/// Where Tools > Nest Defaults saves (the server once it holds them, as
/// <see cref="MachineSettings.SaveNestDefaults"/> does) and whether it can save there now.
/// </summary>
public static (string Text, bool ReadOnly) NestDefaultsSource()
{
if (Find(SharedSettingKinds.NestDefaults, SharedSettingKinds.DefaultKey) == null)
return (Current() == null ? "Saved on this PC." : "Saved on this PC only: not shared on the server yet.", false);
return store?.IsOffline == true
? ("Shared, read-only: the server cannot be reached.", true)
: ("Shared with every workstation on the nest server.", false);
}
/// <summary>The key of a post's shared settings.</summary>
public static string PostKey(IPostProcessor postProcessor) => postProcessor.GetType().FullName;
+2 -1
View File
@@ -48,7 +48,8 @@ saved first the server refuses it and the desktop takes their copy:
- Clamps, nest defaults, support grid: the save reports the conflict.
The window title of Tools > Machine Configuration says whether it edits the shared machines,
this PC's (not shared yet), or a read-only copy.
this PC's (not shared yet), or a read-only copy. Tools > Nest Defaults says the same beside
its buttons and disables Save while its shared copy is read-only.
## Server