private async void OnEditButtonClick() { if (_selection == null) { return; // Selection missing } // Cancel previous edit if (SceneEditHelper.IsActive) { SceneEditHelper.Cancel(); } Esri.ArcGISRuntime.Geometry.Geometry editedGeometry = null; try { // Edit selected geometry and set it back to the selected graphic switch (_selection.GeometryType) { case GeometryType.Point: editedGeometry = await SceneEditHelper.CreatePointAsync( View); break; case GeometryType.Polyline: _selection.SetHidden(); // Hide selected graphic from the UI editedGeometry = await SceneEditHelper.EditPolylineAsync( View, _selection.SelectedGraphic.Geometry as Polyline); break; case GeometryType.Polygon: _selection.SetHidden(); // Hide selected graphic from the UI editedGeometry = await SceneEditHelper.EditPolygonAsync( View, _selection.SelectedGraphic.Geometry as Polygon); break; default: break; } _selection.SelectedGraphic.Geometry = editedGeometry; // Set edited geometry to selected graphic } catch (TaskCanceledException tce) { // This occurs if draw operation is canceled or new operation is started before previous was finished. Debug.WriteLine("Previous edit operation was canceled."); } finally { _selection.Unselect(); _selection.SetVisible(); // Show selected graphic from the UI } }
private async void EditButton_Click(object sender, RoutedEventArgs e) { if (_selection == null) { return; // Selection missing } // Cancel previous edit if (SceneEditHelper.IsActive) { SceneEditHelper.Cancel(); } Geometry editedGeometry = null; DrawButton.IsEnabled = false; ClearButton.IsEnabled = false; EditButton.IsEnabled = false; CancelButton.IsEnabled = true; try { // Edit selected geometry and set it back to the selected graphic switch (_selection.GeometryType) { case GeometryType.Point: editedGeometry = await SceneEditHelper.CreatePointAsync( MySceneView); break; case GeometryType.Polyline: _selection.SetHidden(); // Hide selected graphic from the UI editedGeometry = await SceneEditHelper.EditPolylineAsync( MySceneView, _selection.SelectedGraphic.Geometry as Polyline); break; case GeometryType.Polygon: _selection.SetHidden(); // Hide selected graphic from the UI editedGeometry = await SceneEditHelper.EditPolygonAsync( MySceneView, _selection.SelectedGraphic.Geometry as Polygon); break; default: break; } _selection.SelectedGraphic.Geometry = editedGeometry; // Set edited geometry to selected graphic } catch (TaskCanceledException) { // This occurs if draw operation is canceled or new operation is started before previous was finished. Debug.WriteLine("Previous edit operation was canceled."); } finally { _selection.Unselect(); _selection.SetVisible(); // Show selected graphic from the UI DrawButton.IsEnabled = true; ClearButton.IsEnabled = true; CancelButton.IsEnabled = false; } }