feat: restore previous action on Escape from ActionSelect
Pressing Escape from ActionSelect now restores the previous action (e.g. ActionClone) instead of staying in Select mode. Adds ConnectEvents() to the Action base class for action resume support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,8 @@ namespace OpenNest.Actions
|
|||||||
|
|
||||||
public virtual void OnPlateChanged() { }
|
public virtual void OnPlateChanged() { }
|
||||||
|
|
||||||
|
public virtual void ConnectEvents() { }
|
||||||
|
|
||||||
public abstract void DisconnectEvents();
|
public abstract void DisconnectEvents();
|
||||||
|
|
||||||
public abstract void CancelAction();
|
public abstract void CancelAction();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ namespace OpenNest.Controls
|
|||||||
private string status;
|
private string status;
|
||||||
private Plate plate;
|
private Plate plate;
|
||||||
private Action currentAction;
|
private Action currentAction;
|
||||||
|
private Action previousAction;
|
||||||
private List<LayoutPart> parts;
|
private List<LayoutPart> parts;
|
||||||
private Point middleMouseDownPoint;
|
private Point middleMouseDownPoint;
|
||||||
|
|
||||||
@@ -283,6 +284,8 @@ namespace OpenNest.Controls
|
|||||||
case Keys.Escape:
|
case Keys.Escape:
|
||||||
if (currentAction.IsBusy())
|
if (currentAction.IsBusy())
|
||||||
currentAction.CancelAction();
|
currentAction.CancelAction();
|
||||||
|
else if (currentAction is ActionSelect && previousAction != null)
|
||||||
|
RestorePreviousAction();
|
||||||
else
|
else
|
||||||
SetAction(typeof(ActionSelect));
|
SetAction(typeof(ActionSelect));
|
||||||
break;
|
break;
|
||||||
@@ -650,6 +653,11 @@ namespace OpenNest.Controls
|
|||||||
|
|
||||||
if (currentAction != null)
|
if (currentAction != null)
|
||||||
{
|
{
|
||||||
|
if (type == typeof(ActionSelect) && !(currentAction is ActionSelect))
|
||||||
|
previousAction = currentAction;
|
||||||
|
else
|
||||||
|
previousAction = null;
|
||||||
|
|
||||||
currentAction.CancelAction();
|
currentAction.CancelAction();
|
||||||
currentAction.DisconnectEvents();
|
currentAction.DisconnectEvents();
|
||||||
currentAction = null;
|
currentAction = null;
|
||||||
@@ -664,6 +672,7 @@ namespace OpenNest.Controls
|
|||||||
{
|
{
|
||||||
if (currentAction != null)
|
if (currentAction != null)
|
||||||
{
|
{
|
||||||
|
previousAction = null;
|
||||||
currentAction.CancelAction();
|
currentAction.CancelAction();
|
||||||
currentAction.DisconnectEvents();
|
currentAction.DisconnectEvents();
|
||||||
currentAction = null;
|
currentAction = null;
|
||||||
@@ -688,6 +697,20 @@ namespace OpenNest.Controls
|
|||||||
Status = GetDisplayName(type);
|
Status = GetDisplayName(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RestorePreviousAction()
|
||||||
|
{
|
||||||
|
var action = previousAction;
|
||||||
|
previousAction = null;
|
||||||
|
|
||||||
|
currentAction.CancelAction();
|
||||||
|
currentAction.DisconnectEvents();
|
||||||
|
|
||||||
|
action.ConnectEvents();
|
||||||
|
currentAction = action;
|
||||||
|
|
||||||
|
Status = GetDisplayName(action.GetType());
|
||||||
|
}
|
||||||
|
|
||||||
public void AlignSelected(AlignType alignType)
|
public void AlignSelected(AlignType alignType)
|
||||||
{
|
{
|
||||||
if (SelectedParts.Count == 0)
|
if (SelectedParts.Count == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user