private void CutBuilding(MapViewMouseButtonEventArgs e)
        {
            QueuedTask.Run(() =>
            {
                Dictionary <MapMember, List <long> > selectedItems = GetSelectedItems(e);
                EditOperation editOperation = new EditOperation();
                foreach (KeyValuePair <MapMember, List <long> > item in selectedItems)
                {
                    BasicFeatureLayer layer = item.Key as BasicFeatureLayer;
                    if (layer.ShapeType != ArcGIS.Core.CIM.esriGeometryType.esriGeometryPolygon)
                    {
                        continue;
                    }

                    foreach (long oid in item.Value)
                    {
                        var feature = layer.Inspect(oid);

                        Geometry geometry = feature.Shape.Clone();
                        Polyline polyLine = GetCutPolyLine(geometry);

                        var splitItems = GeometryEngine.Cut(geometry, polyLine);
                        feature.Shape  = splitItems.First();
                        editOperation.Modify(feature);

                        Layer pointLayer = MapView.Active.Map.Layers[0];
                        editOperation.Create(pointLayer, geometry.Extent.Center);
                    }
                    editOperation.Execute();
                }
                MapView.Active.Map.SetSelection(null);
            });
        }
        // Cuts feature geometries with a user defined cut polyline.
        private async void CutButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                resultGraphics.Graphics.Clear();

                // wait for user to draw cut line
                var cutLine = await mapView.Editor.RequestShapeAsync(DrawShape.Polyline, _cutLineSymbol) as Polyline;

                // get intersecting features from the feature layer
                SpatialQueryFilter filter = new SpatialQueryFilter();
                filter.Geometry            = GeometryEngine.Project(cutLine, _statesLayer.FeatureTable.SpatialReference);
                filter.SpatialRelationship = SpatialRelationship.Crosses;
                filter.MaximumRows         = 52;
                var stateFeatures = await _statesLayer.FeatureTable.QueryAsync(filter);

                // Cut the feature geometries and add to graphics layer
                var states      = stateFeatures.Select(feature => feature.Geometry);
                var cutGraphics = states
                                  .Where(geo => !GeometryEngine.Within(cutLine, geo))
                                  .SelectMany(state => GeometryEngine.Cut(state, cutLine))
                                  .Select(geo => new Graphic(geo, _cutFillSymbol));

                resultGraphics.Graphics.AddRange(cutGraphics);
            }
            catch (TaskCanceledException)
            {
            }
            catch (Exception ex)
            {
                MessageBox.Show("Cut Error: " + ex.Message, "Cut Geometry");
            }
        }
        private async Task DoCutPolygons()
        {
            if (statesOverlay != null && resultsOverlay != null)
            {
                resultsOverlay.Graphics.Clear();

                // Get the user's input
                var cutPolyLine = (await mapView1.Editor.RequestShapeAsync(DrawShape.Polyline)) as Polyline;

                // Normalize for WrapAround
                Polyline polyline = GeometryEngine.NormalizeCentralMeridian(cutPolyLine) as Polyline;

                // Iterate over the graphics in the GraphicsOverlay. If the graphic intersects with the polyline we will cut it
                // and create Graphic objects from the results. Next we add those Graphics resulting to a List<Graphic>.
                List <Graphic> cutGraphics = new List <Graphic>();
                foreach (var g in statesOverlay.Graphics)
                {
                    if (GeometryEngine.Intersects(g.Geometry, polyline))
                    {
                        var cutPolygonGeometries = GeometryEngine.Cut(g.Geometry, polyline);
                        var cutPolygonGraphics   = cutPolygonGeometries.Select(x => new Graphic {
                            Geometry = x
                        });
                        cutGraphics.AddRange(cutPolygonGraphics);
                    }
                }
                // Add the results to the GraphicsOverlay
                resultsOverlay.Graphics.AddRange(cutGraphics);
            }
        }
