I am trying to build some functionality that allows the user to cancel a trackshape operation by pressing the ESC key. There are no errors thrown, but the trackshape operation does cancel. I am testing it with TrackMode.Polygon
1. Try the following codes, hopefully it is what you are trying to do. private void Form1_Load(object sender, EventArgs e) { winformsMap1.TrackOverlay.TrackMode = TrackMode.Polygon; }
private void TrackOverlayTrackEnding() { if (cancel) { winformsMap1.TrackOverlay.Lock.EnterWriteLock(); try { int count = winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures.Count; if (count > 0) { winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures.Remove("InTrackingFeature"); } //winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures.Add(new Feature(e.Shape)); } finally { winformsMap1.TrackOverlay.Lock.ExitWriteLock(); }