Пример #1
0
        private void UpdatePreview(bool fullExtents)
        {
            int layersCount = _mainMap.Layers.Count;

            if (layersCount == 0 &&
                (_mainMap.TileProvider == TileProvider.None || _mainMap.Projection.IsEmpty))
            {
                MessageService.Current.Info("Map is empty. It's not possible to create an overview image.");
                return;
            }

            if (fullExtents && layersCount == 0)
            {
                MessageService.Current.Info("No layers are loaded to make snapshot.");
                return;
            }

            IEnvelope e = fullExtents ? _mainMap.MaxExtents : _mainMap.Extents;

            e = e.Inflate(e.Width * 0.1, e.Height * 0.1);       // parameter can be introduced

            double ratio = _view.Width / (double)_view.Height;
            var    exts  = e.Adjust(ratio);

            var img = GetSnapshot(exts);

            if (img == null)
            {
                MessageService.Current.Warn("Failed to make screenshot.");
                return;
            }

            img.Dx               = (exts.MaxX - exts.MinX) / img.Width;
            img.Dy               = (exts.MaxY - exts.MinY) / img.Height;
            img.XllCenter        = exts.MinX + 0.5 * img.Dx;
            img.YllCenter        = exts.MinY + 0.5 * img.Dx; // TODO: Shouldn't this be img.Dy?
            img.DownsamplingMode = InterpolationType.HighQualityBicubic;
            img.UpsamplingMode   = InterpolationType.HighQualityBicubic;

            _view.UpdateImage(img);

            _view.UpdateLocatorBox(_mainMap.Extents);
        }