Exemplo n.º 1
0
        /// <summary>
        /// Adds map element to the new layout.
        /// </summary>
        /// <param name="mapScale">The map scale.</param>
        /// <param name="extents">The extents.</param>
        private void AddMapElement(int mapScale, IEnvelope extents)
        {
            var map = _context.Map;

            var mapElement = new LayoutMap();

            mapElement.Initialize(map, View.LayoutControl);
            mapElement.IsMain       = true;
            mapElement.TileProvider = _context.Map.TileProvider;

            mapElement.LocationF = new PointF(PrintingConstants.DefaultMapOffset, PrintingConstants.DefaultMapOffset);
            mapElement.DrawTiles = map.Tiles.Visible;

            // calc the necessary size in paper coordinates
            GeoSize size;

            if (map.GetGeodesicSize(extents, out size))
            {
                mapElement.SizeF = LayoutScaleHelper.CalcMapSize(mapScale, size, extents.Width / extents.Height);

                mapElement.Envelope    = extents.Clone();
                mapElement.Initialized = true;

                View.LayoutControl.AddToLayout(mapElement);

                View.LayoutControl.UpdateLayout();

                View.LayoutControl.ZoomFitToScreen();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculates canvas size in pixels.
        /// </summary>
        private bool CalculateCanvasSize(out SizeF size)
        {
            size = default(SizeF);

            var extents = View.MapExtents;

            GeoSize geoSize;

            if (!_context.Map.GetGeodesicSize(extents, out geoSize))
            {
                return(false);
            }

            if (!NumericHelper.Equal(View.MapScale, 0.0))
            {
                size = LayoutScaleHelper.CalcMapSize(View.MapScale, geoSize, extents.Width / extents.Height);
            }

            return(true);
        }