Beispiel #4
0
        private async Task DoCutPolygons()
        {
            SetupUI();
            if (graphicsLayer != null)
            {
                //Get the user's input
                var cutPolyLine = (await mapView1.Editor.RequestShapeAsync(DrawShape.Polyline)) as Polyline;

                //iterate over the graphics in the graphicsLayer. If the graphic intersects with the polyline we will cut it.
                //and then create Graphic objects from the results. Next we add those Graphics resulting to a new list (finalList).
                //if it doesn't we will add the graphic to the new list (finalList)
                var finalList = graphicsLayer.Graphics.ToList();
                foreach (var g in graphicsLayer.Graphics)
                {
                    if (GeometryEngine.Intersects(g.Geometry, cutPolyLine))
                    {
                        var cutPolygonGeometries = GeometryEngine.Cut(g.Geometry, cutPolyLine);
                        var cutPolygonGraphics   = cutPolygonGeometries.Select(x => new Graphic {
                            Geometry = x
                        });
                        finalList.AddRange(cutPolygonGraphics);
                    }
                    else
                    {
                        finalList.Add(g);
                    }
                }
                //add the results to the graphics layer
                graphicsLayer.Graphics.Clear();
                graphicsLayer.Graphics.AddRange(finalList);
            }
        }
        private void CutButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Cut the polygon geometry with the polyline, expect two geometries.
                Geometry[] cutGeometries = GeometryEngine.Cut(_lakeSuperiorPolygonGraphic.Geometry, (Polyline)_countryBorderPolylineGraphic.Geometry);

                // Create a simple line symbol for the outline of the Canada side of Lake Superior.
                SimpleLineSymbol canadaSideSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Null, System.Drawing.Color.Blue, 0);

                // Create the simple fill symbol for the Canada side of Lake Superior graphic - comprised of a fill style, fill color and outline.
                SimpleFillSymbol canadaSideSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.ForwardDiagonal, System.Drawing.Color.Green, canadaSideSimpleLineSymbol);

                // Create the graphic for the Canada side of Lake Superior - comprised of a polygon shape and fill symbol.
                Graphic canadaSideGraphic = new Graphic(cutGeometries[0], canadaSideSimpleFillSymbol);

                // Add the Canada side of the Lake Superior graphic to the graphics overlay collection.
                _graphicsOverlay.Graphics.Add(canadaSideGraphic);

                // Create a simple line symbol for the outline of the USA side of Lake Superior.
                SimpleLineSymbol usaSideSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Null, System.Drawing.Color.Blue, 0);

                // Create the simple fill symbol for the USA side of Lake Superior graphic - comprised of a fill style, fill color and outline.
                SimpleFillSymbol usaSideSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.ForwardDiagonal, System.Drawing.Color.Yellow, usaSideSimpleLineSymbol);

                // Create the graphic for the USA side of Lake Superior - comprised of a polygon shape and fill symbol.
                Graphic usaSideGraphic = new Graphic(cutGeometries[1], usaSideSimpleFillSymbol);

                // Add the USA side of the Lake Superior graphic to the graphics overlay collection.
                _graphicsOverlay.Graphics.Add(usaSideGraphic);

                // Disable the button after has been used.
                _cutButton.Enabled = false;
            }
            catch (System.Exception ex)
            {
                // Display an error message if there is a problem generating cut operation.
                AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
                alertBuilder.SetTitle("There was a problem cutting the geometry.");
                alertBuilder.SetMessage(ex.ToString());
                alertBuilder.Show();
            }
        }
