feat(ui): add bend line editing to CAD converter
Add Edit link and double-click handler to the bend lines list so existing bends can be modified without removing and re-adding them. BendLineDialog gains a LoadBend method to populate fields from an existing Bend. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,7 @@ namespace OpenNest.Controls
|
||||
public event EventHandler FilterChanged;
|
||||
public event EventHandler<int> BendLineSelected;
|
||||
public event EventHandler<int> BendLineRemoved;
|
||||
public event EventHandler<int> BendLineEdited;
|
||||
public event EventHandler AddBendLineClicked;
|
||||
|
||||
public FilterPanel()
|
||||
@@ -51,6 +52,18 @@ namespace OpenNest.Controls
|
||||
bendLinesList.SelectedIndexChanged += (s, e) =>
|
||||
BendLineSelected?.Invoke(this, bendLinesList.SelectedIndex);
|
||||
|
||||
var bendEditLink = new LinkLabel
|
||||
{
|
||||
Text = "Edit",
|
||||
AutoSize = true,
|
||||
Font = new Font("Segoe UI", 8f)
|
||||
};
|
||||
bendEditLink.LinkClicked += (s, e) =>
|
||||
{
|
||||
if (bendLinesList.SelectedIndex >= 0)
|
||||
BendLineEdited?.Invoke(this, bendLinesList.SelectedIndex);
|
||||
};
|
||||
|
||||
var bendDeleteLink = new LinkLabel
|
||||
{
|
||||
Text = "Remove",
|
||||
@@ -63,6 +76,12 @@ namespace OpenNest.Controls
|
||||
BendLineRemoved?.Invoke(this, bendLinesList.SelectedIndex);
|
||||
};
|
||||
|
||||
bendLinesList.DoubleClick += (s, e) =>
|
||||
{
|
||||
if (bendLinesList.SelectedIndex >= 0)
|
||||
BendLineEdited?.Invoke(this, bendLinesList.SelectedIndex);
|
||||
};
|
||||
|
||||
bendAddLink = new LinkLabel
|
||||
{
|
||||
Text = "Add Bend Line",
|
||||
@@ -80,6 +99,7 @@ namespace OpenNest.Controls
|
||||
WrapContents = false
|
||||
};
|
||||
bendLinksPanel.Controls.Add(bendAddLink);
|
||||
bendLinksPanel.Controls.Add(bendEditLink);
|
||||
bendLinksPanel.Controls.Add(bendDeleteLink);
|
||||
|
||||
bendLinesPanel.ContentPanel.Controls.Add(bendLinesList);
|
||||
|
||||
@@ -99,5 +99,17 @@ namespace OpenNest.Forms
|
||||
public double BendAngle => (double)numAngle.Value;
|
||||
|
||||
public double? BendRadius => chkRadius.Checked ? (double)numRadius.Value : null;
|
||||
|
||||
public void LoadBend(Bend bend)
|
||||
{
|
||||
cboDirection.SelectedIndex = bend.Direction == BendDirection.Up ? 1 : 0;
|
||||
if (bend.Angle.HasValue)
|
||||
numAngle.Value = (decimal)bend.Angle.Value;
|
||||
if (bend.Radius.HasValue)
|
||||
{
|
||||
chkRadius.Checked = true;
|
||||
numRadius.Value = (decimal)bend.Radius.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace OpenNest.Forms
|
||||
filterPanel.FilterChanged += OnFilterChanged;
|
||||
filterPanel.BendLineSelected += OnBendLineSelected;
|
||||
filterPanel.BendLineRemoved += OnBendLineRemoved;
|
||||
filterPanel.BendLineEdited += OnBendLineEdited;
|
||||
filterPanel.AddBendLineClicked += OnAddBendLineClicked;
|
||||
entityView1.LinePicked += OnLinePicked;
|
||||
entityView1.PickCancelled += OnPickCancelled;
|
||||
@@ -292,6 +293,29 @@ namespace OpenNest.Forms
|
||||
entityView1.Invalidate();
|
||||
}
|
||||
|
||||
private void OnBendLineEdited(object sender, int index)
|
||||
{
|
||||
var item = CurrentItem;
|
||||
if (item == null || index < 0 || index >= item.Bends.Count) return;
|
||||
|
||||
var bend = item.Bends[index];
|
||||
using var dialog = new BendLineDialog();
|
||||
dialog.LoadBend(bend);
|
||||
|
||||
if (dialog.ShowDialog(this) != DialogResult.OK) return;
|
||||
|
||||
bend.Direction = dialog.Direction;
|
||||
bend.Angle = dialog.BendAngle;
|
||||
bend.Radius = dialog.BendRadius;
|
||||
|
||||
Bend.UpdateEtchEntities(item.Entities, item.Bends);
|
||||
entityView1.Entities.Clear();
|
||||
entityView1.Entities.AddRange(item.Entities);
|
||||
entityView1.Bends = item.Bends;
|
||||
filterPanel.LoadItem(item.Entities, item.Bends);
|
||||
entityView1.Invalidate();
|
||||
}
|
||||
|
||||
private void OnQuantityChanged(object sender, EventArgs e)
|
||||
{
|
||||
var item = CurrentItem;
|
||||
|
||||
Reference in New Issue
Block a user