Exemple #1
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);
        }