feat(ui): add bool checkbox support to ShapeLibraryForm
BuildParameterControls now creates a CheckBox (wired to UpdatePreview) for bool properties instead of a TextBox; CreateShapeFromInputs reads the Checked value via a short-circuit before the TextBox cast. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -180,6 +180,20 @@ namespace OpenNest.Forms
|
|||||||
|
|
||||||
y += 18;
|
y += 18;
|
||||||
|
|
||||||
|
Control editor;
|
||||||
|
if (prop.PropertyType == typeof(bool))
|
||||||
|
{
|
||||||
|
var cb = new CheckBox
|
||||||
|
{
|
||||||
|
Location = new Point(parametersPanel.Padding.Left, y),
|
||||||
|
AutoSize = true,
|
||||||
|
Checked = sourceValues != null && (bool)prop.GetValue(sourceValues)
|
||||||
|
};
|
||||||
|
cb.CheckedChanged += (s, ev) => UpdatePreview();
|
||||||
|
editor = cb;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
var tb = new TextBox
|
var tb = new TextBox
|
||||||
{
|
{
|
||||||
Location = new Point(parametersPanel.Padding.Left, y),
|
Location = new Point(parametersPanel.Padding.Left, y),
|
||||||
@@ -196,11 +210,13 @@ namespace OpenNest.Forms
|
|||||||
}
|
}
|
||||||
|
|
||||||
tb.TextChanged += (s, ev) => UpdatePreview();
|
tb.TextChanged += (s, ev) => UpdatePreview();
|
||||||
|
editor = tb;
|
||||||
|
}
|
||||||
|
|
||||||
parameterBindings.Add(new ParameterBinding { Property = prop, Control = tb });
|
parameterBindings.Add(new ParameterBinding { Property = prop, Control = editor });
|
||||||
|
|
||||||
parametersPanel.Controls.Add(label);
|
parametersPanel.Controls.Add(label);
|
||||||
parametersPanel.Controls.Add(tb);
|
parametersPanel.Controls.Add(editor);
|
||||||
|
|
||||||
y += 30;
|
y += 30;
|
||||||
}
|
}
|
||||||
@@ -241,6 +257,13 @@ namespace OpenNest.Forms
|
|||||||
|
|
||||||
foreach (var binding in parameterBindings)
|
foreach (var binding in parameterBindings)
|
||||||
{
|
{
|
||||||
|
if (binding.Property.PropertyType == typeof(bool))
|
||||||
|
{
|
||||||
|
var cb = (CheckBox)binding.Control;
|
||||||
|
binding.Property.SetValue(shape, cb.Checked);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var tb = (TextBox)binding.Control;
|
var tb = (TextBox)binding.Control;
|
||||||
|
|
||||||
if (binding.Property.PropertyType == typeof(int))
|
if (binding.Property.PropertyType == typeof(int))
|
||||||
|
|||||||
Reference in New Issue
Block a user