예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <summary>
        /// Clones the scene.
        /// </summary>
        /// <returns>The cloned scene.</returns>
        public Scene CloneScene()
        {
            var index = new Dictionary <IVisual, IVisualNode>();
            var root  = Clone((VisualNode)Root, null, index);

            var result = new Scene(root, index, Layers.Clone(), Generation + 1)
            {
                Size    = Size,
                Scaling = Scaling,
            };

            return(result);
        }
예제 #3
0
        /// <summary>
        /// Overridden to clone the inner objects.
        /// </summary>
        /// <returns>A deep clone of the <see cref="Map"/> field.</returns>
        public override object Clone()
        {
            // base.Clone() sets Font, which causes OnPropertyChanged,
            // which in turn disposes the clone's - i.e. OUR - image.
            // So we want to stop this bespredel:
            var tmpImage = _image;

            _image = null;
            Map clone = (Map)base.Clone();

            clone._c1mapper     = new C1Mapper(clone);
            clone.MarkerStyles  = (MarkerStyleCollection)MarkerStyles.Clone(clone);
            clone.LineStyles    = (LineStyleCollection)LineStyles.Clone(clone);
            clone.KmlItemStyles = (KmlItemStyleCollection)KmlItemStyles.Clone(clone);
            clone.Layers        = (LayerCollection)Layers.Clone(clone);
            clone.Legends       = (LegendCollection)Legends.Clone(clone);
            _image = tmpImage;
            return(clone);
        }
예제 #4
0
파일: Map.cs 프로젝트: cugkgq/Project
        /// <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);
        }
예제 #5
0
        private GetImage PrepareGetImage()
        {
            // create a new GetImage request, set the extent and image size

            GetImage getImage = new GetImage();

            getImage.Properties.ImageSize.Width  = Width;
            getImage.Properties.ImageSize.Height = Height;
            getImage.Properties.Envelope         = VisibleExtent;

            if (Resolution != 1)
            {
                if (_service.IsArcMap)
                {
                    getImage.Properties.ImageSize.Width  = Convert.ToInt32(Width * Resolution);
                    getImage.Properties.ImageSize.Height = Convert.ToInt32(Height * Resolution);
                    getImage.Properties.ImageSize.Dpi    = Convert.ToInt32(DataFrame.Dpi * Resolution);
                }
                else
                {
                    getImage.Properties.ImageSize.PrintWidth   = Convert.ToInt32(Width * Resolution);
                    getImage.Properties.ImageSize.PrintHeight  = Convert.ToInt32(Height * Resolution);
                    getImage.Properties.ImageSize.ScaleSymbols = true;
                }
            }

            getImage.DataFrame = DataFrame.Name;

            // set the projection if necessary

            if (_coordinateSystem != null)
            {
                FeatureCoordSys featSys = new FeatureCoordSys();
                FilterCoordSys  filtSys = new FilterCoordSys();

                string csType = _coordinateSystem.Substring(0, 6);

                if (csType == "PROJCS" || csType == "GEOGCS")
                {
                    featSys.String = _coordinateSystem;
                    filtSys.String = _coordinateSystem;
                }
                else
                {
                    featSys.ID = _coordinateSystem;
                    filtSys.ID = _coordinateSystem;
                }

                getImage.Properties.FeatureCoordSys = featSys;
                getImage.Properties.FilterCoordSys  = filtSys;
            }

            // set the background color if one was specified

            if (BackgroundColor != Color.Empty)
            {
                getImage.Properties.Background = new Background(BackgroundColor);

                if (Transparent)
                {
                    getImage.Properties.Background.TransparentColor = BackgroundColor;
                }
            }

            // set the image format if one was specified

            if (ImageType != CommonImageType.Default)
            {
                getImage.Properties.Output = new Output();

                switch (ImageType)
                {
                case CommonImageType.Jpg: getImage.Properties.Output.Type = ArcXml.ImageType.Jpg; break;

                case CommonImageType.Png: getImage.Properties.Output.Type = ArcXml.ImageType.Png24; break;
                }
            }

            // add layers to the request that were specified in code

            getImage.Properties.LayerList = (LayerList)_layerList.Clone();

            if (_layers.Count > 0)
            {
                getImage.Layers = (Layers)_layers.Clone();
            }

            if (_acetateLayer.Objects != null && _acetateLayer.Objects.Count > 0)
            {
                if (getImage.Layers == null)
                {
                    getImage.Layers = new Layers();
                }

                getImage.Layers.Add((Layer)_acetateLayer.Clone());
                getImage.Properties.LayerList.Add(new LayerDef(_acetateLayer.ID));
            }

            return(getImage);
        }