public static GraphicCollection LoadGraphics( gpxType source ) { source.RequireArgument<gpxType>( "source" ).NotNull<gpxType>(); GraphicCollection graphics = new GraphicCollection(); if( source == null ) return graphics; if( source.wpt != null ) { GraphicCollection gcs = LoadWayPoints( source.wpt ); gcs.ForEach<Graphic>( g => graphics.Add(g) ); } if( source.rte != null ) { GraphicCollection gcs = LoadRoutes( source.rte ); gcs.ForEach<Graphic>( g => graphics.Add(g) ); } if( source.trk != null ) { GraphicCollection gcs = LoadTracks( source.trk ); gcs.ForEach<Graphic>( g => graphics.Add( g ) ); } return graphics; }
private void OnView_Tapped(object sender, Esri.ArcGISRuntime.UI.GeoViewInputEventArgs e) { MapPoint geoPoint = getGeoPoint(e); geoPoint = (MapPoint)GeometryEngine.Project(geoPoint, SpatialReference.Create(3857)); Polygon buffer = (Polygon)GeometryEngine.Buffer(geoPoint, 1000.0); GraphicCollection graphics = (threeD ? bufferAndQuerySceneGraphics : bufferAndQueryMapGraphics).Graphics; graphics.Clear(); graphics.Add(new Graphic(buffer, BUFFER_SYMBOL)); graphics.Add(new Graphic(geoPoint, CLICK_SYMBOL)); Esri.ArcGISRuntime.Data.QueryParameters query = new Esri.ArcGISRuntime.Data.QueryParameters(); query.Geometry = buffer; LayerCollection operationalLayers; if (threeD) { operationalLayers = sceneView.Scene.OperationalLayers; } else { operationalLayers = mapView.Map.OperationalLayers; } foreach (Layer layer in operationalLayers) { ((FeatureLayer)layer).SelectFeaturesAsync(query, SelectionMode.New); } }
private void AddTissueLayers(VolumePresentationImage image) { GraphicCollection layers = image.TissueLayers; TissueSettings tissue = new TissueSettings(); tissue.SelectPreset("Bone"); layers.Add(new VolumeGraphic(tissue)); tissue = new TissueSettings(); tissue.SelectPreset("Blood"); layers.Add(new VolumeGraphic(tissue)); }
/// <summary> /// Creates and displays a <see cref="ProgressGraphic"/>. /// </summary> /// <remarks> /// This method will invoke the graphic's <see cref="IDrawable.Draw"/> method, so do not call it from a draw routine in the same scene graph! /// </remarks> /// <param name="source">The source from which progress information is retrieved and displayed.</param> /// <param name="parentCollection">The graphics collection on which the progress graphic should be shown.</param> /// <param name="autoClose">A value indicating whether or not the progress graphic should be automatically removed when the task is terminated.</param> /// <param name="progressBarGraphicStyle">The style of the progress bar.</param> public static void Show(IProgressGraphicProgressProvider source, GraphicCollection parentCollection, bool autoClose, ProgressBarGraphicStyle progressBarGraphicStyle) { ProgressGraphic progressGraphic = new ProgressGraphic(source, autoClose, progressBarGraphicStyle); parentCollection.Add(progressGraphic); progressGraphic.Draw(); }
private async void Load3DPolygonLayer(object parameter) { try { var queryTask = new QueryTask(new Uri("http://119.2.29.21:6080/arcgis/rest/services/ChinaMap/MapServer/0")); Query query = new Query("1=1"); query.OutFields.Add("POPU");//人口数 var result = await queryTask.ExecuteAsync(query); var res = new GraphicCollection(); foreach (var state in result.FeatureSet.Features) { res.Add(new Graphic(state.Geometry, state.Attributes)); } var graphicLayer = new GraphicsLayer(); graphicLayer.DisplayName = "3D面图层"; graphicLayer.GraphicsSource = res; graphicLayer.Renderer = App.Current.Resources["3DPolygonRenderer"] as Renderer; graphicLayer.SceneProperties.SurfacePlacement = SurfacePlacement.Relative; graphicLayer.ID = "3DPolygonLayer"; scene.Layers.Add(graphicLayer); } catch (Exception ex) { MessageBox.Show(ex.Message, "Sample Error"); } }
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); } } }
// Draw horizontal distributed load // Note: x1<x2, (x1,y1)-(x2,y1) is a horizontal line, (x1,y2)-(x2,y3) is a oblique line // public static GraphicCollection DistributedLoad_Horizontal(double x1, double x2, double y1, double y2, double y3, Symbol backgroundFillSymbol, Symbol arrowFillSymbol, Symbol lineSymbol) { GraphicCollection gc = new GraphicCollection(); MapPoint p1 = new MapPoint(x1, y1); MapPoint p2 = new MapPoint(x1, y2); MapPoint p3 = new MapPoint(x2, y3); MapPoint p4 = new MapPoint(x2, y1); Graphic g = ArcGISMappingUtility.NewQuadrilateral(p1, p2, p3, p4); g.Symbol = backgroundFillSymbol; gc.Add(g); Esri.ArcGISRuntime.Geometry.PointCollection pc = new Esri.ArcGISRuntime.Geometry.PointCollection(); pc.Add(p1); pc.Add(p2); pc.Add(p3); pc.Add(p4); pc.Add(p1); g = ArcGISMappingUtility.NewPolyline(pc); g.Symbol = lineSymbol; gc.Add(g); double x00, y00, y01; for (int i = 0; i <= 10; ++i) { x00 = x1 + i * (x2 - x1) / 10.0; y00 = y1; y01 = y2 + i * (y3 - y2) / 10.0; MapPoint p00 = new MapPoint(x00, y00); MapPoint p01 = new MapPoint(x00, y01); g = ArcGISMappingUtility.NewLine(p00, p01); g.Symbol = lineSymbol; gc.Add(g); pc = ArcGISMappingUtility.VectorArrowPoints(x00, y2, p00); g = ArcGISMappingUtility.NewPolygon(pc); g.Symbol = arrowFillSymbol; gc.Add(g); } return(gc); }
private void Initialize() { // Create a map with a topographic basemap. Map theMap = new Map(Basemap.CreateTopographic()); // Assign the map to the MapView. MyMapView.Map = theMap; // Create a simple fill symbol - used to render a polygon covering Colorado. SimpleFillSymbol theSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Cross, System.Drawing.Color.Blue, null); // Create a simple line symbol - used to render a polyline border between California and Nevada. SimpleLineSymbol theSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Blue, 3); // Create a simple marker symbol - used to render multi-points for various state capital locations in the Western United States. SimpleMarkerSymbol theSimpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Triangle, System.Drawing.Color.Blue, 14); // Create a simple marker symbol - used to render a map point where the Esri headquarters is located. SimpleMarkerSymbol theSimpleMarkerSymbol2 = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Diamond, System.Drawing.Color.Red, 18); // Create a graphics overlay to hold the various graphics. GraphicsOverlay theGraphicsOverlays = new GraphicsOverlay(); // Get the graphic collection from the graphics overlay. GraphicCollection theGraphicCollection = theGraphicsOverlays.Graphics; // Add a graphic to the graphic collection - polygon with a simple fill symbol. theGraphicCollection.Add(new Graphic(CreatePolygon(), theSimpleFillSymbol)); // Add a graphic to the graphic collection - polyline with a simple line symbol. theGraphicCollection.Add(new Graphic(CreatePolyline(), theSimpleLineSymbol)); // Add a graphic to the graphic collection - map point with a simple marker symbol. theGraphicCollection.Add(new Graphic(CreateMapPoint(), theSimpleMarkerSymbol2)); // Add a graphic to the graphic collection - multi-point with a simple marker symbol. theGraphicCollection.Add(new Graphic(CreateMultipoint(), theSimpleMarkerSymbol)); // Set the map views graphics overlay to the created graphics overlay. MyMapView.GraphicsOverlays.Add(theGraphicsOverlays); // Zoom to the extent of an envelope with some padding (10 pixels). MyMapView.SetViewpointGeometryAsync(CreateEnvelope(), 10); }
public static void Show(IProgressGraphicProgressProvider source, GraphicCollection parentCollection, bool autoClose = _defaultAutoClose, ProgressBarGraphicStyle progressBarStyle = _defaultStyle, bool drawImmediately = _defaultDrawImmediately) { ProgressGraphic progressGraphic = new ProgressGraphic(source, autoClose, progressBarStyle); parentCollection.Add(progressGraphic); if (drawImmediately) { progressGraphic.Draw(); } }
/// <summary> /// 地图边界盒改变,进行聚合操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Map_ExtentChanged(object sender, EventArgs e) { if (!IsCluster) { return; } if (Math.Abs(_lastScale - MapObj.MapView.Scale) < 0.001) { return; } _lastScale = MapObj.MapView.Scale; if (_originalGraphics == null) { _originalGraphics = new GraphicCollection(); foreach (var g in Graphics) { _originalGraphics.Add(new Graphic(g.Geometry, g.Attributes, g.Symbol)); } } Graphics.Clear(); var cs = new List <ClusterItem>(); foreach (var g in _originalGraphics) { if (!(g.Geometry is MapPoint)) { continue; } if (((MapPoint)g.Geometry).X < MapObj.MapView.Extent.XMin || ((MapPoint)g.Geometry).X > MapObj.MapView.Extent.XMax || ((MapPoint)g.Geometry).Y < MapObj.MapView.Extent.YMin || ((MapPoint)g.Geometry).Y > MapObj.MapView.Extent.YMax) { continue; } cs.Add(new ClusterItem(MapObj.MapView, g, _originalGraphics.Count)); } //如果地图已经放到最大那么就不再聚合 if (MapObj.TiledInfo != null && MapObj.TiledInfo.Lods.Count > 0 && Math.Abs(MapObj.TiledInfo.Lods[MapObj.TiledInfo.Lods.Count - 1].Scale - MapObj.MapView.Scale) < 0.001) { foreach (var ci in cs) { Graphics.Add(ci.GetGraphic()); } return; } _clusterThread?.Abort(); _clusterThread = new Thread(DoCluster); _clusterThread.Start(cs); }
private void geometryService_GeneralizeCompleted(object sender, GraphicsEventArgs e) { if (e.Results != null && e.Results.Count > 0) { GraphicCollection clipGraphics = new GraphicCollection(); foreach (Graphic graphic in e.Results) { clipGraphics.Add(graphic); } CreateGPParamsAndExtract(clipGraphics); } }
public static GraphicCollection LoadTracks( trkTypeCollection trks ) { trks.RequireArgument<trkTypeCollection>( "trks" ).NotNull<trkTypeCollection>(); GraphicCollection lines = new GraphicCollection(); foreach( var trk in trks ) { Graphic gr = new Graphic(); gr.Geometry = LoadTrack(trk.trkseg); LoadTrackAttributes( trk, gr.Attributes ); lines.Add( gr ); } return lines; }
/// <summary> /// Clone Map Layers /// </summary> private Layer CloneLayer(Layer layer) { Layer toLayer = null; if (layer is GraphicsLayer) // Include FeatureLayer and GeoRSS layers { GraphicsLayer fromLayer = layer as GraphicsLayer; GraphicsLayer printLayer = new GraphicsLayer(); printLayer.Renderer = fromLayer.Renderer; printLayer.Clusterer = fromLayer.Clusterer; // todo : clone ? GraphicCollection graphicCollection = new GraphicCollection(); foreach (Graphic graphic in fromLayer.Graphics) { Graphic clone = new Graphic(); foreach (var kvp in graphic.Attributes) { clone.Attributes.Add(kvp); } clone.Geometry = graphic.Geometry; clone.Symbol = graphic.Symbol; clone.Selected = graphic.Selected; clone.TimeExtent = graphic.TimeExtent; graphicCollection.Add(clone); } printLayer.Graphics = graphicCollection; toLayer = printLayer; toLayer.ID = layer.ID; toLayer.Opacity = layer.Opacity; toLayer.Visible = layer.Visible; toLayer.MaximumResolution = layer.MaximumResolution; toLayer.MinimumResolution = layer.MinimumResolution; } else { // Clone other layer types toLayer = layer.Clone(); } return(toLayer); }
/// <summary> /// Gets the DICOM graphics plane of the specified DICOM presentation image. /// </summary> /// <param name="dicomPresentationImage">The target DICOM presentation image.</param> /// <param name="createIfNecessary">A value indicating if a DICOM graphics plane should be automatically created and associated with the presentation image.</param> /// <returns>The DICOM graphics plane associated with the specified presentation image, or null if one doesn't exist and was not created.</returns> public static DicomGraphicsPlane GetDicomGraphicsPlane(IDicomPresentationImage dicomPresentationImage, bool createIfNecessary) { if (dicomPresentationImage == null) { return(null); } GraphicCollection dicomGraphics = dicomPresentationImage.DicomGraphics; DicomGraphicsPlane dicomGraphicsPlane = dicomGraphics.FirstOrDefault(IsType <DicomGraphicsPlane>) as DicomGraphicsPlane; if (dicomGraphicsPlane == null && createIfNecessary) { dicomGraphics.Add(dicomGraphicsPlane = new DicomGraphicsPlane()); } return(dicomGraphicsPlane); }
internal static void CopyGraphics(System.Collections.Generic.IList <Graphic> fromCollection, GraphicCollection toCollection) { // copy all graphics foreach (Graphic featureGraphic in fromCollection) { Graphic graphic = new Graphic(); foreach (String attributeName in featureGraphic.Attributes.Keys) { graphic.Attributes[attributeName] = featureGraphic.Attributes[attributeName]; } graphic.Geometry = featureGraphic.Geometry; graphic.Symbol = featureGraphic.Symbol; toCollection.Add(graphic); } }
private static ColorBarCompositeGraphic GetCompositeColorBarGraphic(IPresentationImage image, bool createIfNull) { if (image is IColorMapProvider && image is IApplicationGraphicsProvider) { GraphicCollection applicationGraphics = ((IApplicationGraphicsProvider)image).ApplicationGraphics; ColorBarCompositeGraphic graphic = (ColorBarCompositeGraphic)CollectionUtils.SelectFirst(applicationGraphics, g => g is ColorBarCompositeGraphic); if (graphic == null && createIfNull) { applicationGraphics.Add(graphic = new ColorBarCompositeGraphic()); } return(graphic); } return(null); }
private void DoFlash(IPresentationImage image, SynchronizationContext syncContext, string message) { if (!(image is IOverlayGraphicsProvider)) { return; } GraphicCollection overlayGraphics = ((IOverlayGraphicsProvider)image).OverlayGraphics; // Prevent multiple flash graphics per image. var existing = overlayGraphics.OfType <FlashOverlayGraphic>().FirstOrDefault(g => g.Controller == this); if (existing != null) { return; } // Very little utility in flashing if nobody's looking at it. if (syncContext == null) { return; } var flashOverlayGraphic = new FlashOverlayGraphic(this, message); overlayGraphics.Add(flashOverlayGraphic); image.Draw(); ThreadPool.QueueUserWorkItem( delegate { Thread.Sleep(FlashSpeed); syncContext.Post(delegate { if (flashOverlayGraphic.IsDisposed) { return; } overlayGraphics.Remove(flashOverlayGraphic); image.Draw(); }, null); }, null); }
void Graphics_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) { if (e.NewItems != null) { GraphicCollection newGraphics = new GraphicCollection(); foreach (Graphic newGraphic in e.NewItems) { newGraphics.Add(newGraphic); } OnGraphicsCreated(newGraphics, false, null); } } else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset) { Graphics.Clear(); } }
private async void Initialize() { try { CreateExtrusionInfos(); // Set initial viewpoint var viewpoint = new ViewpointCenter(new MapPoint(-96, 39), 15000000); await MySceneView.SetViewAsync(viewpoint); // Query states with statistical attributes var queryTask = new QueryTask( new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5")); Query query = new Query("1=1"); query.OutFields.Add("STATE_NAME"); query.OutFields.Add("AGE_5_17"); query.OutFields.Add("AGE_18_21"); query.OutFields.Add("AGE_22_29"); query.OutFields.Add("AGE_30_39"); query.OutFields.Add("AGE_40_49"); query.OutFields.Add("AGE_50_64"); query.OutFields.Add("AGE_65_UP"); var result = await queryTask.ExecuteAsync(query); var states = new GraphicCollection(); foreach (var state in result.FeatureSet.Features) { states.Add(new Graphic(state.Geometry, state.Attributes)); } // Make sure that all layers are loaded await MySceneView.LayersLoadedAsync(); // Set graphics to the overlay var statesOverlay = MySceneView.GraphicsOverlays["statesOverlay"]; statesOverlay.GraphicsSource = states; } catch (Exception ex) { MessageBox.Show(ex.Message, "Graphics Extrusion Sample"); } }
public static ESRI.ArcGIS.Client.GraphicsLayer CreateSearchLyr(ESRI.ArcGIS.Client.Geometry.Geometry mp) { ESRI.ArcGIS.Client.GraphicsLayer gl = new GraphicsLayer(); ESRI.ArcGIS.Client.GraphicCollection listGc = new GraphicCollection(); ESRI.ArcGIS.Client.Graphic gp = new Graphic() { Geometry = mp }; listGc.Add(gp); gl.ID = "SearchLyr"; gl.Graphics = listGc; ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol skb = new ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol(); skb.Color = Brushes.Red; skb.Size = 15; var render = new SimpleRenderer(); render.Symbol = skb; gl.Renderer = render as IRenderer; return gl; }
private async void Initialize() { try { CreateExtrusionInfos(); // Set initial viewpoint var viewpoint = new ViewpointCenter(new MapPoint(-96, 39), 15000000); await MySceneView.SetViewAsync(viewpoint); // Query states with statistical attributes var queryTask = new QueryTask( new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5")); Query query = new Query("1=1"); query.OutFields.Add("STATE_NAME"); query.OutFields.Add("AGE_5_17"); query.OutFields.Add("AGE_18_21"); query.OutFields.Add("AGE_22_29"); query.OutFields.Add("AGE_30_39"); query.OutFields.Add("AGE_40_49"); query.OutFields.Add("AGE_50_64"); query.OutFields.Add("AGE_65_UP"); var result = await queryTask.ExecuteAsync(query); var states = new GraphicCollection(); foreach (var state in result.FeatureSet.Features) states.Add(new Graphic(state.Geometry, state.Attributes)); // Make sure that all layers are loaded await MySceneView.LayersLoadedAsync(); // Set graphics to the overlay var statesOverlay = MySceneView.GraphicsOverlays["statesOverlay"]; statesOverlay.GraphicsSource = states; } catch (Exception ex) { MessageBox.Show(ex.Message, "Graphics Extrusion Sample"); } }
private void RadioButton_Checked(object sender, RoutedEventArgs e) { ClearAll(); string shapeTag = (string)((RadioButton)sender).Tag; switch (shapeTag) { case "Point": GraphicCollection absoluteGC = new GraphicCollection(); GraphicCollection relativeGC = new GraphicCollection(); GraphicCollection drapedGC = new GraphicCollection(); foreach (MapPoint mp in _coordinates) { absoluteGC.Add(new Graphic(mp, GetPointSymbol(SurfacePlacement.Absolute))); relativeGC.Add(new Graphic(mp, GetPointSymbol(SurfacePlacement.Relative))); drapedGC.Add(new Graphic(mp, GetPointSymbol(SurfacePlacement.Draped))); } _absoluteModeGL.Graphics.AddRange(absoluteGC); _relativeModeGL.Graphics.AddRange(relativeGC); _drapedModeGL.Graphics.AddRange(drapedGC); break; case "Line": var line = new Polyline(_coordinates, SpatialReferences.Wgs84); _absoluteModeGL.Graphics.Add(new Graphic(line, GetPolylineSymbol(SurfacePlacement.Absolute))); _relativeModeGL.Graphics.Add(new Graphic(line, GetPolylineSymbol(SurfacePlacement.Relative))); _drapedModeGL.Graphics.Add(new Graphic(line, GetPolylineSymbol(SurfacePlacement.Draped))); break; case "Polygon": var polygon = new Polygon(_coordinates, SpatialReferences.Wgs84); _absoluteModeGL.Graphics.Add(new Graphic(polygon, GetPolygonSymbol(SurfacePlacement.Absolute))); _relativeModeGL.Graphics.Add(new Graphic(polygon, GetPolygonSymbol(SurfacePlacement.Relative))); _drapedModeGL.Graphics.Add(new Graphic(polygon, GetPolygonSymbol(SurfacePlacement.Draped))); break; } }
public IEnumerable <Graphic> removeSelectedDrawingObjects( GraphicsLayer drawingLayer) { if (drawingLayer.SelectedGraphics.Count() == 0) { return(null); } GraphicCollection gc = new GraphicCollection(); foreach (Graphic g in drawingLayer.Graphics) { if (g.IsSelected) { gc.Add(g); } } foreach (Graphic g in gc) { drawingLayer.Graphics.Remove(g); } return(gc); }
/// <summary> /// Creates graphic elements and adds them to the graphics layer. /// </summary> /// <param name="layer">Graphics layer that will have features added to it.</param> /// <param name="images">Dictionary of images coming from kmz content or from previous parsing</param> public void CreateGraphics(KmlGraphicsLayer layer, IDictionary<string, ImageBrush> images) { if (layer == null) return; GraphicCollection graphics = new GraphicCollection(); UniqueValueRenderer renderer = new UniqueValueRenderer(); // dummy renderer used to create the legend items (since creation of the swatches from the symbol is not that obvious) // Process each metadata feature in the list foreach (PlacemarkDescriptor feature in placemarks) { KMLStyle style = feature.Symbol.style; if (style.ZipFile != null) { // Look for the image in the zip file if (style.IconImage == null && !String.IsNullOrEmpty(style.IconHref)) { style.IconImage = GetIconImage(style.ZipFile, style.IconHref.ToLower()); } style.ZipFile.Dispose(); style.ZipFile = null; } // If the style has an HREF then it is associated with an image if (style.IconImage == null && !String.IsNullOrEmpty(style.IconHref)) { // If the image is already loaded in the image dictionary, use it if (images.ContainsKey(style.IconHref.ToLower())) style.IconImage = images[style.IconHref.ToLower()]; else { // Get the image using the HREF and store the image in the images dictionary so that if // other features reference it, it is cached style.IconImage = GetIconImage(style.IconHref); images.Add(style.IconHref.ToLower(), style.IconImage); } } // Create a new graphic from the metadata and construct the symbol using polymorphism Graphic g = new Graphic() { Geometry = feature.Geometry, Symbol = feature.Symbol.CreateSymbol() }; // Create legend entry string label = null; string description = null; if (string.IsNullOrEmpty(style.StyleId)) { //if the feature is not using a shared style -> create an entry by graphic with the name as ident if (feature.Attributes.ContainsKey("name")) label = feature.Attributes["name"].ToString(); if (feature.Attributes.ContainsKey("description")) description = feature.Attributes["description"].ToString(); } else { //if the feature is using a shared style -> create an entry for the style label = style.StyleId; } if (!string.IsNullOrEmpty(label) && !renderer.Infos.Any(info => info.Label == label)) renderer.Infos.Add(new UniqueValueInfo { Label = label, Description = description, Symbol = g.Symbol }); // Adjust and assign picture marker symbol properties if (g.Geometry is ESRI.ArcGIS.Client.Geometry.MapPoint && g.Symbol is KmlPlaceMarkerSymbol) { try { #if SILVERLIGHT string ext = style.IconHref.Substring(style.IconHref.LastIndexOf(".")).ToLower(); switch (ext) { case ".jpg": case ".jpeg": case ".png": break; default: throw new System.Exception(string.Format(Properties.Resources.FeatureDefinition_ImageTypeNotSupported, ext)); } #endif KmlPlaceMarkerSymbol ms = g.Symbol as KmlPlaceMarkerSymbol; // To match sizing of Google Earth, default size of point images is 40x40 ms.Height = 40; ms.Width = 40; ms.Fill = style.IconImage as ImageBrush; // Default to half the pixel size (width and height) if symbol offsets are 0 (supported in wpf and sl3) ImageBrush ib = ms.Fill; BitmapImage bi = ib.ImageSource as BitmapImage; #if SILVERLIGHT if (bi.PixelHeight == 0 || bi.PixelWidth == 0) { EventHandler<RoutedEventArgs> completed = null; completed = (s, e) => { bi.ImageOpened -= completed; ComputeIconTranslationValues(style, ms, bi); }; bi.ImageOpened += completed; } #else if (bi.IsDownloading) { EventHandler completed = null; completed = (s, e) => { bi.DownloadCompleted -= completed; ComputeIconTranslationValues(style, ms, bi); }; bi.DownloadCompleted += completed; } #endif else { ComputeIconTranslationValues(style, ms, bi); } } catch { g.Symbol = new SimpleMarkerSymbol(); } } // Copy attributes values from metadata to graphic foreach (var attribute in feature.Attributes) { g.Attributes.Add(attribute.Key, attribute.Value); } // If the balloontext property has been assigned a value in the style associated with this // graphic feature, then add it to the attributes collection. if (!String.IsNullOrEmpty(style.BalloonText)) { g.Attributes.Add("balloonText", style.BalloonText); } // Add graphic to graphics layer graphics.Add(g); } layer.Graphics = graphics; // Use the renderer to create the legend itens (asynchronously since creating a swatch from a symbol is asynchronous) renderer.QueryLegendInfos(layerLegendInfo => { layer.LegendInfo = layerLegendInfo;}, null); }
private void RadioButton_Click(object sender, RoutedEventArgs e) { // Clear all existing graphics var graphicLayers = MySceneView.Scene.Layers.OfType<GraphicsLayer>(); foreach (GraphicsLayer gl in graphicLayers) gl.Graphics.Clear(); string shapeTag = (string)((RadioButton)sender).Tag; switch (shapeTag) { case "Point": // Add coordinates to all graphics layers using GraphicCollection and populate the data GraphicCollection absoluteCollection = new GraphicCollection(); GraphicCollection relativeCollection = new GraphicCollection(); GraphicCollection drapedCollection = new GraphicCollection(); foreach (MapPoint point in _coordinates) { // Use graphics with different ElevationModes absoluteCollection.Add(new Graphic(point, GetPointSymbol(SurfacePlacement.Absolute))); relativeCollection.Add(new Graphic(point, GetPointSymbol(SurfacePlacement.Relative))); drapedCollection.Add(new Graphic(point, GetPointSymbol(SurfacePlacement.Draped))); } _absoluteGraphicsLayer.Graphics.AddRange(absoluteCollection); _drapedGraphicsLayer.Graphics.AddRange(drapedCollection); _relativeGraphicsLayer.Graphics.AddRange(relativeCollection); break; case "Line": // Create polylines with different ElevationModes var line = new Polyline(_coordinates, SpatialReferences.Wgs84); _absoluteGraphicsLayer.Graphics.Add( new Graphic( line, GetPolylineSymbol(SurfacePlacement.Absolute))); _drapedGraphicsLayer.Graphics.Add( new Graphic( line, GetPolylineSymbol(SurfacePlacement.Draped))); _relativeGraphicsLayer.Graphics.Add( new Graphic( line, GetPolylineSymbol(SurfacePlacement.Relative))); break; case "Polygon": // Create polygons using different ElevationModes var polygon = new Polygon(_coordinates, SpatialReferences.Wgs84); _absoluteGraphicsLayer.Graphics.Add( new Graphic(polygon, GetPolygonSymbol(SurfacePlacement.Absolute))); _drapedGraphicsLayer.Graphics.Add( new Graphic(polygon, GetPolygonSymbol(SurfacePlacement.Draped))); _relativeGraphicsLayer.Graphics.Add( new Graphic(polygon, GetPolygonSymbol(SurfacePlacement.Relative))); break; } }
private void RadioButton_Click(object sender, RoutedEventArgs e) { // Clear all existing graphics var graphicLayers = MySceneView.Scene.Layers.OfType <GraphicsLayer>(); foreach (GraphicsLayer gl in graphicLayers) { gl.Graphics.Clear(); } string shapeTag = (string)((RadioButton)sender).Tag; switch (shapeTag) { case "Point": // Add coordinates to all graphics layers using GraphicCollection and populate the data GraphicCollection absoluteCollection = new GraphicCollection(); GraphicCollection relativeCollection = new GraphicCollection(); GraphicCollection drapedCollection = new GraphicCollection(); foreach (MapPoint point in _coordinates) { // Use graphics with different ElevationModes absoluteCollection.Add(new Graphic(point, GetPointSymbol(SurfacePlacement.Absolute))); relativeCollection.Add(new Graphic(point, GetPointSymbol(SurfacePlacement.Relative))); drapedCollection.Add(new Graphic(point, GetPointSymbol(SurfacePlacement.Draped))); } _absoluteGraphicsLayer.Graphics.AddRange(absoluteCollection); _drapedGraphicsLayer.Graphics.AddRange(drapedCollection); _relativeGraphicsLayer.Graphics.AddRange(relativeCollection); break; case "Line": // Create polylines with different ElevationModes var line = new Polyline(_coordinates, SpatialReferences.Wgs84); _absoluteGraphicsLayer.Graphics.Add( new Graphic( line, GetPolylineSymbol(SurfacePlacement.Absolute))); _drapedGraphicsLayer.Graphics.Add( new Graphic( line, GetPolylineSymbol(SurfacePlacement.Draped))); _relativeGraphicsLayer.Graphics.Add( new Graphic( line, GetPolylineSymbol(SurfacePlacement.Relative))); break; case "Polygon": // Create polygons using different ElevationModes var polygon = new Polygon(_coordinates, SpatialReferences.Wgs84); _absoluteGraphicsLayer.Graphics.Add( new Graphic(polygon, GetPolygonSymbol(SurfacePlacement.Absolute))); _drapedGraphicsLayer.Graphics.Add( new Graphic(polygon, GetPolygonSymbol(SurfacePlacement.Draped))); _relativeGraphicsLayer.Graphics.Add( new Graphic(polygon, GetPolygonSymbol(SurfacePlacement.Relative))); break; } }
public IEnumerable<Graphic> removeSelectedDrawingObjects( GraphicsLayer drawingLayer) { if (drawingLayer.SelectedGraphics.Count() == 0) return null; GraphicCollection gc = new GraphicCollection(); foreach (Graphic g in drawingLayer.Graphics) { if (g.IsSelected) gc.Add(g); } foreach (Graphic g in gc) drawingLayer.Graphics.Remove(g); return gc; }
private void LoadRoutes( rteTypeCollection rtes, GraphicCollection graphics ) { rtes.RequireArgument<rteTypeCollection>( "rtes" ).NotNull<rteTypeCollection>(); foreach( var rte in rtes ) { Graphic gr = new Graphic() { Geometry = LoadRoute(rte.rtept) }; LoadRouteAttributes(rte, gr.Attributes); gr.Symbol = Renderer.GetSymbol( gr ); graphics.Add( gr ); } }
private void LoadTracks( trkTypeCollection trks, GraphicCollection graphics ) { trks.RequireArgument<trkTypeCollection>( "trks" ).NotNull<trkTypeCollection>(); foreach( var trk in trks ) { Graphic gr = new Graphic() { Geometry = LoadTrack(trk.trkseg) }; LoadTrackAttributes(trk, gr.Attributes); gr.Symbol = Renderer.GetSymbol( gr ); graphics.Add( gr ); } }
private async void Load3DPolygonLayer(object parameter) { try { var queryTask = new QueryTask(new Uri("http://119.2.29.21:6080/arcgis/rest/services/ChinaMap/MapServer/0")); Query query = new Query("1=1"); query.OutFields.Add("POPU");//人口数 var result = await queryTask.ExecuteAsync(query); var res = new GraphicCollection(); foreach (var state in result.FeatureSet.Features) res.Add(new Graphic(state.Geometry, state.Attributes)); var graphicLayer = new GraphicsLayer(); graphicLayer.DisplayName = "3D面图层"; graphicLayer.GraphicsSource = res; graphicLayer.Renderer = App.Current.Resources["3DPolygonRenderer"] as Renderer; graphicLayer.SceneProperties.SurfacePlacement = SurfacePlacement.Relative; graphicLayer.ID = "3DPolygonLayer"; scene.Layers.Add(graphicLayer); } catch (Exception ex) { MessageBox.Show(ex.Message, "Sample Error"); } }
// Clone a Layer private static Layer CloneLayer(Layer layer) { Layer toLayer; var featureLayer = layer as FeatureLayer; if (layer is GraphicsLayer && (featureLayer == null || featureLayer.Url == null || featureLayer.Mode != FeatureLayer.QueryMode.OnDemand)) { // Clone the layer and the graphics var fromLayer = layer as GraphicsLayer; var printLayer = new GraphicsLayer { Renderer = fromLayer.Renderer, Clusterer = fromLayer.Clusterer == null ? null : fromLayer.Clusterer.Clone(), ShowLegend = fromLayer.ShowLegend, RendererTakesPrecedence = fromLayer.RendererTakesPrecedence, ProjectionService = fromLayer.ProjectionService }; toLayer = printLayer; var graphicCollection = new GraphicCollection(); foreach (var graphic in fromLayer.Graphics) { var clone = new Graphic(); foreach (var kvp in graphic.Attributes) { if (kvp.Value is DependencyObject) { // If the attribute is a dependency object --> clone it var clonedkvp = new KeyValuePair <string, object>(kvp.Key, (kvp.Value as DependencyObject).Clone()); clone.Attributes.Add(clonedkvp); } else { clone.Attributes.Add(kvp); } } clone.Geometry = graphic.Geometry; clone.Symbol = graphic.Symbol; clone.Selected = graphic.Selected; clone.TimeExtent = graphic.TimeExtent; graphicCollection.Add(clone); } printLayer.Graphics = graphicCollection; toLayer.ID = layer.ID; toLayer.Opacity = layer.Opacity; toLayer.Visible = layer.Visible; toLayer.MaximumResolution = layer.MaximumResolution; toLayer.MinimumResolution = layer.MinimumResolution; } else { // Clone other layer types toLayer = layer.Clone(); if (layer is GroupLayerBase) { // Clone sublayers (not cloned in Clone() to avoid issue with graphicslayer) var childLayers = new LayerCollection(); foreach (Layer subLayer in (layer as GroupLayerBase).ChildLayers) { var toSubLayer = CloneLayer(subLayer); if (toSubLayer != null) { toSubLayer.InitializationFailed += (s, e) => { }; // to avoid crash if bad layer childLayers.Add(toSubLayer); } } ((GroupLayerBase)toLayer).ChildLayers = childLayers; } } return(toLayer); }
// Plot points defining seismic lines, roughly outlining the area where the seismic survey was conducted private void PlotSeismicLines() { GraphicsLayer mygl = new GraphicsLayer(); mygl.ID = "SeismicLinePoints"; SimpleMarkerSymbol MyPointSymbol = new SimpleMarkerSymbol(); MyPointSymbol.Color = System.Windows.Media.Brushes.DarkMagenta; MyPointSymbol.Size = 8.0; SimpleLineSymbol MyLineSymbol = new SimpleLineSymbol(); MyLineSymbol.Color = System.Windows.Media.Brushes.DarkMagenta; MyLineSymbol.Width = 2.0; SpatialReference OriginalSpatialReference = new SpatialReference(4283); // GDA 1994 SpatialReference TargetSpatialReference = new SpatialReference(3857); // webmercator GeometryService mygeom = LayoutRoot.Resources["GeomService"] as GeometryService; GraphicCollection mygc = new GraphicCollection(); double[][] myPoints = new double[46][] { new double[] {-28.1434989,139.5514607}, new double[] {-28.1278969,139.6851856}, new double[] {-28.1801364,139.5568852}, new double[] {-28.1635794,139.6987722}, new double[] {-28.1901613,139.5583702}, new double[] {-28.1745546,139.6921527}, new double[] {-28.1917250,139.5585937}, new double[] {-28.1761182,139.6923782}, new double[] {-28.1934517,139.5588558}, new double[] {-28.1778446,139.6926424}, new double[] {-28.1939819,139.5844259}, new double[] {-28.1827765,139.6804436}, new double[] {-28.1961695,139.5847537}, new double[] {-28.1849639,139.6807733}, new double[] {-28.1983661,139.5850813}, new double[] {-28.1871603,139.6811028}, new double[] {-28.2013400,139.5855209}, new double[] {-28.1923641,139.6624829}, new double[] {-28.2057240,139.5861662}, new double[] {-28.1967479,139.6631312}, new double[] {-28.2080743,139.5865224}, new double[] {-28.1990981,139.6634891}, new double[] {-28.1125094,139.5809721}, new double[] {-28.2149162,139.5961573}, new double[] {-28.1110919,139.5931426}, new double[] {-28.2134978,139.6083392}, new double[] {-28.1108863,139.5949064}, new double[] {-28.2132921,139.6101047}, new double[] {-28.1105985,139.5973756}, new double[] {-28.2130042,139.6125764}, new double[] {-28.1103518,139.5994922}, new double[] {-28.2127573,139.6146949}, new double[] {-28.1100845,139.6017852}, new double[] {-28.2124898,139.6169900}, new double[] {-28.1098377,139.6039017}, new double[] {-28.2122429,139.6191085}, new double[] {-28.1095498,139.6063709}, new double[] {-28.2119547,139.6215802}, new double[] {-28.1092618,139.6088402}, new double[] {-28.2116666,139.6240517}, new double[] {-28.1077388,139.6218919}, new double[] {-28.2101425,139.6371157}, new double[] {-28.1075947,139.6231264}, new double[] {-28.2099983,139.6383515}, new double[] {-28.1061527,139.6354723}, new double[] {-28.2085555,139.6507091} }; foreach (double[] da in myPoints) { Graphic g = new Graphic(); g.Geometry = new MapPoint(da[1], da[0]); g.Geometry.SpatialReference = OriginalSpatialReference; mygc.Add(g); } IList<Graphic> glist = mygeom.Project(mygc, TargetSpatialReference); foreach (Graphic g in glist) { g.Symbol = MyPointSymbol; mygl.Graphics.Add(g); //System.Diagnostics.Debug.WriteLine((g.Geometry as MapPoint).X + " " + (g.Geometry as MapPoint).Y); } MyMap.Layers.Add(mygl); }
// Plot points and lines highlighting the area where seismic line slices can be obtained, with the seismic line control public void PlotActualSeismicLines() { GraphicsLayer mygl = new GraphicsLayer(); mygl.ID = "ActiveSeismicLinePoints"; SimpleMarkerSymbol MyPointSymbol = new SimpleMarkerSymbol(); MyPointSymbol.Color = System.Windows.Media.Brushes.DarkGreen; MyPointSymbol.Size = 8.0; SimpleLineSymbol MyLineSymbol = new SimpleLineSymbol(); MyLineSymbol.Color = System.Windows.Media.Brushes.DarkGreen; MyLineSymbol.Width = 2.0; SpatialReference OriginalSpatialReference = new SpatialReference(4283); // GDA 1994 SpatialReference TargetSpatialReference = new SpatialReference(3857); // webmercator GeometryService mygeom = LayoutRoot.Resources["GeomService"] as GeometryService; GraphicCollection mygc = new GraphicCollection(); double[][] myPoints = new double[4][] { // (latitude,longitude), ie (y,x) new double[] {-28.1801364, 139.5568852}, new double[] {-28.1434989,139.5514607}, new double[] {-28.1278969,139.6851856}, new double[] {-28.1635794, 139.6987722} }; foreach (double[] da in myPoints) { Graphic g = new Graphic(); g.Geometry = new MapPoint(da[1], da[0]); g.Geometry.SpatialReference = OriginalSpatialReference; mygc.Add(g); } IList<Graphic> glist = mygeom.Project(mygc, TargetSpatialReference); foreach (Graphic g in glist) { g.Symbol = MyPointSymbol; mygl.Graphics.Add(g); //System.Diagnostics.Debug.WriteLine((g.Geometry as MapPoint).X + " " + (g.Geometry as MapPoint).Y); } Graphic lineOne = new Graphic(); lineOne.Geometry = new Polyline(); ESRI.ArcGIS.Client.Geometry.PointCollection lineCollectionOne = new ESRI.ArcGIS.Client.Geometry.PointCollection(); lineCollectionOne.Add((glist[0] as Graphic).Geometry as MapPoint); lineCollectionOne.Add((glist[1] as Graphic).Geometry as MapPoint); lineCollectionOne.Add((glist[2] as Graphic).Geometry as MapPoint); lineCollectionOne.Add((glist[3] as Graphic).Geometry as MapPoint); lineCollectionOne.Add((glist[0] as Graphic).Geometry as MapPoint); (lineOne.Geometry as Polyline).Paths.Add(lineCollectionOne); lineOne.Symbol = MyLineSymbol; mygl.Graphics.Add(lineOne); MyMap.Layers.Add(mygl); }
/// <summary> /// Creates graphic elements and adds them to the graphics layer. /// </summary> /// <param name="layer">Graphics layer that will have features added to it.</param> /// <param name="images">Dictionary of images coming from kmz content or from previous parsing</param> public void CreateGraphics(KmlGraphicsLayer layer, IDictionary<string, ImageBrush> images) { if (layer == null) return; GraphicCollection graphics = new GraphicCollection(); UniqueValueRenderer renderer = new UniqueValueRenderer(); // dummy renderer used to create the legend items (since creation of the swatches from the symbol is not that obvious) // Process each metadata feature in the list foreach (PlacemarkDescriptor feature in placemarks) { KMLStyle style = feature.Symbol.style; if (style.ZipFile != null) { // Look for the image in the zip file if (style.IconImage == null && !String.IsNullOrEmpty(style.IconHref)) { style.IconImage = GetIconImage(style.ZipFile, style.IconHref.ToLower()); } style.ZipFile.Dispose(); style.ZipFile = null; } //Define handlers upfront so we can unhook from them #if SILVERLIGHT EventHandler<RoutedEventArgs> #else EventHandler #endif imageCompleted = null; #if SILVERLIGHT EventHandler<ExceptionRoutedEventArgs> #else EventHandler<ExceptionEventArgs> #endif imageFailed = null; // If the style has an HREF then it is associated with an image if (style.IconImage == null && !String.IsNullOrEmpty(style.IconHref)) { // If the image is already loaded in the image dictionary, use it if (images.ContainsKey(style.IconHref.ToLower())) style.IconImage = images[style.IconHref.ToLower()]; else { // Get the image using the HREF and store the image in the images dictionary so that if // other features reference it, it is cached style.IconImage = GetIconImage(style.IconHref); if (style.IconImage != null && (style.IconImage as ImageBrush).ImageSource != null) { var bi = (style.IconImage as ImageBrush).ImageSource as BitmapImage; if (bi != null) { imageFailed = (s, e) => { var b = s as BitmapImage; #if SILVERLIGHT if (imageCompleted != null) b.ImageOpened -= imageCompleted; if(imageFailed != null) b.ImageFailed -= imageFailed; #else if (imageCompleted != null) b.DownloadCompleted -= imageCompleted; if (imageFailed != null) b.DownloadFailed -= imageFailed; #endif var key = b.GetValue(BitmapImageKeyProperty) as string; layer.Dispatcher.BeginInvoke((Action)delegate { UpdateGraphicsAndRenderer(layer, renderer, key); }); }; #if SILVERLIGHT bi.ImageFailed += imageFailed; #else bi.DownloadFailed += imageFailed; #endif } } images.Add(style.IconHref.ToLower(), style.IconImage); } } // Create a new graphic from the metadata and construct the symbol using polymorphism Graphic g = new Graphic() { Geometry = feature.Geometry, Symbol = feature.Symbol.CreateSymbol(), TimeExtent = feature.TimeExtent }; g.SetValue(FeaturePlacemarkerDescriptorProperty, feature); // Create legend entry string label; string description; GetRendererInfo(feature, style, out label, out description); if (!string.IsNullOrEmpty(label) && !renderer.Infos.Any(info => info.Label == label)) renderer.Infos.Add(new UniqueValueInfo { Label = label, Description = description, Symbol = g.Symbol }); // Adjust and assign picture marker symbol properties if (g.Geometry is ESRI.ArcGIS.Client.Geometry.MapPoint && g.Symbol is KmlPlaceMarkerSymbol) { try { KmlPlaceMarkerSymbol ms = g.Symbol as KmlPlaceMarkerSymbol; // To match sizing of Google Earth, default size of point images is 40x40 ms.Height = 40; ms.Width = 40; ms.Fill = style.IconImage; ms.IconColor = style.IconColor; // Default to half the pixel size (width and height) if symbol offsets are 0 (supported in wpf and sl3) ImageBrush ib = ms.Fill; BitmapImage bi = ib.ImageSource as BitmapImage; #if SILVERLIGHT if (bi.PixelHeight == 0 || bi.PixelWidth == 0) #else if (bi.IsDownloading) #endif { imageCompleted = (s, e) => { var b = s as BitmapImage; #if SILVERLIGHT if (imageCompleted != null) b.ImageOpened -= imageCompleted; if(imageFailed != null) b.ImageFailed -= imageFailed; #else if (imageCompleted != null) b.DownloadCompleted -= imageCompleted; if (imageFailed != null) b.DownloadFailed -= imageFailed; #endif ComputeIconTranslationValues(style, ms, b); }; #if SILVERLIGHT bi.ImageOpened += imageCompleted; #else bi.DownloadCompleted += imageCompleted; #endif } else { ComputeIconTranslationValues(style, ms, bi); } } catch { g.Symbol = PointSymbolDescriptor.GetDefaultSymbol(); ComputeIconTranslationValues(style, g.Symbol as KmlPlaceMarkerSymbol, ((g.Symbol as KmlPlaceMarkerSymbol).Fill as ImageBrush).ImageSource as BitmapImage); var info = renderer.Infos.FirstOrDefault(i => i.Label == label); if (info != null) { info.Symbol = g.Symbol; } } } // Copy attributes values from metadata to graphic foreach (var attribute in feature.Attributes) { g.Attributes.Add(attribute.Key, attribute.Value); } // If the balloontext property has been assigned a value in the style associated with this // graphic feature, then add it to the attributes collection. if (!String.IsNullOrEmpty(style.BalloonText)) { g.Attributes.Add("balloonText", style.BalloonText); } // Add graphic to graphics layer graphics.Add(g); } layer.Graphics = graphics; // keep the renderer for further usage (when QueryLegendInfos is called) layer.RendererBasedOnStyle = renderer; }
private async void OnView_Tapped(object sender, Esri.ArcGISRuntime.UI.GeoViewInputEventArgs e) { MapPoint geoPoint = getGeoPoint(e); geoPoint = (MapPoint)GeometryEngine.Project(geoPoint, SpatialReference.Create(3857)); if (QueryandBufferButton.Content == FindResource("LocationSelected")) { Polygon buffer = (Polygon)GeometryEngine.Buffer(geoPoint, 1000.0); GraphicCollection graphics = (threeD ? bufferAndQuerySceneGraphics : bufferAndQueryMapGraphics).Graphics; graphics.Clear(); graphics.Add(new Graphic(buffer, BUFFER_SYMBOL)); graphics.Add(new Graphic(geoPoint, CLICK_SYMBOL)); Esri.ArcGISRuntime.Data.QueryParameters query = new Esri.ArcGISRuntime.Data.QueryParameters(); query.Geometry = buffer; LayerCollection operationalLayers; if (threeD) { operationalLayers = sceneView.Scene.OperationalLayers; } else { operationalLayers = mapView.Map.OperationalLayers; } foreach (Layer layer in operationalLayers) { await((FeatureLayer)layer).SelectFeaturesAsync(query, SelectionMode.New); } } else if (RoutingButton.Content == FindResource("RoutingSelected")) { GraphicCollection graphics = (threeD ? sceneRouteGraphics : mapRouteGraphics).Graphics; if (originPoint == null) { originPoint = geoPoint; graphics.Clear(); graphics.Add(new Graphic(originPoint, ROUTE_ORIGIN_SYMBOL)); } else { graphics.Add(new Graphic(geoPoint, ROUTE_DESTINATION_SYMBOL)); if (routeParameters != null) { routeParameters.ReturnDirections = false; routeParameters.ReturnRoutes = true; routeParameters.ReturnStops = false; } else { RoutingButton_Click(null, null); } var stop1 = new Stop(originPoint); var stop2 = new Stop(geoPoint); var stopPoints = new List <Stop> { stop1, stop2 }; routeParameters.SetStops(stopPoints); var routeResult = await routeTask.SolveRouteAsync(routeParameters); // get the route from the results var route = routeResult.Routes[0]; // create a graphic (with a dashed line symbol) to represent the route var routeSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Colors.Yellow, 5); var routeGraphic = new Graphic(route.RouteGeometry, routeSymbol); graphics.Add(routeGraphic); originPoint = null; } } }
internal static void CopyGraphics(System.Collections.Generic.IList<Graphic> fromCollection, GraphicCollection toCollection) { // copy all graphics foreach (Graphic featureGraphic in fromCollection) { Graphic graphic = new Graphic(); foreach (String attributeName in featureGraphic.Attributes.Keys) graphic.Attributes[attributeName] = featureGraphic.Attributes[attributeName]; graphic.Geometry = featureGraphic.Geometry; graphic.Symbol = featureGraphic.Symbol; toCollection.Add(graphic); } }
public static GraphicCollection LoadRoutes( rteTypeCollection rtes ) { rtes.RequireArgument<rteTypeCollection>( "rtes" ).NotNull<rteTypeCollection>(); GraphicCollection routes = new GraphicCollection(); foreach( var rte in rtes ) { Graphic gr = new Graphic(); gr.Geometry = LoadRoute( rte.rtept ); LoadRouteAttributes( rte, gr.Attributes ); routes.Add( gr ); } return routes; }
public static GraphicCollection ToGraphic(this JObject geoJson, SpatialReference sourceSpatialReference = null) { var graphics = new GraphicCollection(); if (sourceSpatialReference == null) { sourceSpatialReference = new SpatialReference(4326); } var src = ProjectionInfo.FromEpsgCode(sourceSpatialReference.WKID); var dest = ProjectionInfo.FromEpsgCode(4326); var sr = new SpatialReference(4326); var jFeatures = geoJson["features"] as JArray; if (jFeatures == null) return null; foreach (var jFeature in jFeatures.OfType<JObject>()) { var jGeometry = jFeature["geometry"]; if (jGeometry == null) continue; var geometryType = (string)jGeometry["type"]; switch (geometryType) { case "MultiPolygon": var jPolygons = jGeometry["coordinates"] as JArray; if (jPolygons == null) continue; foreach (var jPolygon in jPolygons.OfType<JArray>()) { if (jPolygon.Count == 0) continue; var polygon = new Polygon(); polygon.SpatialReference = sr; foreach (var jLinearRing in jPolygon.OfType<JArray>()) { if (src == dest) { var pointCollection = new PointCollection(jLinearRing.OfType<JArray>().Select(point=>new MapPoint((double)point[0], (double)point[1], sourceSpatialReference))); polygon.Rings.Add(pointCollection); } else { // reproject var points = jLinearRing.OfType<JArray>().SelectMany(point=>new double[2]{(double)point[0], (double)point[1]}).ToArray(); Reproject.ReprojectPoints(points, null, src, dest, 0, points.Length/2); var pointCollection = new PointCollection(Enumerable.Range(0, points.Length / 2).Select(i=>new MapPoint(points[i*2], points[(i*2)+1], sr))); polygon.Rings.Add(pointCollection); } } var graphic = new Graphic(); graphic.Geometry = polygon; graphic.Symbol = new SimpleFillSymbol { BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = 4, Fill = new SolidColorBrush(Colors.Blue) { Opacity = 0.8f} }; graphics.Add(graphic); } break; default: throw new NotSupportedException(string.Format("Geometry type {0} is not supported. Supported geometry types are: MultiPolygon.", geometryType)); } } return graphics; }
public static GraphicCollection LoadWayPoints( wptTypeCollection wpts ) { wpts.RequireArgument<wptTypeCollection>( "wpts" ).NotNull<wptTypeCollection>(); GraphicCollection pts = new GraphicCollection(); foreach( var wpt in wpts ) { Graphic gr = new Graphic(); gr.Geometry = LoadWayPointGeometry( wpt ); LoadWayPointAttributes( wpt, gr.Attributes ); pts.Add( gr ); } return pts; }
/// <summary> /// Creates graphic elements and adds them to the graphics layer. /// </summary> /// <param name="layer">Graphics layer that will have features added to it.</param> /// <param name="images">Dictionary of images coming from kmz content or from previous parsing</param> public void CreateGraphics(KmlGraphicsLayer layer, IDictionary <string, ImageBrush> images) { if (layer == null) { return; } GraphicCollection graphics = new GraphicCollection(); UniqueValueRenderer renderer = new UniqueValueRenderer(); // dummy renderer used to create the legend items (since creation of the swatches from the symbol is not that obvious) // Process each metadata feature in the list foreach (PlacemarkDescriptor feature in placemarks) { KMLStyle style = feature.Symbol.style; if (style.ZipFile != null) { // Look for the image in the zip file if (style.IconImage == null && !String.IsNullOrEmpty(style.IconHref)) { style.IconImage = GetIconImage(style.ZipFile, style.IconHref.ToLower()); } style.ZipFile.Dispose(); style.ZipFile = null; } //Define handlers upfront so we can unhook from them #if SILVERLIGHT EventHandler <RoutedEventArgs> #else EventHandler #endif imageCompleted = null; #if SILVERLIGHT EventHandler <ExceptionRoutedEventArgs> #else EventHandler <ExceptionEventArgs> #endif imageFailed = null; // If the style has an HREF then it is associated with an image if (style.IconImage == null && !String.IsNullOrEmpty(style.IconHref)) { // If the image is already loaded in the image dictionary, use it if (images.ContainsKey(style.IconHref.ToLower())) { style.IconImage = images[style.IconHref.ToLower()]; } else { // Get the image using the HREF and store the image in the images dictionary so that if // other features reference it, it is cached style.IconImage = GetIconImage(style.IconHref); if (style.IconImage != null && (style.IconImage as ImageBrush).ImageSource != null) { var bi = (style.IconImage as ImageBrush).ImageSource as BitmapImage; if (bi != null) { imageFailed = (s, e) => { var b = s as BitmapImage; #if SILVERLIGHT if (imageCompleted != null) { b.ImageOpened -= imageCompleted; } if (imageFailed != null) { b.ImageFailed -= imageFailed; } #else if (imageCompleted != null) { b.DownloadCompleted -= imageCompleted; } if (imageFailed != null) { b.DownloadFailed -= imageFailed; } #endif var key = b.GetValue(BitmapImageKeyProperty) as string; layer.Dispatcher.BeginInvoke((Action) delegate { UpdateGraphicsAndRenderer(layer, renderer, key); }); }; #if SILVERLIGHT bi.ImageFailed += imageFailed; #else bi.DownloadFailed += imageFailed; #endif } } images.Add(style.IconHref.ToLower(), style.IconImage); } } // Create a new graphic from the metadata and construct the symbol using polymorphism Graphic g = new Graphic() { Geometry = feature.Geometry, Symbol = feature.Symbol.CreateSymbol(), TimeExtent = feature.TimeExtent }; g.SetValue(FeaturePlacemarkerDescriptorProperty, feature); // Create legend entry string label; string description; GetRendererInfo(feature, style, out label, out description); if (!string.IsNullOrEmpty(label) && !renderer.Infos.Any(info => info.Label == label)) { renderer.Infos.Add(new UniqueValueInfo { Label = label, Description = description, Symbol = g.Symbol }); } // Adjust and assign picture marker symbol properties if (g.Geometry is ESRI.ArcGIS.Client.Geometry.MapPoint && g.Symbol is KmlPlaceMarkerSymbol) { try { KmlPlaceMarkerSymbol ms = g.Symbol as KmlPlaceMarkerSymbol; // To match sizing of Google Earth, default size of point images is 40x40 ms.Height = 40; ms.Width = 40; ms.Fill = style.IconImage; ms.IconColor = style.IconColor; // Default to half the pixel size (width and height) if symbol offsets are 0 (supported in wpf and sl3) ImageBrush ib = ms.Fill; BitmapImage bi = ib.ImageSource as BitmapImage; #if SILVERLIGHT if (bi.PixelHeight == 0 || bi.PixelWidth == 0) #else if (bi.IsDownloading) #endif { imageCompleted = (s, e) => { var b = s as BitmapImage; #if SILVERLIGHT if (imageCompleted != null) { b.ImageOpened -= imageCompleted; } if (imageFailed != null) { b.ImageFailed -= imageFailed; } #else if (imageCompleted != null) { b.DownloadCompleted -= imageCompleted; } if (imageFailed != null) { b.DownloadFailed -= imageFailed; } #endif ComputeIconTranslationValues(style, ms, b); }; #if SILVERLIGHT bi.ImageOpened += imageCompleted; #else bi.DownloadCompleted += imageCompleted; #endif } else { ComputeIconTranslationValues(style, ms, bi); } } catch { g.Symbol = PointSymbolDescriptor.GetDefaultSymbol(); ComputeIconTranslationValues(style, g.Symbol as KmlPlaceMarkerSymbol, ((g.Symbol as KmlPlaceMarkerSymbol).Fill as ImageBrush).ImageSource as BitmapImage); var info = renderer.Infos.FirstOrDefault(i => i.Label == label); if (info != null) { info.Symbol = g.Symbol; } } } // Copy attributes values from metadata to graphic foreach (var attribute in feature.Attributes) { g.Attributes.Add(attribute.Key, attribute.Value); } // If the balloontext property has been assigned a value in the style associated with this // graphic feature, then add it to the attributes collection. if (!String.IsNullOrEmpty(style.BalloonText)) { g.Attributes.Add("balloonText", style.BalloonText); } // Add graphic to graphics layer graphics.Add(g); } layer.Graphics = graphics; // keep the renderer for further usage (when QueryLegendInfos is called) layer.RendererBasedOnStyle = renderer; }
private void LoadWayPoints( wptTypeCollection wpts, GraphicCollection graphics ) { wpts.RequireArgument<wptTypeCollection>( "wpts" ).NotNull<wptTypeCollection>(); foreach( var wpt in wpts ) { Graphic gr = new Graphic() { Geometry = LoadWayPointGeometry(wpt) }; LoadWayPointAttributes( wpt, gr.Attributes ); gr.Symbol = Renderer.GetSymbol( gr ); graphics.Add( gr ); } }
// Draw horizontal distributed load // Note: x1<x2, (x1,y1)-(x2,y1) is a horizontal line, (x1,y2)-(x2,y3) is a oblique line // public static GraphicCollection DistributedLoad_Horizontal(double x1, double x2, double y1, double y2, double y3, Symbol backgroundFillSymbol, Symbol arrowFillSymbol, Symbol lineSymbol) { GraphicCollection gc = new GraphicCollection(); MapPoint p1 = new MapPoint(x1, y1); MapPoint p2 = new MapPoint(x1, y2); MapPoint p3 = new MapPoint(x2, y3); MapPoint p4 = new MapPoint(x2, y1); Graphic g = ArcGISMappingUtility.NewQuadrilateral(p1, p2, p3, p4); g.Symbol = backgroundFillSymbol; gc.Add(g); Esri.ArcGISRuntime.Geometry.PointCollection pc = new Esri.ArcGISRuntime.Geometry.PointCollection(); pc.Add(p1); pc.Add(p2); pc.Add(p3); pc.Add(p4); pc.Add(p1); g = ArcGISMappingUtility.NewPolyline(pc); g.Symbol = lineSymbol; gc.Add(g); double x00, y00, y01; for (int i = 0; i <= 10; ++i) { x00 = x1 + i * (x2 - x1) / 10.0; y00 = y1; y01 = y2 + i * (y3 - y2) / 10.0; MapPoint p00 = new MapPoint(x00, y00); MapPoint p01 = new MapPoint(x00, y01); g = ArcGISMappingUtility.NewLine(p00, p01); g.Symbol = lineSymbol; gc.Add(g); pc = ArcGISMappingUtility.VectorArrowPoints(x00, y2, p00); g = ArcGISMappingUtility.NewPolygon(pc); g.Symbol = arrowFillSymbol; gc.Add(g); } return gc; }
public static void Show(IProgressGraphicProgressProvider source, GraphicCollection parentCollection, bool autoClose = _defaultAutoClose, ProgressBarGraphicStyle progressBarStyle = _defaultStyle) { ProgressGraphic progressGraphic = new ProgressGraphic(source, autoClose, progressBarStyle); parentCollection.Add(progressGraphic); progressGraphic.Draw(); }
private async void ShowServiceAreasButtonClick(object sender, EventArgs e) { // Finish any drawings in progress. if (_myMapView.SketchEditor.CompleteCommand.CanExecute(null)) { _myMapView.SketchEditor.CompleteCommand.Execute(null); } // Update the UI. _barrierButton.Text = "Draw barrier"; // Use a local variable for the graphics overlay. GraphicCollection allGraphics = _myMapView.GraphicsOverlays[0].Graphics; // Get a list of the facilities from the graphics overlay. List <ServiceAreaFacility> serviceAreaFacilities = (from g in allGraphics where (string)g.Attributes["Type"] == "Facility" select new ServiceAreaFacility((MapPoint)g.Geometry)).ToList(); // Check that there is at least 1 facility to find a service area for. if (!serviceAreaFacilities.Any()) { CreateErrorDialog("Must have at least one Facility!"); return; } // Create the service area task and parameters based on the Uri. ServiceAreaTask serviceAreaTask = await ServiceAreaTask.CreateAsync(_serviceAreaUri); // Store the default parameters for the service area in an object. ServiceAreaParameters serviceAreaParameters = await serviceAreaTask.CreateDefaultParametersAsync(); // Add impedance cutoffs for facilities (drive time minutes). serviceAreaParameters.DefaultImpedanceCutoffs.Add(2.0); serviceAreaParameters.DefaultImpedanceCutoffs.Add(5.0); // Set the level of detail for the polygons. serviceAreaParameters.PolygonDetail = ServiceAreaPolygonDetail.High; // Get a list of the barriers from the graphics overlay. List <PolylineBarrier> polylineBarriers = (from g in allGraphics where (string)g.Attributes["Type"] == "Barrier" select new PolylineBarrier((Polyline)g.Geometry)).ToList(); // Add the barriers to the service area parameters. serviceAreaParameters.SetPolylineBarriers(polylineBarriers); // Update the parameters to include all of the placed facilities. serviceAreaParameters.SetFacilities(serviceAreaFacilities); // Clear existing graphics for service areas. foreach (Graphic g in allGraphics.ToList()) { // Check if the graphic g is a service area. if ((string)g.Attributes["Type"] == "ServiceArea") { allGraphics.Remove(g); } } try { // Solve for the service area of the facilities. ServiceAreaResult result = await serviceAreaTask.SolveServiceAreaAsync(serviceAreaParameters); // Loop over each facility. for (int i = 0; i < serviceAreaFacilities.Count; i++) { // Create list of polygons from a service facility. List <ServiceAreaPolygon> polygons = result.GetResultPolygons(i).ToList(); // Symbol for the outline of the service areas. SimpleLineSymbol serviceOutline = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.DarkGray, 3.0f); // Create a list of fill symbols for the polygons. List <SimpleFillSymbol> fillSymbols = new List <SimpleFillSymbol>(); fillSymbols.Add(new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.Color.FromArgb(70, 255, 0, 0), serviceOutline)); fillSymbols.Add(new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.Color.FromArgb(70, 255, 165, 0), serviceOutline)); // Loop over every polygon in every facilities result. for (int j = 0; j < polygons.Count; j++) { // Create the graphic for the service areas, alternating between fill symbols. Graphic serviceGraphic = new Graphic(polygons[j].Geometry, new Dictionary <string, object>() { { "Type", "ServiceArea" } }, fillSymbols[j % 2]) { ZIndex = 0 }; // Add graphic for service area. Alternate the color of each polygon. allGraphics.Add(serviceGraphic); } } } catch (Esri.ArcGISRuntime.Http.ArcGISWebException exception) { if (exception.Message.ToString().Equals("Unable to complete operation.")) { CreateErrorDialog("Facility not within San Diego area!"); } else { CreateErrorDialog("An ArcGIS web exception occurred. \n" + exception.Message); } } }
public void SetShapeRangeValues(DashboardHelper dashboardHelper, string shapeKey, string dataKey, string valueField, List <SolidColorBrush> brushList, int classCount, string missingText, string legendText, bool?showPolyLabels = false) { try { _classCount = classCount; _dashboardHelper = dashboardHelper; _shapeKey = shapeKey; _dataKey = dataKey; _valueField = valueField; _missingText = missingText; _legendText = legendText; _showPolyLabels = (bool)showPolyLabels; if (brushList != null) { _colors = brushList; } DataTable loadedData = GetLoadedData(dashboardHelper, dataKey, ref valueField); if (_valueField == "{Record Count}") { _valueField = "freq"; } GraphicsLayer graphicsLayer = GetGraphicsLayer() as GraphicsLayer; _thematicItem = GetThematicItem(classCount, loadedData, graphicsLayer); if (this.UseQuantiles == false && RangeStarts_FromControls != null && RangeStarts_FromControls.Count > 0) { _thematicItem.RangeStarts = RangeStarts_FromControls; PopulateRangeValues(); } else { PopulateRangeValues(); } GraphicCollection textGraphics = new GraphicCollection(); if (graphicsLayer.Graphics != null && graphicsLayer.Graphics.Count > 0) { for (int i = graphicsLayer.Graphics.Count - 1; i > -1; i--) { if (graphicsLayer.Graphics[i].Symbol is TextSymbol) { graphicsLayer.Graphics.RemoveAt(i); } } } bool usePoleOfInaccessibility = true; if (graphicsLayer.Graphics != null && graphicsLayer.Graphics.Count > 0) { for (int i = 0; i < graphicsLayer.Graphics.Count; i++) { Graphic graphicFeature = graphicsLayer.Graphics[i]; if (graphicFeature.Symbol is TextSymbol) { continue; } if (graphicFeature.Attributes.Count == 0) { continue; } string filterExpression = ""; if (dataKey.Contains(" ") || dataKey.Contains("$") || dataKey.Contains("#")) { filterExpression += "["; } filterExpression += dataKey; if (dataKey.Contains(" ") || dataKey.Contains("$") || dataKey.Contains("#")) { filterExpression += "]"; } filterExpression += " = '" + GetShapeValue(graphicFeature, shapeKey) + "'"; double graphicValue = Double.PositiveInfinity; try { DataRow[] postFilterExpression = loadedData.Select(filterExpression); if (postFilterExpression.Length > 0) { graphicValue = Convert.ToDouble(postFilterExpression[0][_valueField]); } } catch (Exception) { graphicValue = Double.PositiveInfinity; } int brushIndex = GetRangeIndex(graphicValue, _thematicItem.RangeStarts); if (brushList != null) { Color color = ((SolidColorBrush)brushList[brushIndex]).Color; Brush fill = new SolidColorBrush(Color.FromArgb(Opacity, color.R, color.G, color.B)); if (graphicValue == Double.PositiveInfinity) { color = ((SolidColorBrush)brushList[brushList.Count - 1]).Color; fill = new SolidColorBrush(Color.FromArgb(Opacity, color.R, color.G, color.B)); } SimpleFillSymbol symbol = new SimpleFillSymbol(); symbol.Fill = fill; symbol.BorderBrush = new SolidColorBrush(Colors.Black); symbol.BorderThickness = 1; graphicFeature.Symbol = symbol; } if (ShowPolyLabels) { TextSymbol textSymbol = new TextSymbol(); textSymbol.Foreground = new SolidColorBrush(Colors.Black); textSymbol.FontSize = 11; if (graphicFeature.Attributes[shapeKey] != null) { string sShapekey = graphicFeature.Attributes[shapeKey].ToString().Trim(); int indexShapeKey = sShapekey.LastIndexOfAny(new char[] { ' ', '-' }); int iShapeKeyLen = sShapekey.Length; // Break up label if possible and put on new line. Adjust offsets as needed. if (indexShapeKey != -1) //& iShapeKeyLen > 10) { textSymbol.Text = sShapekey.Substring(0, indexShapeKey) + "\r\n " + sShapekey.Substring(indexShapeKey + 1, (iShapeKeyLen - (indexShapeKey + 1))); textSymbol.OffsetX = iShapeKeyLen / 0.8; textSymbol.OffsetY = 6; } else { textSymbol.Text = sShapekey; textSymbol.OffsetX = iShapeKeyLen / 0.4; textSymbol.OffsetY = 3; } //Console.WriteLine(textSymbol.Text); //textSymbol.OffsetX = textSymbol.Text.Length / 0.4; textSymbol.OffsetY = textSymbol.FontSize / 2.0; Envelope extentEnvelope = graphicFeature.Geometry.Extent; MapPoint pole = extentEnvelope.GetCenter(); ObservableCollection <ESRI.ArcGIS.Client.Geometry.PointCollection> rings = new ObservableCollection <ESRI.ArcGIS.Client.Geometry.PointCollection>(); //if (graphicFeature.Attributes[shapeKey].ToString().Trim() == "Richmond Hill") usePoleOfInaccessibility = true; if (usePoleOfInaccessibility) { if (graphicFeature.Geometry is ESRI.ArcGIS.Client.Geometry.Polygon) { rings = ((ESRI.ArcGIS.Client.Geometry.Polygon)graphicFeature.Geometry).Rings; Tuple <double, double> coords; bool showDebugCells = true; if (showDebugCells) { double precision = 0.1; double denom = 64.0; precision = extentEnvelope.Width / denom < precision? extentEnvelope.Width / denom : precision; precision = extentEnvelope.Height / denom < precision ? extentEnvelope.Height / denom : precision; coords = PolyLabel.PoleOfInaccessibility(rings, precision, graphicsLayer: graphicsLayer); //Envelope extent = graphicFeature.Geometry.Extent; //Cell extentCell = new Cell(extent.XMin, extent.YMin, extent.Width / 2, rings); //PolyLabel.AddDebugGraphic(extentCell, graphicsLayer); } else { coords = PolyLabel.PoleOfInaccessibility(rings); } pole.X = coords.Item1; pole.Y = coords.Item2; } //usePoleOfInaccessibility = false; } Graphic textGraphic = new Graphic(); textGraphic.Symbol = textSymbol; textGraphic.Geometry = pole; textGraphics.Add(textGraphic); } } TextBlock t = new TextBlock(); t.Background = Brushes.White; if (graphicValue == Double.PositiveInfinity) { t.Text = GetShapeValue(graphicFeature, shapeKey) + " " + DashboardSharedStrings.DASHBOARD_MAP_NO_DATA; } else { t.Text = GetShapeValue(graphicFeature, shapeKey) + " : " + graphicValue.ToString(); } t.FontSize = 14; Border border = new Border(); border.BorderThickness = new Thickness(1); Panel panel = new StackPanel(); panel.Children.Add(t); border.Child = panel; graphicFeature.MapTip = border; if (graphicFeature.Attributes.Keys.Contains("EpiInfoValCol")) { graphicFeature.Attributes["EpiInfoValCol"] = graphicValue; } else { graphicFeature.Attributes.Add("EpiInfoValCol", graphicValue); } } graphicsLayer.Graphics.AddRange(textGraphics); if (graphicsLayer is FeatureLayer) { ClassBreaksRenderer renderer = new ClassBreaksRenderer(); renderer.Field = "EpiInfoValCol"; Color color = ((SolidColorBrush)brushList[brushList.Count - 1]).Color; Brush fill = new SolidColorBrush(Color.FromArgb(Opacity, color.R, color.G, color.B)); renderer.DefaultSymbol = new SimpleFillSymbol() { Fill = fill, BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = 1 }; for (int i = 0; i < _thematicItem.RangeStarts.Count; i++) { ClassBreakInfo classBreakInfo = new ClassBreakInfo(); classBreakInfo.MinimumValue = double.Parse(RangeValues[i, 0]); classBreakInfo.MaximumValue = double.Parse(RangeValues[i, 1]); color = ((SolidColorBrush)brushList[i]).Color; fill = new SolidColorBrush(Color.FromArgb(Opacity, color.R, color.G, color.B)); classBreakInfo.Symbol = new SimpleFillSymbol() { Fill = fill, BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = 1 }; renderer.Classes.Add(classBreakInfo); } graphicsLayer.Renderer = renderer; } } SetLegendSection(brushList, classCount, missingText, _thematicItem); } catch { } }
void Graphics_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) { if (e.NewItems != null) { GraphicCollection newGraphics = new GraphicCollection(); foreach (Graphic newGraphic in e.NewItems) newGraphics.Add(newGraphic); OnGraphicsCreated(newGraphics, false, null); } } else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset) { Graphics.Clear(); } }