SketchEditor UndoCommand

1258
5
Jump to solution
01-21-2019 03:41 AM
KarinGisperg1
New Contributor

Hello!

We are developing an application based on ArcGIS Runtime .NET 100.3, .Net Framework 4.7.1 , Windows 10 64bit

For polygon feature edit operations we use the the sketch editor using different modes:
We trigger the <command>.Execute in the code (for selected workflows)

(MyMapView.SketchEditor.AddCommand.Execute(insertPoint); MyMapView.SketchEditor.MoveSelectedVertex(newPosition); ... MyMapView.SketchEditor.UndoCommand.Execute(...););
Additionally, the user is allowed to edit the geometry interactively on the mapview

(AllowVertexEditing = true,

SketchVertexEditMode VertexEditMode = InteractionEdit;

RequireSelectionBeforeDrag = false; ... )

Our question is: What does the UndoCommand exactly "undo"?

Our expectation is, that the last operation is rollbacked, but we observed following behaviour (check the attached videos):

Move - Undo
- In case of moving an arbitrary vertex interactively, the undo command does not reset the original position, but DELETES the moved point.
- same behaviour when using MyMapView.SketchEditor.MoveSelectedVertex(newPosition);

Delete - Undo
- In case of deleting an arbitrary selected vertex, the undo command does not recreate the deleted point, but deletes the vertex subsequent to the deleted point ???

Is this behaviour "as designed" ?
Is there a detailled description in the APIreference documentation?

Thanks in advance,
Karin

0 Kudos
1 Solution

Accepted Solutions
MichaelBranscomb
Esri Frequent Contributor

Hi,

Rounding out this thread - this issue was resolved in the v100.5 release.

Cheers

Mike

View solution in original post

0 Kudos
5 Replies
JenniferNery
Esri Regular Contributor

Thank you for your feedback. This appears to be a regression between v100.2.1 and v100.3 that dragging vertex or geometry is not part of the undo stack. I have logged an issue for this so we can fix in future releases of the API. Meanwhile, you may use GeometryChanged event to track the old geometry to be restored on Undo.

UndoCommand is meant to bring back the previous state of geometry. When a new vertex was added, the new vertex will be removed. When a vertex is deleted, the deleted vertex is added back. When a vertex is moved, the moved vertex is moved back to its previous location. When the geometry is scaled, rotated or resized, its previous shape and location is restored.

Possible workaround:

public MainWindow()
{
    InitializeComponent();
    MyMapView.SketchEditor.GeometryChanged += (s, e) =>
    {
        undoStack.Push(e.OldGeometry);
    };
}

private readonly Stack<Geometry> undoStack = new Stack<Geometry>();

private void OnUndo(object sender, RoutedEventArgs e)
{
    MyMapView.SketchEditor.ReplaceGeometry(undoStack.Pop());
}
0 Kudos
KarinGisperg1
New Contributor

Thank you for your workaround, it temporary helps us.

I just want to point out that the wrong behaviour occurs at deleted vertices too (not only in case of dragging them). 

Is there an esri bug number or issue ticket or similar? 

0 Kudos
JenniferNery
Esri Regular Contributor

Thanks for the follow-up. Undo from move or delete are both addressed in the same issue. I don't have a reference number I can share but fix is on its way for next release.

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi,

Rounding out this thread - this issue was resolved in the v100.5 release.

Cheers

Mike

View solution in original post

0 Kudos
ChristopherPalmer99
New Contributor II

I'm seeing the problem in 100.10 when calling MoveSelectedVertex, followed by executing the UndoCommand. The vertex that was moved is deleted on the Undo.

https://community.esri.com/t5/arcgis-runtime-sdk-for-net/potential-bug-with-sketcheditor-when-undoin...

 

0 Kudos