protected override Task <bool> OnSketchCompleteAsync(Geometry geometry) { if (Module1.Current.SelectedGraphicsLayerTOC == null) { MessageBox.Show("Select a graphics layer in the TOC", "No graphics layer selected", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Exclamation); return(Task.FromResult(true)); } return(QueuedTask.Run(() => { var lineSketched = geometry as Polyline; //Create MultipPoints from the sketched line var multiPoints = MultipointBuilder.CreateMultipoint(lineSketched); //specify a symbol var point_symbol = SymbolFactory.Instance.ConstructPointSymbol( ColorFactory.Instance.GreenRGB); //create a CIMGraphic using the Multi-points var graphic = new CIMMultipointGraphic { Symbol = point_symbol.MakeSymbolReference(), Multipoint = multiPoints }; //Add the graphic to the layer Module1.Current.SelectedGraphicsLayerTOC.AddElement(graphic); return true; })); }
public void CreateMultiPointGraphics() { var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType <ArcGIS.Desktop.Mapping.GraphicsLayer>().FirstOrDefault(); if (graphicsLayer == null) { return; } QueuedTask.Run(() => { #region Multi-point Graphic Element using CIMGraphic //On the QueuedTask //Place a multipoint graphic using the mapview extent geometry var extent = MapView.Active.Extent; //Contract the extent var polygonEnv = extent.Expand(-100000, -90000, false); //create a polygon using the envelope var polygon = PolygonBuilder.CreatePolygon(polygonEnv); //Create MultipPoints from the polygon var multiPoints = MultipointBuilder.CreateMultipoint(polygon); //specify a symbol var point_symbol = SymbolFactory.Instance.ConstructPointSymbol( ColorFactory.Instance.GreenRGB); //create a CIMGraphic var graphic = new CIMMultipointGraphic { Symbol = point_symbol.MakeSymbolReference(), Multipoint = multiPoints }; graphicsLayer.AddElement(graphic); #endregion }); }
protected override Task <bool> OnSketchCompleteAsync(Geometry geometry) { //var targetGraphicLayers = MapView.Active?.Map.TargetGraphicsLayer; //if (targetGraphicLayers == null) Task.FromResult(true); if (ActiveElementContainer == null) { Task.FromResult(true); } if (Module1.SelectedSymbol == null) { return(Task.FromResult(true)); } return(QueuedTask.Run(() => { var cimGraphic = new CIMMultipointGraphic() { Multipoint = geometry as Multipoint, Symbol = Module1.SelectedSymbol.MakeSymbolReference() }; ElementFactory.Instance.CreateGraphicElement(this.ActiveElementContainer, cimGraphic); return true; })); }