private async void EditButtonClick(object sender, RoutedEventArgs e) { try { // Set the focus to the map view(close the flyout panel) DrawToolsFlyout.Hide(); // Allow the user to select a graphic Graphic editGraphic = await GetGraphicAsync(); if (editGraphic == null) { return; } // Let the user make changes to the graphic's geometry, await the result (updated geometry) Esri.ArcGISRuntime.Geometry.Geometry newGeometry = await MyMapView.SketchEditor.StartAsync(editGraphic.Geometry); // Display the updated geometry in the graphic editGraphic.Geometry = newGeometry; } catch (TaskCanceledException) { // Ignore ... let the user cancel editing } catch (Exception ex) { // Report exceptions var dialog = new MessageDialog("Error editing shape: " + ex.Message); dialog.ShowAsync(); } }
private async void DrawButtonClick(object sender, RoutedEventArgs e) { try { // Set the focus to the map view(close the flyout panel) DrawToolsFlyout.Hide(); // Let the user draw on the map view using the chosen sketch mode SketchCreationMode creationMode = (SketchCreationMode)SketchModeComboBox.SelectedItem; Esri.ArcGISRuntime.Geometry.Geometry geometry = await MyMapView.SketchEditor.StartAsync(creationMode, true); // Create and add a graphic from the geometry the user drew Graphic graphic = CreateGraphic(geometry); _sketchOverlay.Graphics.Add(graphic); // Enable/disable the clear and edit buttons according to whether or not graphics exist in the overlay ClearButton.IsEnabled = _sketchOverlay.Graphics.Count > 0; EditButton.IsEnabled = _sketchOverlay.Graphics.Count > 0; } catch (TaskCanceledException) { // Ignore ... let the user cancel drawing } catch (Exception ex) { // Report exceptions var dialog = new MessageDialog("Error drawing graphic shape: " + ex.Message); dialog.ShowAsync(); } }