AddVertex on Draw object uses mouse location instead of geometry passed in

08-05-2013 11:38 AM
Labels (1)
New Contributor III
Hello there, I seem to be running into what was described in this thread in the 10.1.1 WPF Runtime and was wondering if anyone else had found any workarounds, since the bug seems to still be present.

Briefly described, I have enabled a Draw object using PolyLine draw mode. I click with the mouse on a location of the map to initiate drawing. I then use a keyboard key to pull up an input form (much like Ctrl-A to choose Direction in ArcMap while creating a polyline) and type in the angle and length of the segment I would like to draw. Upon hitting enter, the dialog is dismissed and I call AddVertex on the draw object with the MapPoint I have calculated. I do this several times, and call CompleteDraw. What I then see is that the geometry for the polyline is not the series of MapPoints I have specified via AddVertex, but instead the locations that the mouse cursor was over while the dialog had focus, is instead used for the geometry of the polyline.

I attached an annotated screenshot of the resulting data to show what was expected based on the MapPoints entered, and the resulting geometry of the polyline that was created.

Any advice? I tried moving the cursor with code to the same location as that which I was calling AddVertex on, but it didn't appear to affect the geometry used to create the line.
0 Kudos
1 Reply
New Contributor III
For anyone else who happens to run into this, I coded up a hacky workaround to move the mouse cursor to the position I was hoping to add the vertex, and have the user click there instead (much like the tool in ArcMap, though I was hoping to automatically place the feature).

MapPoint referencePole; // Set elsewhere in application
var screenPoint = Map.MapToScreen(referencePole);

// Get position of Map Control on screen
var locationFromScreen = Map.PointToScreen(new System.Windows.Point(0, 0));

// Set cursor based on the above reference point and the location of the MapControl
System.Windows.Forms.Cursor.Position = new Point(Convert.ToInt32(locationFromScreen.X + screenPoint .X), Convert.ToInt32(locationFromScreen.Y + screenPoint .Y));

I'll try to create a reproducible sample and get this sent into Tech Support as well, I believe this to be a bug.
0 Kudos