Beispiel #6
0
        private void CutButton_TouchUpInside(object sender, EventArgs e)
        {
            try
            {
                // Cut the polygon geometry with the polyline, expect two geometries.
                Geometry[] cutGeometries = GeometryEngine.Cut(_lakeSuperiorPolygonGraphic.Geometry, (Polyline)_countryBorderPolylineGraphic.Geometry);

                // Create a simple line symbol for the outline of the Canada side of Lake Superior.
                SimpleLineSymbol canadaSideSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Null, System.Drawing.Color.Blue, 0);

                // Create the simple fill symbol for the Canada side of Lake Superior graphic - comprised of a fill style, fill color and outline.
                SimpleFillSymbol canadaSideSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.ForwardDiagonal, System.Drawing.Color.Green, canadaSideSimpleLineSymbol);

                // Create the graphic for the Canada side of Lake Superior - comprised of a polygon shape and fill symbol.
                Graphic canadaSideGraphic = new Graphic(cutGeometries[0], canadaSideSimpleFillSymbol);

                // Add the Canada side of the Lake Superior graphic to the graphics overlay collection.
                _graphicsOverlay.Graphics.Add(canadaSideGraphic);

                // Create a simple line symbol for the outline of the USA side of Lake Superior.
                SimpleLineSymbol usaSideSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Null, System.Drawing.Color.Blue, 0);

                // Create the simple fill symbol for the USA side of Lake Superior graphic - comprised of a fill style, fill color and outline.
                SimpleFillSymbol usaSideSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.ForwardDiagonal, System.Drawing.Color.Yellow, usaSideSimpleLineSymbol);

                // Create the graphic for the USA side of Lake Superior - comprised of a polygon shape and fill symbol.
                Graphic usaSideGraphic = new Graphic(cutGeometries[1], usaSideSimpleFillSymbol);

                // Add the USA side of the Lake Superior graphic to the graphics overlay collection.
                _graphicsOverlay.Graphics.Add(usaSideGraphic);

                // Disable the button after has been used.
                _cutButton.Enabled = false;
            }
            catch (System.Exception ex)
            {
                // Display an error message if there is a problem generating cut operation.
                UIAlertController alertController = UIAlertController.Create("Geometry Engine Failed!", ex.Message, UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alertController, true, null);
                return;
            }
        }
        private async void CutButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Cut the polygon geometry with the polyline, expect two geometries.
                Geometry[] cutGeometries = GeometryEngine.Cut(_lakeSuperiorPolygonGraphic.Geometry, (Polyline)_countryBorderPolylineGraphic.Geometry);

                // Create a simple line symbol for the outline of the Canada side of Lake Superior.
                SimpleLineSymbol canadaSideSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Null, Windows.UI.Colors.Blue, 0);

                // Create the simple fill symbol for the Canada side of Lake Superior graphic - comprised of a fill style, fill color and outline.
                SimpleFillSymbol canadaSideSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.ForwardDiagonal, Windows.UI.Colors.Green, canadaSideSimpleLineSymbol);

                // Create the graphic for the Canada side of Lake Superior - comprised of a polygon shape and fill symbol.
                Graphic canadaSideGraphic = new Graphic(cutGeometries[0], canadaSideSimpleFillSymbol);

                // Add the Canada side of the Lake Superior graphic to the graphics overlay collection.
                _graphicsOverlay.Graphics.Add(canadaSideGraphic);

                // Create a simple line symbol for the outline of the USA side of Lake Superior.
                SimpleLineSymbol usaSideSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Null, Windows.UI.Colors.Blue, 0);

                // Create the simple fill symbol for the USA side of Lake Superior graphic - comprised of a fill style, fill color and outline.
                SimpleFillSymbol usaSideSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.ForwardDiagonal, Windows.UI.Colors.Yellow, usaSideSimpleLineSymbol);

                // Create the graphic for the USA side of Lake Superior - comprised of a polygon shape and fill symbol.
                Graphic usaSideGraphic = new Graphic(cutGeometries[1], usaSideSimpleFillSymbol);

                // Add the USA side of the Lake Superior graphic to the graphics overlay collection.
                _graphicsOverlay.Graphics.Add(usaSideGraphic);

                // Disable the button after has been used.
                CutButton.IsEnabled = false;
            }
            catch (System.Exception ex)
            {
                // Display an error message if there is a problem generating cut operation.
                MessageDialog theMessageDialog = new MessageDialog("Geometry Engine Failed: " + ex.Message);
                await theMessageDialog.ShowAsync();
            }
        }
        private void CutButton_Clicked(object sender, EventArgs e)
        {
            try
            {
                // Cut the polygon geometry with the polyline, expect two geometries.
                Geometry[] cutGeometries = GeometryEngine.Cut(_lakeSuperiorPolygonGraphic.Geometry, (Polyline)_countryBorderPolylineGraphic.Geometry);

                // Create a simple line symbol for the outline of the Canada side of Lake Superior.
                SimpleLineSymbol canadaSideSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Null, Color.Blue, 0);

                // Create the simple fill symbol for the Canada side of Lake Superior graphic - comprised of a fill style, fill color and outline.
                SimpleFillSymbol canadaSideSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.ForwardDiagonal, Color.Green, canadaSideSimpleLineSymbol);

                // Create the graphic for the Canada side of Lake Superior - comprised of a polygon shape and fill symbol.
                Graphic canadaSideGraphic = new Graphic(cutGeometries[0], canadaSideSimpleFillSymbol);

                // Add the Canada side of the Lake Superior graphic to the graphics overlay collection.
                _graphicsOverlay.Graphics.Add(canadaSideGraphic);

                // Create a simple line symbol for the outline of the USA side of Lake Superior.
                SimpleLineSymbol usaSideSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Null, Color.Blue, 0);

                // Create the simple fill symbol for the USA side of Lake Superior graphic - comprised of a fill style, fill color and outline.
                SimpleFillSymbol usaSideSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.ForwardDiagonal, Color.Yellow, usaSideSimpleLineSymbol);

                // Create the graphic for the USA side of Lake Superior - comprised of a polygon shape and fill symbol.
                Graphic usaSideGraphic = new Graphic(cutGeometries[1], usaSideSimpleFillSymbol);

                // Add the USA side of the Lake Superior graphic to the graphics overlay collection.
                _graphicsOverlay.Graphics.Add(usaSideGraphic);

                // Disable the button after has been used.
                CutButton.IsEnabled = false;
            }
            catch (Exception ex)
            {
                // Display an error message if there is a problem generating cut operation.
                Application.Current.MainPage.DisplayAlert("Geometry Engine Failed", "Error performing cut: " + ex.Message, "OK");
            }
        }
