SketchEditor broken in Quartz (WPF/v100.0)?

3382
15
12-12-2016 01:25 PM
KeithGemeinhart1
New Contributor III

I have code that I wrote in .NET runtime 10.2.7 using the MapView.Editor that allows the user to draw a polyline on the map. I'm sure it came from one of the samples. I'm trying to do the same thing in Quartz (WPF only), and it doesn't seem to work as expected. When I click my button, the map is clearly in editor mode, and I can click to draw the polyline. However, there doesn't seem to be a way to end the editing mode. Typically this is a double-click, but that does nothing. I'm left with the polyline in edit mode.

Maybe I'm missing a step, but I couldn't find an example in the docs or in the sample code.

Here is my button click code:

private async void Button_Click(object sender, RoutedEventArgs e)
{
    var geometry = await MyMapView.SketchEditor.StartAsync(SketchCreationMode.Polyline);

    GraphicsOverlay graphicsOverlay;
    if (MyMapView.GraphicsOverlays.Count < 1)
    {
        graphicsOverlay = new GraphicsOverlay();
        MyMapView.GraphicsOverlays.Add(graphicsOverlay);
    }
    else
        graphicsOverlay = MyMapView.GraphicsOverlays[0];

    var outlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Black, 1.0);
    var line = new Graphic(geometry, outlineSymbol);

    graphicsOverlay.Graphics.Add(line);
}
0 Kudos
15 Replies
KeithGemeinhart1
New Contributor III

Thanks again!

It's seems counter-intuitive that Enter/Return key press would cancel the operation. It seems more logical that Enter would complete the operation, while ESC would would be more appropriate for cancel. But the confusing thing to me is that Enter does nothing while editing in runtime 10.2.7 or in ArcMap. Michael Branscomb, is any particular reason for the change in v100.0 and more specifically choosing Enter to cancel the operation instead of ESC?

0 Kudos
dotMorten_esri
Esri Notable Contributor

Enter/ESC doesn't cancel the editing. We have no such thing. Are you sure your app doesn't trigger some code when you click enter? ie does the "draw" button still have focus, so when you hit enter, it starts a new draw, which causes the previous one to get cancelled (this would have been an issue in 10.2.x as well)

KeithGemeinhart1
New Contributor III

Morten Nielsen, you nailed it! After some testing and debugging, it looks like my draw button still has focus. If I force focus to the map view (i.e. MyMapView.Focus() ), the behavior goes away. Now the next question is why doesn't the MapView gain focus automatically when I do SketchEditor.StartAsync() and start drawing? 

0 Kudos
dotMorten_esri
Esri Notable Contributor

ow the next question is why doesn't the MapView gain focus automatically when I do SketchEditor.StartAsync() and start drawing? 

That's a great question. I'll log an enhancement request 😉

KeithGemeinhart1
New Contributor III

Thanks!! I can send you my test code if you need it.

0 Kudos
dotMorten_esri
Esri Notable Contributor

No need. I have enough information here.

0 Kudos