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:
Drag vertex 2 to M point manually:
Undo:
Move selected vertex to cursor using MoveSelectedVertex:
Undo of MoveSelectedVertex (moved vertex gets deleted)
If I call Redo, it gets put back where it was:
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.