Beispiel #9
0
        // myMapView 事件
        private async void MyMapView_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            IInputElement ie  = (IInputElement)(sender);
            MapPoint      loc = myMapView.ScreenToLocation(e.GetPosition(ie));

            switch (operation)
            {
            case OperateType.DrawPoint:     //画点
                Graphic pt = new Graphic(loc, pointSymbol);
                graphicsLayer.Graphics.Add(pt);
                break;

            case OperateType.DrawPolyline:    //画线
                pointCollection.Add(loc);
                if (pointCollection.Count >= 2)
                {
                    if (pointCollection.Count > 2)
                    {
                        Graphic         g  = graphicsLayer.Graphics[graphicsLayer.Graphics.Count - 1];
                        PolylineBuilder lb = new PolylineBuilder(pointCollection);
                        g.Geometry = lb.ToGeometry();
                    }
                    else
                    {
                        Esri.ArcGISRuntime.Geometry.Polyline l = new Esri.ArcGISRuntime.Geometry.Polyline(pointCollection);
                        Graphic lg = new Graphic(l, lineSymbol);
                        graphicsLayer.Graphics.Add(lg);
                    }
                }
                break;

            case OperateType.DrawPolygon:    //画多边形
                pointCollection.Add(loc);
                if (pointCollection.Count >= 3)
                {
                    if (pointCollection.Count > 3)
                    {
                        Graphic        g  = graphicsLayer.Graphics[graphicsLayer.Graphics.Count - 1];
                        PolygonBuilder pb = new PolygonBuilder(pointCollection);
                        g.Geometry = pb.ToGeometry();
                    }
                    else
                    {
                        Esri.ArcGISRuntime.Geometry.Polygon p = new Esri.ArcGISRuntime.Geometry.Polygon(pointCollection);
                        Graphic pg = new Graphic(p, fillSymbol);
                        graphicsLayer.Graphics.Add(pg);
                    }
                }
                break;

            case OperateType.None:    //缺省状态
                graphicsLayer.ClearSelection();
                IdentifyGraphicsOverlayResult result = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                //选择图形元素
                if (result.Graphics.Count < 1)
                {
                    curSelGraphic = null;
                    EditVertexMenuItem.IsEnabled   = false;
                    UneditVertexMenuItem.IsEnabled = false;
                    return;
                }
                curSelGraphic                = result.Graphics.First();
                curSelGraphic.IsSelected     = true;
                EditVertexMenuItem.IsEnabled = true;
                break;

            case OperateType.Cal_Clip:     //选择图形
                IdentifyGraphicsOverlayResult gResult = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic = gResult.Graphics.First();
                selGraphic.IsSelected = true; listOfClipGraphics.Add(selGraphic); //记录所选图形
                if (listOfClipGraphics.Count == 2)                                //图形数目为2时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    Graphic g2 = listOfClipGraphics[1];
                    if (g1.Geometry.GeometryType != GeometryType.Polygon || g2.Geometry.GeometryType != GeometryType.Polygon)     //如果所选图形不是多边形,则退出
                    {
                        MessageBox.Show("请选择两个多边形图形!");
                        listOfClipGraphics.Clear();
                        graphicsLayer.ClearSelection();
                        return;
                    }
                    Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Clip(g1.Geometry, g2.Geometry.Extent); //执行剪切操作
                    if (resultGeometry != null)                                                                                 //处理结果
                    {
                        graphicsLayer.Graphics.Remove(g1);                                                                      //从图形层中移除原图形
                        graphicsLayer.Graphics.Remove(g2);
                        Graphic clipedGraphic = new Graphic(resultGeometry, fillSymbol);                                        //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic); operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Union:     // 联合
                IdentifyGraphicsOverlayResult gResultUnion = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResultUnion.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphicUnion = gResultUnion.Graphics.First();
                selGraphicUnion.IsSelected = true;
                listOfClipGraphics.Add(selGraphicUnion); //记录所选图形
                if (listOfClipGraphics.Count == 2)       //图形数目为2时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    Graphic g2 = listOfClipGraphics[1];
                    if (g1.Geometry.GeometryType != GeometryType.Polygon || g2.Geometry.GeometryType != GeometryType.Polygon)     //如果所选图形不是多边形,则退出
                    {
                        MessageBox.Show("请选择两个多边形图形!");
                        listOfClipGraphics.Clear();
                        graphicsLayer.ClearSelection();
                        return;
                    }
                    Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Union(g1.Geometry, g2.Geometry.Extent); //执行剪切操作
                    if (resultGeometry != null)                                                                                  //处理结果
                    {
                        graphicsLayer.Graphics.Remove(g1);                                                                       //从图形层中移除原图形
                        graphicsLayer.Graphics.Remove(g2);
                        Graphic clipedGraphic = new Graphic(resultGeometry, fillSymbol);                                         //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic);
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Cut:     // 剪切
                IdentifyGraphicsOverlayResult gResult_Cut = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult_Cut.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic_Cut = gResult_Cut.Graphics.First();
                selGraphic_Cut.IsSelected = true;
                listOfClipGraphics.Add(selGraphic_Cut); //记录所选图形
                if (listOfClipGraphics.Count == 2)      //图形数目为1时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    Graphic g2 = listOfClipGraphics[1];
                    if (g1.Geometry.GeometryType != GeometryType.Polygon || g2.Geometry.GeometryType != GeometryType.Polyline)     //如果所选图形不是多边形,则退出
                    {
                        MessageBox.Show("请先选择一个面要素后再选择一个线要素.");
                        listOfClipGraphics.Clear();
                        graphicsLayer.ClearSelection();
                        return;
                    }
                    Esri.ArcGISRuntime.Geometry.Polyline   polyLine       = (Esri.ArcGISRuntime.Geometry.Polyline)g2.Geometry;
                    Esri.ArcGISRuntime.Geometry.Geometry[] resultGeometry = GeometryEngine.Cut(g1.Geometry, polyLine); //执行剪切操作
                    if (resultGeometry != null)                                                                        //处理结果
                    {
                        graphicsLayer.Graphics.Remove(g1);
                        for (int z = 0; z < resultGeometry.Length; z++)
                        {
                            Graphic clipedGraphic = new Graphic(resultGeometry[z], fillSymbol);     //利 用剪切结果构建新的图形
                            graphicsLayer.Graphics.Add(clipedGraphic);
                        }
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Simplify:     // 拓扑纠正
                IdentifyGraphicsOverlayResult gResult_Simplify = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult_Simplify.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic_Simplify = gResult_Simplify.Graphics.First();
                selGraphic_Simplify.IsSelected = true;
                listOfClipGraphics.Add(selGraphic_Simplify); //记录所选图形
                if (listOfClipGraphics.Count == 1)           //图形数目为1时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    if (g1.Geometry.GeometryType == GeometryType.Point)     //如果所选图形不是多边形,则退出
                    {
                        MessageBox.Show("请先选择一个面要素或线要素.");
                        listOfClipGraphics.Clear();
                        graphicsLayer.ClearSelection();
                        return;
                    }
                    Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Simplify(g1.Geometry); //执行剪切操作
                    if (resultGeometry != null)                                                                 //处理结果
                    {
                        graphicsLayer.Graphics.Remove(g1);                                                      //从图形层中移除原图形
                        Graphic clipedGraphic = new Graphic(resultGeometry, fillSymbol);                        //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic);
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Gene:     // 简化
                IdentifyGraphicsOverlayResult gResult_Gene = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult_Gene.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic_Gene = gResult_Gene.Graphics.First();
                selGraphic_Gene.IsSelected = true;
                listOfClipGraphics.Add(selGraphic_Gene); //记录所选图形
                if (listOfClipGraphics.Count == 1)       //图形数目为1时
                {
                    Graphic g1 = listOfClipGraphics[0];
                    if (g1.Geometry.GeometryType == GeometryType.Point)     //如果所选图形是点,则退出
                    {
                        MessageBox.Show("请先选择一个面要素或线要素.");
                        listOfClipGraphics.Clear();
                        graphicsLayer.ClearSelection();
                        return;
                    }
                    Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Generalize(g1.Geometry, 1000000.0, true); //执行剪切操作
                    if (resultGeometry != null)                                                                                    //处理结果
                    {
                        MessageBox.Show(resultGeometry.ToJson() + "\n" + resultGeometry.GeometryType);
                        graphicsLayer.Graphics.Remove(g1);                               //从图形层中移除原图形
                        Graphic clipedGraphic = new Graphic(resultGeometry, fillSymbol); //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic);
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Buff:     // 缓冲
                IdentifyGraphicsOverlayResult gResult_Buff = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult_Buff.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic_Buff = gResult_Buff.Graphics.First();
                selGraphic_Buff.IsSelected = true;
                listOfClipGraphics.Add(selGraphic_Buff); //记录所选图形
                if (listOfClipGraphics.Count == 1)       //图形数目为1时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Buffer(g1.Geometry, 1000000.0);                                                                                                                           //执行剪切操作
                    if (resultGeometry != null)                                                                                                                                                                                                    //处理结果
                    {
                        graphicsLayer.Graphics.Remove(g1);                                                                                                                                                                                         //从图形层中移除原图形
                        Graphic clipedGraphic = new Graphic(resultGeometry, new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.FromArgb(125, 255, 250, 0), new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.FromArgb(0, 0, 0), 4.0))); //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic);
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Jiaodian:     // 交点
                IdentifyGraphicsOverlayResult gResult_Jiaodian = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult_Jiaodian.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic_Jiaodian = gResult_Jiaodian.Graphics.First();
                selGraphic_Jiaodian.IsSelected = true;
                listOfClipGraphics.Add(selGraphic_Jiaodian); //记录所选图形
                if (listOfClipGraphics.Count == 2)           //图形数目为1时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    Graphic g2 = listOfClipGraphics[1];
                    IReadOnlyList <Geometry> resultGeometry = GeometryEngine.Intersections(g1.Geometry, g2.Geometry); //执行剪切操作
                    if (resultGeometry != null)                                                                       //处理结果
                    {
                        Graphic clipedGraphic = new Graphic(resultGeometry[0], pointSymbol);                          //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic);
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;
            }
        }