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;
            }
        }
Пример #2
0
        private async void AreaButton_Click(object sender, RoutedEventArgs e)
        {
            var geometry = await SceneEditHelper.CreatePolygonAsync(View);

            var graphic = new Graphic(geometry);

            graphic.Symbol = new SimpleFillSymbol()
            {
                Color = getColorWithAlpha(SelectedColor.Color, DEFAULT_AREA_ALPHA), Outline = new SimpleLineSymbol()
                {
                    Color = DEFAULT_POLYGON_BORFDER_COLOR
                }
            };
            _polygonsOverlay.Graphics.Add(graphic);
        }