private void DrawPuntualFeature(FtTransmitterDataset dataset) { var puntualLayer = new FtPuntualVectorLayer(this, dataset); ActiveVectorLayers.Add(dataset, puntualLayer); VariableLayers.AddCollection(puntualLayer); }
/// <summary> /// Returns a cloned copy of this map-object. /// Layers are not cloned. The same instances are referenced from the cloned copy as from the original. /// The property <see cref="DisposeLayersOnDispose"/> is however false on this object (which prevents layers beeing disposed and then not usable from the original map) /// </summary> /// <returns>Instance of <see cref="Map"/></returns> public Map Clone() { Map clone = null; lock (MapTransform) { clone = new Map() { BackColor = BackColor, Disclaimer = Disclaimer, DisclaimerLocation = DisclaimerLocation, MaximumZoom = MaximumZoom, MinimumZoom = MinimumZoom, PixelAspectRatio = PixelAspectRatio, Zoom = Zoom, DisposeLayersOnDispose = false }; if (DisclaimerFont != null) { clone.DisclaimerFont = (Font)DisclaimerFont.Clone(); } if (MapTransform != null) { clone.MapTransform = MapTransform.Clone(); } if (Size != null) { clone.Size = new Size(Size.Width, Size.Height); } if (Center != null) { clone.Center = Center.Clone(); } } if (clone != null) { if (BackgroundLayer != null) { clone.BackgroundLayer.AddCollection(BackgroundLayer.Clone()); } for (int i = 0; i < Decorations.Count; i++) { clone.Decorations.Add(Decorations[i]); } if (Layers != null) { clone.Layers.AddCollection(Layers.Clone()); } if (VariableLayers != null) { clone.VariableLayers.AddCollection(VariableLayers.Clone()); } } return(clone); }
private void ErasePuntualFeature(FtTransmitterDataset dataset) { var puntualVectorLayer = ActiveVectorLayers[dataset]; ActiveVectorLayers.Remove(dataset); // Labellayer kann null sein, wenn für das Feature keine Labels angezeigt werden sollen if (puntualVectorLayer.LabelLayer != null) { VariableLayers.Remove(puntualVectorLayer.LabelLayer); } VariableLayers.Remove(puntualVectorLayer.SymbolizerLayer); }
/// <summary> /// Disposes the map object /// </summary> public void Dispose() { if (DisposeLayersOnDispose) { if (Layers != null) { foreach (ILayer layer in Layers) { if (layer is IDisposable) { ((IDisposable)layer).Dispose(); } } } if (BackgroundLayer != null) { foreach (ILayer layer in BackgroundLayer) { if (layer is IDisposable) { ((IDisposable)layer).Dispose(); } } } if (VariableLayers != null) { foreach (ILayer layer in VariableLayers) { if (layer is IDisposable) { ((IDisposable)layer).Dispose(); } } } } if (Layers != null) { Layers.Clear(); } if (BackgroundLayer != null) { BackgroundLayer.Clear(); } if (VariableLayers != null) { VariableLayers.Clear(); } }
/// <summary> /// Returns a layer by its name /// </summary> /// <param name="name">Name of layer</param> /// <returns>Layer</returns> public ILayer GetLayerByName(string name) { ILayer lay = null; if (Layers != null) { lay = Layers.GetLayerByName(name); } if (lay == null && BackgroundLayer != null) { lay = BackgroundLayer.GetLayerByName(name); } if (lay == null && VariableLayers != null) { lay = VariableLayers.GetLayerByName(name); } return(lay); }
/// <summary> /// Returns a cloned copy of this map-object. /// Layers are not cloned. The same instances are referenced from the cloned copy as from the original. /// The property <see cref="DisposeLayersOnDispose"/> is however false on this object (which prevents layers beeing disposed and then not usable from the original map) /// </summary> /// <returns>Instance of <see cref="Map"/></returns> public Map Clone() { Map clone = null; lock (MapTransform) { clone = new Map() { BackColor = BackColor, #pragma warning disable 612,618 Disclaimer = Disclaimer, DisclaimerLocation = DisclaimerLocation, #pragma warning restore 612,618 MaximumZoom = MaximumZoom, MinimumZoom = MinimumZoom, PixelAspectRatio = PixelAspectRatio, Zoom = Zoom, DisposeLayersOnDispose = false, SRID = SRID }; #pragma warning disable 612,618 if (DisclaimerFont != null) { clone.DisclaimerFont = (Font)DisclaimerFont.Clone(); } #pragma warning restore 612,618 if (MapTransform != null) { clone.MapTransform = MapTransform.Clone(); } if (!Size.IsEmpty) { clone.Size = new Size(Size.Width, Size.Height); } if (Center != null) { clone.Center = (Coordinate)Center.Clone(); } } if (BackgroundLayer != null) { clone.BackgroundLayer.AddCollection(BackgroundLayer.Clone()); } for (int i = 0; i < Decorations.Count; i++) { clone.Decorations.Add(Decorations[i]); } if (Layers != null) { clone.Layers.AddCollection(Layers.Clone()); } if (VariableLayers != null) { clone.VariableLayers.AddCollection(VariableLayers.Clone()); } return(clone); }
/// <summary> /// Renders the map using the provided <see cref="T:System.Drawing.Graphics" /> object. /// Uses custom <see cref="LayerCollectionRendererThrowsException"/> in order to honor WmsLayer property ContinueOnError. /// If ContinueOnError is false, an exception will be thrown. /// If ContinueOnErrror is true, a red X will be drawn instead of the layer. /// </summary> /// <param name="g">the <see cref="T:System.Drawing.Graphics" /> object to use</param> /// <exception cref="T:System.ArgumentNullException">if <see cref="T:System.Drawing.Graphics" /> object is null.</exception> /// <exception cref="T:System.InvalidOperationException">if there are no layers to render.</exception> public new void RenderMap(Graphics g) { OnMapRendering(g); if (g == null) { throw new ArgumentNullException("g", "Cannot render map with null graphics object!"); } //Pauses the timer for VariableLayer VariableLayerCollection.Pause = true; if ((Layers == null || Layers.Count == 0) && (BackgroundLayer == null || BackgroundLayer.Count == 0) && (VariableLayers == null || VariableLayers.Count == 0)) { throw new InvalidOperationException("No layers to render"); } lock (MapTransform) { g.Transform = MapTransform.Clone(); } g.Clear(BackColor); g.PageUnit = GraphicsUnit.Pixel; double zoom = Zoom; double scale = double.NaN; //will be resolved if needed ILayer[] layerList; if (BackgroundLayer != null && BackgroundLayer.Count > 0) { layerList = new ILayer[BackgroundLayer.Count]; BackgroundLayer.CopyTo(layerList, 0); foreach (ILayer layer in layerList) { if (layer.VisibilityUnits == VisibilityUnits.Scale && double.IsNaN(scale)) { scale = MapScale; } double visibleLevel = layer.VisibilityUnits == VisibilityUnits.ZoomLevel ? zoom : scale; OnLayerRendering(layer, LayerCollectionType.Background); if (layer.Enabled) { if (layer.MaxVisible >= visibleLevel && layer.MinVisible < visibleLevel) { LayerCollectionRendererThrowsException.RenderLayer(layer, g, this); } } OnLayerRendered(layer, LayerCollectionType.Background); } } if (Layers != null && Layers.Count > 0) { layerList = new ILayer[Layers.Count]; Layers.CopyTo(layerList, 0); //int srid = (Layers.Count > 0 ? Layers[0].SRID : -1); //Get the SRID of the first layer foreach (ILayer layer in layerList) { if (layer.VisibilityUnits == VisibilityUnits.Scale && double.IsNaN(scale)) { scale = MapScale; } double visibleLevel = layer.VisibilityUnits == VisibilityUnits.ZoomLevel ? zoom : scale; OnLayerRendering(layer, LayerCollectionType.Static); if (layer.Enabled && layer.MaxVisible >= visibleLevel && layer.MinVisible < visibleLevel) { LayerCollectionRendererThrowsException.RenderLayer(layer, g, this); } OnLayerRendered(layer, LayerCollectionType.Static); } } if (VariableLayers != null && VariableLayers.Count > 0) { layerList = new ILayer[VariableLayers.Count]; VariableLayers.CopyTo(layerList, 0); foreach (ILayer layer in layerList) { if (layer.VisibilityUnits == VisibilityUnits.Scale && double.IsNaN(scale)) { scale = MapScale; } double visibleLevel = layer.VisibilityUnits == VisibilityUnits.ZoomLevel ? zoom : scale; if (layer.Enabled && layer.MaxVisible >= visibleLevel && layer.MinVisible < visibleLevel) { LayerCollectionRendererThrowsException.RenderLayer(layer, g, this); } } } #pragma warning disable 612,618 RenderDisclaimer(g); #pragma warning restore 612,618 // Render all map decorations foreach (var mapDecoration in Decorations) { mapDecoration.Render(g, this); } //Resets the timer for VariableLayer VariableLayerCollection.Pause = false; OnMapRendered(g); }