/// <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); }
/// <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); }