private async void LineButton_Click(object sender, RoutedEventArgs e) { var geometry = await SceneEditHelper.CreatePolylineAsync(View); var graphic = new Graphic(geometry); graphic.Symbol = new SimpleLineSymbol() { Color = SelectedColor.Color, Width = DEFAULT_WIDTH }; _polylinesOverlay.Graphics.Add(graphic); }
private async void DrawButton_Click(object sender, RoutedEventArgs e) { try { Geometry geometry = null; Graphic graphic = null; CancelButton.IsEnabled = true; ClearButton.IsEnabled = false; // Draw geometry and create a new graphic using it switch ((DrawShape)DrawShapes.SelectedValue) { case DrawShape.Point: geometry = await SceneEditHelper.CreatePointAsync(MySceneView); graphic = new Graphic(geometry); _pointsOverlay.Graphics.Add(graphic); break; case DrawShape.Polygon: geometry = await SceneEditHelper.CreatePolygonAsync(MySceneView); graphic = new Graphic(geometry); _polygonsOverlay.Graphics.Add(graphic); break; case DrawShape.Polyline: geometry = await SceneEditHelper.CreatePolylineAsync(MySceneView); graphic = new Graphic(geometry); _polylinesOverlay.Graphics.Add(graphic); break; default: break; } } catch (TaskCanceledException) { // This occurs if draw operation is canceled or new operation is started before previous was finished. Debug.WriteLine("Previous draw operation was canceled."); } finally { CancelButton.IsEnabled = false; ClearButton.IsEnabled = true; } }