Example #1
0
        public void ZoomToBox(Geometries.Point beginPoint, Geometries.Point endPoint)
        {
            var width  = Math.Abs(endPoint.X - beginPoint.X);
            var height = Math.Abs(endPoint.Y - beginPoint.Y);

            if (width <= 0)
            {
                return;
            }
            if (height <= 0)
            {
                return;
            }

            ZoomHelper.ZoomToBoudingbox(
                beginPoint.X, beginPoint.Y, endPoint.X, endPoint.Y,
                Map.Viewport.Width, Map.Viewport.Height,
                out var x, out var y, out var resolution);

            resolution = ViewportLimiter.LimitResolution(resolution, _map.Viewport.Width, _map.Viewport.Height, _map.ZoomMode, _map.ZoomLimits,
                                                         _map.Resolutions, _map.Envelope);

            _map.Viewport.Resolution = resolution;

            _map.Viewport.Center = new Geometries.Point(x, y);


            _map.RefreshData(true);
            RefreshGraphics();
            ClearBBoxDrawing();
        }
Example #2
0
        private double DetermineNewResolution(int mouseWheelDelta, double currentResolution)
        {
            if (mouseWheelDelta > 0)
            {
                var resolution = ZoomHelper.ZoomIn(_map.Resolutions, currentResolution);

                return(ViewportLimiter.LimitResolution(resolution, Viewport.Width, Viewport.Height,
                                                       _map.Limits.ZoomMode, _map.Limits.ZoomLimits, _map.Resolutions, _map.Envelope));
            }
            if (mouseWheelDelta < 0)
            {
                var resolution = ZoomHelper.ZoomOut(_map.Resolutions, currentResolution);

                return(ViewportLimiter.LimitResolution(resolution, Viewport.Width, Viewport.Height,
                                                       _map.Limits.ZoomMode, _map.Limits.ZoomLimits, _map.Resolutions, _map.Envelope));
            }
            return(currentResolution);
        }