diff --git a/OpenNest/Controls/PlateView.cs b/OpenNest/Controls/PlateView.cs index 501dbe8..6efe5f2 100644 --- a/OpenNest/Controls/PlateView.cs +++ b/OpenNest/Controls/PlateView.cs @@ -32,6 +32,7 @@ namespace OpenNest.Controls private Action previousAction; private CutOffSettings cutOffSettings = new CutOffSettings(); private CutOff selectedCutOff; + private bool draggingCutOff; protected List parts; private List stationaryParts = new List(); private List activeParts = new List(); @@ -234,6 +235,21 @@ namespace OpenNest.Controls if (e.Button == MouseButtons.Middle) middleMouseDownPoint = e.Location; + if (e.Button == MouseButtons.Left && currentAction is ActionSelect) + { + var hitCutOff = GetCutOffAtPoint(CurrentPoint, 5.0 / ViewScale); + if (hitCutOff != null) + { + SelectedCutOff = hitCutOff; + draggingCutOff = true; + return; + } + else + { + SelectedCutOff = null; + } + } + base.OnMouseDown(e); } @@ -251,6 +267,14 @@ namespace OpenNest.Controls } } + if (draggingCutOff && selectedCutOff != null) + { + draggingCutOff = false; + Plate.RegenerateCutOffs(cutOffSettings); + Invalidate(); + return; + } + base.OnMouseUp(e); } @@ -307,6 +331,13 @@ namespace OpenNest.Controls lastPoint = e.Location; + if (draggingCutOff && selectedCutOff != null) + { + selectedCutOff.Position = CurrentPoint; + Invalidate(); + return; + } + base.OnMouseMove(e); } @@ -323,7 +354,17 @@ namespace OpenNest.Controls switch (e.KeyCode) { case Keys.Delete: - RemoveSelectedParts(); + if (selectedCutOff != null) + { + Plate.CutOffs.Remove(selectedCutOff); + selectedCutOff = null; + Plate.RegenerateCutOffs(cutOffSettings); + Invalidate(); + } + else + { + RemoveSelectedParts(); + } break; case Keys.F: