public void Map_TileAsyncReplacedFromGroup_DoesNotFireMapNewTileAvailable(LayerCollectionType collectionType) { var map = new Map(); var group = CreateLayerGroup(); map.GetCollection(collectionType).Add(group); var tileLayer = CreateTileAsyncLayer(); AddTileLayerToLayerGroup(tileLayer, group); var newTileLayer = CreateTileAsyncLayer(); ReplaceExistingAsyncLayerFromGroup(group, tileLayer, newTileLayer); var eventSource = map.GetMapNewTileAvailableAsObservable(); RaiseMapNewtileAvailableOn(tileLayer); Assert.That(eventSource.IsEmpty().First(), "Map should NOT fire MapNewTileAvailable event for TileAsyncLayers replaced from a group"); RaiseMapNewtileAvailableOn(newTileLayer); Assert.That(eventSource.Count().First(), Is.EqualTo(1), TestContext.CurrentContext.Test.GetDescription()); }
/// <summary> /// Renders the map using the provided <see cref="Graphics"/> object. /// </summary> /// <param name="g">the <see cref="Graphics"/> object to use</param> /// <param name="layerCollectionType">the <see cref="LayerCollectionType"/> to use</param> /// <exception cref="ArgumentNullException">if <see cref="Graphics"/> object is null.</exception> /// <exception cref="InvalidOperationException">if there are no layers to render.</exception> public void RenderMap(Graphics g, LayerCollectionType layerCollectionType) { if (g == null) { throw new ArgumentNullException("g", "Cannot render map with null graphics object!"); } VariableLayerCollection.Pause = true; LayerCollection lc = null; switch (layerCollectionType) { case LayerCollectionType.Static: lc = Layers; break; case LayerCollectionType.Variable: lc = VariableLayers; break; case LayerCollectionType.Background: lc = BackgroundLayer; break; } if (lc == null || lc.Count == 0) { throw new InvalidOperationException("No layers to render"); } Matrix transform = g.Transform; g.Transform = MapTransform; g.Clear(BackColor); g.PageUnit = GraphicsUnit.Pixel; //int srid = (Layers.Count > 0 ? Layers[0].SRID : -1); //Get the SRID of the first layer ILayer[] layerList = new ILayer[lc.Count]; lc.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.Enabled && layer.MaxVisible >= Zoom && layer.MinVisible < Zoom) { layer.Render(g, this); } } g.Transform = transform; if (layerCollectionType == LayerCollectionType.Static) { RenderDisclaimer(g); } VariableLayerCollection.Pause = false; }
protected virtual void OnLayerRendering(ILayer layer, LayerCollectionType layerCollectionType) { var e = LayerRendering; if (e != null) { e(this, new LayerRenderingEventArgs(layer, layerCollectionType)); } }
public void AddingTileAsyncLayers_HookItsMapNewTileAvaliableEvent(LayerCollectionType collectionType) { var map = new Map(); var layer = CreateTileAsyncLayer(); AddTileLayerToMap(layer, map, collectionType); var eventSource = map.GetMapNewTileAvailableAsObservable(); RaiseMapNewtileAvailableOn(layer); Assert.That(eventSource.Count().First(), Is.EqualTo(1), TestContext.CurrentContext.Test.GetDescription()); }
public void Map_TileAsyncInsideAddedGroup_FiresMapNewTileAvail(LayerCollectionType collectionType) { var map = new Map(); var group = CreateLayerGroup(); var tileLayer = CreateTileAsyncLayer(); AddTileLayerToLayerGroup(tileLayer, group); map.GetCollection(collectionType).Add(group); var eventSource = map.GetMapNewTileAvailableAsObservable(); RaiseMapNewtileAvailableOn(tileLayer); Assert.That(eventSource.Count().First(), Is.EqualTo(1), TestContext.CurrentContext.Test.GetDescription()); }
public static LayerCollection GetCollection(this Map map, LayerCollectionType collectionType) { switch (collectionType) { case LayerCollectionType.Background: return map.BackgroundLayer; case LayerCollectionType.Static: return map.Layers; case LayerCollectionType.Variable: return map.VariableLayers; default: throw new Exception(); } }
public void MapDoesNoGenerateMapNewTile_AfterClear(LayerCollectionType collectionType) { var map = new Map(); var tileAsyncLayer = CreateTileAsyncLayer(); AddTileLayerToMap(tileAsyncLayer, map, collectionType); var eventSource = map.GetMapNewTileAvailableAsObservable(); map.GetCollection(collectionType).Clear(); RaiseMapNewtileAvailableOn(tileAsyncLayer); Assert.That(eventSource.IsEmpty().First(), TestContext.CurrentContext.Test.GetDescription()); }
protected virtual void OnLayerRendered(ILayer layer, LayerCollectionType layerCollectionType) { #pragma warning disable 612,618 var e = LayerRendered; #pragma warning restore 612,618 if (e != null) { e(this, EventArgs.Empty); } var eex = LayerRenderedEx; if (eex != null) { eex(this, new LayerRenderingEventArgs(layer, layerCollectionType)); } }
public static LayerCollection GetCollection(this Map map, LayerCollectionType collectionType) { switch (collectionType) { case LayerCollectionType.Background: return(map.BackgroundLayer); case LayerCollectionType.Static: return(map.Layers); case LayerCollectionType.Variable: return(map.VariableLayers); default: throw new Exception(); } }
public void MapGeneratesMapNewTile_NewReplacedLayers(LayerCollectionType collectionType) { var map = new Map(); var tileAsyncLayer = CreateTileAsyncLayer(); AddTileLayerToMap(tileAsyncLayer, map, collectionType); var eventSource = map.GetMapNewTileAvailableAsObservable(); var newLayer = CreateTileAsyncLayer(); map.GetCollection(collectionType)[0] = newLayer.Item1.Object; RaiseMapNewtileAvailableOn(newLayer); Assert.That(eventSource.Count().First(), Is.EqualTo(1), TestContext.CurrentContext.Test.GetDescription()); }
public void Map_TileAsyncRemovedFromGroup_DoesNotFiredMapNewTileAvailable(LayerCollectionType collectionType) { var map = new Map(); var group = CreateLayerGroup(); map.GetCollection(collectionType).Add(group); var tileLayer = CreateTileAsyncLayer(); AddTileLayerToLayerGroup(tileLayer, group); RemoveTileLayerFromGroup(group, tileLayer); var eventSource = map.GetMapNewTileAvailableAsObservable(); RaiseMapNewtileAvailableOn(tileLayer); Assert.That(eventSource.IsEmpty().First(), TestContext.CurrentContext.Test.GetDescription()); }
private Bitmap GetMap(LayerCollection layers, LayerCollectionType layerCollectionType) { if ((layers == null || layers.Count == 0)) { return(null); } Bitmap retval = new Bitmap(Width, Height); Graphics g = Graphics.FromImage(retval); _map.RenderMap(g, layerCollectionType); g.Dispose(); if (layerCollectionType == LayerCollectionType.Variable) { retval.MakeTransparent(_map.BackColor); } return(retval); }
public void Map_TileAsyncRemovedFromNephew_DoesNotFireMapNewtileAvailable(LayerCollectionType collectionType) { var map = new Map(); var group = CreateLayerGroup(); map.GetCollection(collectionType).Add(group); var subGroup = CreateLayerGroup("subgroup"); var tileAsyncLayer = CreateTileAsyncLayer(); AddTileLayerToLayerGroup(tileAsyncLayer, subGroup); group.Layers.Add(subGroup); // test RemoveTileLayerFromGroup(subGroup, tileAsyncLayer); var eventSource = map.GetMapNewTileAvailableAsObservable(); RaiseMapNewtileAvailableOn(tileAsyncLayer); Assert.That(eventSource.Count().First(), Is.EqualTo(0), TestContext.CurrentContext.Test.GetDescription()); }
private Image GetMap(LayerCollection layers, LayerCollectionType layerCollectionType) { if ((layers == null || layers.Count == 0 || Width == 0 || Height == 0)) { return(null); } Bitmap retval = new Bitmap(Width, Height); lock (m_ImageStatic) { if (layerCollectionType == LayerCollectionType.Static) { if (m_ImageStatic.Width != Width || m_ImageStatic.Height != Height) { retval = new Bitmap(Width, Height); } else { retval = (Bitmap)m_ImageStatic; } } } Graphics g = Graphics.FromImage(retval); m_Map.RenderMap(g, layerCollectionType); g.Dispose(); if (layerCollectionType == LayerCollectionType.Variable) { retval.MakeTransparent(m_Map.BackColor); } return(retval); }
/// <summary> /// Renders the map using the provided <see cref="Graphics"/> object. /// </summary> /// <param name="g">the <see cref="Graphics"/> object to use</param> /// <param name="layerCollectionType">the <see cref="LayerCollectionType"/> to use</param> /// <param name="drawMapDecorations">Set whether to draw map decorations on the map (if such are set)</param> /// <exception cref="ArgumentNullException">if <see cref="Graphics"/> object is null.</exception> /// <exception cref="InvalidOperationException">if there are no layers to render.</exception> public void RenderMap(Graphics g, LayerCollectionType layerCollectionType, bool drawMapDecorations) { if (g == null) throw new ArgumentNullException("g", "Cannot render map with null graphics object!"); VariableLayerCollection.Pause = true; LayerCollection lc = null; switch (layerCollectionType) { case LayerCollectionType.Static: lc = Layers; break; case LayerCollectionType.Variable: lc = VariableLayers; break; case LayerCollectionType.Background: lc = BackgroundLayer; break; } if (lc== null || lc.Count == 0) throw new InvalidOperationException("No layers to render"); Matrix transform = g.Transform; lock (MapTransform) { g.Transform = MapTransform.Clone(); } g.Clear(BackColor); g.PageUnit = GraphicsUnit.Pixel; ILayer[] layerList = new ILayer[lc.Count]; lc.CopyTo(layerList, 0); foreach (ILayer layer in layerList) { if (layer.Enabled && layer.MaxVisible >= Zoom && layer.MinVisible < Zoom) layer.Render(g, this); } g.Transform = transform; if (layerCollectionType == LayerCollectionType.Static) { #pragma warning disable 612,618 RenderDisclaimer(g); #pragma warning restore 612,618 if (drawMapDecorations) { foreach (var mapDecoration in Decorations) { mapDecoration.Render(g, this); } } } VariableLayerCollection.Pause = false; }
/// <summary> /// Renders the map using the provided <see cref="Graphics"/> object. /// </summary> /// <param name="g">the <see cref="Graphics"/> object to use</param> /// <param name="layerCollectionType">the <see cref="LayerCollectionType"/> to use</param> /// <exception cref="ArgumentNullException">if <see cref="Graphics"/> object is null.</exception> /// <exception cref="InvalidOperationException">if there are no layers to render.</exception> public void RenderMap(Graphics g, LayerCollectionType layerCollectionType) { RenderMap(g, layerCollectionType, true); }
#pragma warning disable 612,618 /// <summary> /// Method called when <paramref name="layer"/> of <paramref name="layerCollectionType"/> has been rendered. This fires the /// <see cref="E:SharpMap.Map.LayerRendered"/> and <see cref="E:SharpMap.Map.LayerRenderedEx"/> event. /// </summary> /// <param name="layer">The layer to render</param> /// <param name="layerCollectionType">The collection type</param> protected virtual void OnLayerRendered(ILayer layer, LayerCollectionType layerCollectionType) { var e = LayerRendered; #pragma warning restore 612,618 if (e != null) e(this, EventArgs.Empty); var eex = LayerRenderedEx; if (eex != null) eex(this, new LayerRenderingEventArgs(layer, layerCollectionType)); }
/// <summary> /// Method called when starting to render <paramref name="layer"/> of <paramref name="layerCollectionType"/>. This fires the /// <see cref="E:SharpMap.Map.LayerRendering"/> event. /// </summary> /// <param name="layer">The layer to render</param> /// <param name="layerCollectionType">The collection type</param> protected virtual void OnLayerRendering(ILayer layer, LayerCollectionType layerCollectionType) { var e = LayerRendering; if (e != null) e(this, new LayerRenderingEventArgs(layer, layerCollectionType)); }
/// <summary> /// Creates an instance of this class /// </summary> /// <param name="layer">The layer that is being or has been rendered</param> /// <param name="layerCollectionType">The layer collection type the layer belongs to.</param> public LayerRenderingEventArgs(ILayer layer, LayerCollectionType layerCollectionType) { Layer = layer; LayerCollectionType = layerCollectionType; }
public void Map_TileAsyncReplacedFromGroup_DoesNotFireMapNewTileAvailable(LayerCollectionType collectionType) { var map = new Map(); var group = CreateLayerGroup(); map.GetCollection(collectionType).Add(group); var tileLayer = CreateTileAsyncLayer(); AddTileLayerToLayerGroup(tileLayer, group); var newTileLayer = CreateTileAsyncLayer(); ReplaceExistingAsyncLayerFromGroup(group, tileLayer, newTileLayer); var eventSource = map.GetMapNewTileAvailableAsObservable(); RaiseMapNewtileAvailableOn(tileLayer); Assert.That(eventSource.IsEmpty().First(), "Map should NOT fire MapNewTileAvailable event for TileAsyncLayers replaced from a group"); RaiseMapNewtileAvailableOn(newTileLayer); Assert.That(eventSource.Count().First(), Is.EqualTo(1), TestContext.CurrentContext.Test.GetDescription()); }
private void AddTileLayerToMap(Tuple <Mock <ILayer>, Mock <ITileAsyncLayer> > tileLayer, Map map, LayerCollectionType collectionType = LayerCollectionType.Background) { var layer = tileLayer.Item1.Object; map.GetCollection(collectionType).Add(layer); }
/// <summary> /// Renders the map using the provided <see cref="Graphics"/> object. /// </summary> /// <param name="g">the <see cref="Graphics"/> object to use</param> /// <param name="layerCollectionType">the <see cref="LayerCollectionType"/> to use</param> /// <exception cref="ArgumentNullException">if <see cref="Graphics"/> object is null.</exception> /// <exception cref="InvalidOperationException">if there are no layers to render.</exception> public void RenderMap(Graphics g, LayerCollectionType layerCollectionType) { if (g == null) throw new ArgumentNullException("g", "Cannot render map with null graphics object!"); VariableLayerCollection.Pause = true; LayerCollection lc = null; switch (layerCollectionType) { case LayerCollectionType.Static: lc = Layers; break; case LayerCollectionType.Variable: lc = VariableLayers; break; case LayerCollectionType.Background: lc = BackgroundLayer; break; } if (lc== null || lc.Count == 0) throw new InvalidOperationException("No layers to render"); Matrix transform = g.Transform; g.Transform = MapTransform; g.Clear(BackColor); g.PageUnit = GraphicsUnit.Pixel; //int srid = (Layers.Count > 0 ? Layers[0].SRID : -1); //Get the SRID of the first layer ILayer[] layerList = new ILayer[lc.Count]; lc.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.Enabled && layer.MaxVisible >= Zoom && layer.MinVisible < Zoom) layer.Render(g, this); } g.Transform = transform; if (layerCollectionType == LayerCollectionType.Static) RenderDisclaimer(g); VariableLayerCollection.Pause = false; }
public void Map_TileAsyncAddedToDetachedCollection_DoesNotFireMapNewTileAvailable(LayerCollectionType collectionType) { var map = new Map(); var group = CreateLayerGroup(); map.GetCollection(collectionType).Add(group); var detachedCollection = group.Layers; group.Layers = new ObservableCollection<ILayer>(); var tileAsync = CreateTileAsyncLayer(); detachedCollection.Add(tileAsync.Item1.Object); var eventSource = map.GetMapNewTileAvailableAsObservable(); RaiseMapNewtileAvailableOn(tileAsync); Assert.That(eventSource.Count().First(), Is.EqualTo(0), TestContext.CurrentContext.Test.GetDescription()); }
public void Map_TileAsyncRemovedFromNephew_DoesNotFireMapNewtileAvailable(LayerCollectionType collectionType) { var map = new Map(); var group = CreateLayerGroup(); map.GetCollection(collectionType).Add(group); var subGroup = CreateLayerGroup("subgroup"); var tileAsyncLayer = CreateTileAsyncLayer(); AddTileLayerToLayerGroup(tileAsyncLayer, subGroup); group.Layers.Add(subGroup); // test RemoveTileLayerFromGroup(subGroup, tileAsyncLayer); var eventSource = map.GetMapNewTileAvailableAsObservable(); RaiseMapNewtileAvailableOn(tileAsyncLayer); Assert.That(eventSource.Count().First(), Is.EqualTo(0), TestContext.CurrentContext.Test.GetDescription()); }
public void MapDoesNoGenerateMapNewTile_AfterClear(LayerCollectionType collectionType) { var map = new Map(); var tileAsyncLayer = CreateTileAsyncLayer(); AddTileLayerToMap(tileAsyncLayer, map, collectionType); var eventSource = map.GetMapNewTileAvailableAsObservable(); map.GetCollection(collectionType).Clear(); RaiseMapNewtileAvailableOn(tileAsyncLayer); Assert.That(eventSource.IsEmpty().First(), TestContext.CurrentContext.Test.GetDescription()); }
/// <summary> /// Renders the map using the provided <see cref="Graphics"/> object. /// </summary> /// <param name="g">the <see cref="Graphics"/> object to use</param> /// <param name="layerCollectionType">the <see cref="LayerCollectionType"/> to use</param> /// <param name="drawMapDecorations">Set whether to draw map decorations on the map (if such are set)</param> /// <param name="drawTransparent">Set wether to draw with transparent background or with BackColor as background</param> /// <exception cref="ArgumentNullException">if <see cref="Graphics"/> object is null.</exception> /// <exception cref="InvalidOperationException">if there are no layers to render.</exception> public void RenderMap(Graphics g, LayerCollectionType layerCollectionType, bool drawMapDecorations, bool drawTransparent) { if (g == null) { throw new ArgumentNullException("g", "Cannot render map with null graphics object!"); } VariableLayerCollection.Pause = true; LayerCollection lc = null; switch (layerCollectionType) { case LayerCollectionType.Static: lc = Layers; break; case LayerCollectionType.Variable: lc = VariableLayers; break; case LayerCollectionType.Background: lc = BackgroundLayer; break; } if (lc == null || lc.Count == 0) { throw new InvalidOperationException("No layers to render"); } Matrix transform = g.Transform; lock (MapTransform) { g.Transform = MapTransform.Clone(); } if (!drawTransparent) { g.Clear(BackColor); } g.PageUnit = GraphicsUnit.Pixel; ILayer[] layerList = new ILayer[lc.Count]; lc.CopyTo(layerList, 0); foreach (ILayer layer in layerList) { if (layer.Enabled && layer.MaxVisible >= Zoom && layer.MinVisible < Zoom) { layer.Render(g, this); } } if (drawTransparent) { g.Transform = transform; } if (layerCollectionType == LayerCollectionType.Static) { #pragma warning disable 612,618 RenderDisclaimer(g); #pragma warning restore 612,618 if (drawMapDecorations) { foreach (var mapDecoration in Decorations) { mapDecoration.Render(g, this); } } } VariableLayerCollection.Pause = false; }
private void AddTileLayerToMap(Tuple<Mock<ILayer>, Mock<ITileAsyncLayer>> tileLayer, Map map, LayerCollectionType collectionType = LayerCollectionType.Background) { var layer = tileLayer.Item1.Object; map.GetCollection(collectionType).Add(layer); }
public void MapGeneratesMapNewTile_NewReplacedLayers(LayerCollectionType collectionType) { var map = new Map(); var tileAsyncLayer = CreateTileAsyncLayer(); AddTileLayerToMap(tileAsyncLayer, map, collectionType); var eventSource = map.GetMapNewTileAvailableAsObservable(); var newLayer = CreateTileAsyncLayer(); map.GetCollection(collectionType)[0] = newLayer.Item1.Object; RaiseMapNewtileAvailableOn(newLayer); Assert.That(eventSource.Count().First(), Is.EqualTo(1), TestContext.CurrentContext.Test.GetDescription()); }
public void Map_TileAsyncAddedToReplacedCollection_FiresMapNewtileAvailable(LayerCollectionType collectionType) { var map = new Map(); var group = CreateLayerGroup(); map.GetCollection(collectionType).Add(group); group.Layers = new ObservableCollection<ILayer>(); var tileAsync = CreateTileAsyncLayer(); AddTileLayerToLayerGroup(tileAsync, group); var eventSource = map.GetMapNewTileAvailableAsObservable(); RaiseMapNewtileAvailableOn(tileAsync); Assert.That(eventSource.Count().First(), Is.EqualTo(1), TestContext.CurrentContext.Test.GetDescription()); }
public void AfterRemovingTileAsyncLayer_MapDoesNotHookAnymoreItsMapNewTileAvailableEvent(LayerCollectionType collectionType) { var map = new Map(); var tileAsyncLayer = CreateTileAsyncLayer(); AddTileLayerToMap(tileAsyncLayer, map, collectionType); var eventSource = map.GetMapNewTileAvailableAsObservable(); map.GetCollection(collectionType).RemoveAt(0); RaiseMapNewtileAvailableOn(tileAsyncLayer); Assert.That(eventSource.Count().First(), Is.EqualTo(0), TestContext.CurrentContext.Test.GetDescription()); }
public void AfterRemovingTileAsyncLayer_MapDoesNotHookAnymoreItsMapNewTileAvailableEvent(LayerCollectionType collectionType) { var map = new Map(); var tileAsyncLayer = CreateTileAsyncLayer(); AddTileLayerToMap(tileAsyncLayer, map, collectionType); var eventSource = map.GetMapNewTileAvailableAsObservable(); map.GetCollection(collectionType).RemoveAt(0); RaiseMapNewtileAvailableOn(tileAsyncLayer); Assert.That(eventSource.Count().First(), Is.EqualTo(0), TestContext.CurrentContext.Test.GetDescription()); }
/// <summary> /// Renders the map using the provided <see cref="Graphics"/> object. /// </summary> /// <param name="g">the <see cref="Graphics"/> object to use</param> /// <param name="layerCollectionType">the <see cref="LayerCollectionType"/> to use</param> /// <exception cref="ArgumentNullException">if <see cref="Graphics"/> object is null.</exception> /// <exception cref="InvalidOperationException">if there are no layers to render.</exception> public void RenderMap(Graphics g, LayerCollectionType layerCollectionType) { RenderMap(g, layerCollectionType, true, false); }
public void Map_TileAsyncFromClearedGroup_DoesNotFireMapNewTileAvailable(LayerCollectionType collectionType) { var map = new Map(); var group = CreateLayerGroup(); map.GetCollection(collectionType).Add(group); var tileLayer = CreateTileAsyncLayer(); AddTileLayerToLayerGroup(tileLayer, group); group.Layers.Clear(); var eventSource = map.GetMapNewTileAvailableAsObservable(); RaiseMapNewtileAvailableOn(tileLayer); Assert.That(eventSource.IsEmpty().First(), TestContext.CurrentContext.Test.GetDescription()); }
/// <summary> /// Creates an instance of this class /// </summary> /// <param name="layer">The layer that is being or has been rendered</param> /// <param name="layerCollectionType">The layer collection type the layer belongs to.</param> public LayerRenderingEventArgs(ILayer layer, LayerCollectionType layerCollectionType) { Layer = layer; LayerCollectionType = layerCollectionType; }
public void Map_TileAsyncAddedToDetachedCollection_DoesNotFireMapNewTileAvailable(LayerCollectionType collectionType) { var map = new Map(); var group = CreateLayerGroup(); map.GetCollection(collectionType).Add(group); var detachedCollection = group.Layers; group.Layers = new ObservableCollection <ILayer>(); var tileAsync = CreateTileAsyncLayer(); detachedCollection.Add(tileAsync.Item1.Object); var eventSource = map.GetMapNewTileAvailableAsObservable(); RaiseMapNewtileAvailableOn(tileAsync); Assert.That(eventSource.Count().First(), Is.EqualTo(0), TestContext.CurrentContext.Test.GetDescription()); }
public void AddingTileAsyncLayers_HookItsMapNewTileAvaliableEvent(LayerCollectionType collectionType) { var map = new Map(); var layer = CreateTileAsyncLayer(); AddTileLayerToMap(layer, map, collectionType); var eventSource = map.GetMapNewTileAvailableAsObservable(); RaiseMapNewtileAvailableOn(layer); Assert.That(eventSource.Count().First(), Is.EqualTo(1), TestContext.CurrentContext.Test.GetDescription()); }
private Image GetMap(Map map, LayerCollection layers, LayerCollectionType layerCollectionType, BoundingBox extent) { if ((layers == null || layers.Count == 0 || Width == 0 || Height == 0)) { if (layerCollectionType == LayerCollectionType.Background) return new Bitmap(1, 1); return null; } var retval = new Bitmap(Width, Height); using(var g = Graphics.FromImage(retval)) { map.RenderMap(g, layerCollectionType, false); } if (layerCollectionType == LayerCollectionType.Variable) retval.MakeTransparent(_map.BackColor); return retval; }
private Image GetMap(LayerCollection layers, LayerCollectionType layerCollectionType) { if ((layers == null || layers.Count == 0 || Width == 0 || Height == 0)) { if (layerCollectionType == LayerCollectionType.Background) return new Bitmap(1, 1); return null; } var retval = new Bitmap(Width, Height); Graphics g = Graphics.FromImage(retval); _map.RenderMap(g, layerCollectionType, false); g.Dispose(); if (layerCollectionType == LayerCollectionType.Variable) retval.MakeTransparent(_map.BackColor); return retval; }
private Image GetMap(Map map, LayerCollection layers, LayerCollectionType layerCollectionType, Envelope extent) { try { var width = Width; var height = Height; if ((layers == null || layers.Count == 0 || width <= 0 || height <= 0)) { if (layerCollectionType == LayerCollectionType.Background) return new Bitmap(1, 1); return null; } var retval = new Bitmap(width, height); using (var g = Graphics.FromImage(retval)) { g.Clear(Color.Transparent); map.RenderMap(g, layerCollectionType, false, true); } /*if (layerCollectionType == LayerCollectionType.Variable) retval.MakeTransparent(_map.BackColor); else if (layerCollectionType == LayerCollectionType.Static && map.BackgroundLayer.Count > 0) retval.MakeTransparent(_map.BackColor);*/ return retval; } catch (Exception ee) { Logger.Error("Error while rendering map", ee); if (layerCollectionType == LayerCollectionType.Background) return new Bitmap(1, 1); return null; } }