private void ExtractButton_Click(object sender, RoutedEventArgs e) { if (clipByExtent) { GraphicCollection clipGraphics = new GraphicCollection(); clipGraphics.Add(new Graphic() { Geometry = GeometryTool.EnvelopeToPolygon(this.MapControl.Extent) }); CreateGPParamsAndExtract(clipGraphics); } else { if (needGeneralized) { GeneralizeParameters genParam = new GeneralizeParameters() { DeviationUnit = LinearUnit.Meter, MaxDeviation = 10 }; geometryService.GeneralizeAsync(this.GraphicsLayer.Graphics, genParam); } else { CreateGPParamsAndExtract(this.GraphicsLayer.Graphics); } } }
private void DrawObject_DrawComplete(object sender, DrawEventArgs e) { if (this.DrawWidget == this.GetType()) { Graphic graphic = null; if (this.drawMode == "Freepoly") { // Geometry needs to be simplified needGeneralized = true; // Create a Graphic with the newly closed Polygon graphic = new ESRI.ArcGIS.Client.Graphic() { Geometry = GeometryTool.FreehandToPolygon(e.Geometry as Polyline), Symbol = this.CurrentApp.Resources[SymbolResources.DRAW_FILL] as FillSymbol }; } else { // Create a Graphic with the drawn geometry graphic = new ESRI.ArcGIS.Client.Graphic(); graphic.Symbol = this.CurrentApp.Resources[SymbolResources.DRAW_FILL] as FillSymbol; switch (e.Geometry.GetType().Name) { case "Envelope": graphic.Geometry = GeometryTool.EnvelopeToPolygon(e.Geometry as Envelope); break; case "Polygon": graphic.Geometry = e.Geometry; break; } } if (graphic != null) { this.AddGraphic(graphic); } } }