Potential bug with SketchEditor when undoing MoveSelectedVertex

978
1
02-15-2021 08:31 AM
ChristopherPalmer99
New Contributor II

We are using the SketchEditor to draw polylines in our Xamarin application. We are at version 100.10.0 on the Runtime nuget packages.

If I select a vertex and move it manually, using finger or mouse, then call Undo, everything works.

if (MapView.SketchEditor.IsEnabled)
{
     MapView.SketchEditor.UndoCommand.Execute(null);
}

If I create a MapPoint (we're doing a kind of snapping to the cursor position) and call MoveSelectedVertex:


var cursorPoint = GetCursorPosition();
MapView.SketchEditor.MoveSelectedVertex(cursorPoint);

Then call the same Undo command, the previously moved vertex is deleted instead of being restored to it's previous position.

GetCursorPosition:

private MapPoint GetCursorPosition()
{
     if (IsSnapping && SnapGeometry != null)
     {
           var point = SnapGeometry.Centroid().Project(MapView.SpatialReference);
           return point;
     }
     else
     {
           return MapView.GetExtent().GetCenter();
     }
}

 

Sketching:

ChristopherPalmer99_0-1613406286414.png

Drag vertex 2 to M point manually:

ChristopherPalmer99_1-1613406341893.png

Undo:

ChristopherPalmer99_2-1613406364705.png

Move selected vertex to cursor using MoveSelectedVertex:

ChristopherPalmer99_3-1613406403130.png

Undo of MoveSelectedVertex (moved vertex gets deleted)

ChristopherPalmer99_4-1613406494930.png

If I call Redo, it gets put back where it was:

ChristopherPalmer99_5-1613406551628.png

 

0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor

Thanks for reporting this bug. I can reproduce that updating vertex by interaction allows undo/redo while updating vertex by code with MoveSelectedVertex, cannot be undone without the vertex being deleted. It also appears that GeometryChanged event does not report this as move vertex but as move geometry.

As a workaround, you may subscribe to SelectedVertexChanged event and use this to track the newly inserted vertex (e.NewVertex.Point will be the unmodified/unsnapped vertex). Whether you interactively add point or call InsertAfterSelectedVertex, this event will fire.