예제 #1
0
        private void ZoomToPoint(Point zoomPoint, double newZoomLevel)
        {
            var doublePoint = new DoublePoint()
            {
                X = zoomPoint.X, Y = zoomPoint.Y
            };

            // calculate source point BEFORE the zoom is applied since this changes the ViewportWidth value
            var logicalSourcePoint = this.map.ConvertPixelToLogicalCoordinate(doublePoint);

            newZoomLevel = Math.Max(newZoomLevel, 1);
            var context = new ViewChangedContext()
            {
                PreviousZoomLevel = this.map.ZoomLevel,
                PreviousCenter    = this.map.Center,
                NewZoomLevel      = newZoomLevel
            };

            this.map.ZoomLevel = newZoomLevel;

            var logicalTargetPoint = this.map.ConvertPixelToLogicalCoordinate(doublePoint);

            var shift = new DoublePoint()
            {
                X = logicalSourcePoint.X - logicalTargetPoint.X, Y = logicalSourcePoint.Y - logicalTargetPoint.Y
            };

            var logicalCenter = this.map.SpatialReference.ConvertGeographicToLogicalCoordinate(this.map.Center);

            logicalCenter.X += shift.X;
            logicalCenter.Y += shift.Y;

            context.NewCenter = this.map.SpatialReference.ConvertLogicalToGeographicCoordinate(logicalCenter);
            this.ExecuteViewChangedCommand(context);
        }
예제 #2
0
        /// <summary>
        /// Method is internal for the sake of unit-testing.
        /// </summary>
        /// <param name="translation">The translation.</param>
        internal void OnPan(Point translation)
        {
            if (!this.IsPanEnabled)
            {
                return;
            }

            // NOTE: We can set directly the scroll offset but we need to pass through the coercion mechanism for the Center property instead.
            var centerAfterPan = this.map.SpatialReference.ConvertGeographicToLogicalCoordinate(this.map.Center);

            double pixelFactorX = this.map.ViewportWidth / this.map.CurrentSize.Width;
            double pixelFactorY = this.map.ViewportWidth * this.map.AspectRatio / this.map.CurrentSize.Height;

            centerAfterPan.X -= translation.X * pixelFactorX;
            centerAfterPan.Y -= translation.Y * pixelFactorY;

            double zoom    = this.map.ZoomLevel;
            var    context = new ViewChangedContext()
            {
                PreviousZoomLevel = zoom,
                PreviousCenter    = this.map.Center,
                NewCenter         = map.SpatialReference.ConvertLogicalToGeographicCoordinate(centerAfterPan),
                NewZoomLevel      = zoom
            };

            this.ExecuteViewChangedCommand(context);
        }
예제 #3
0
        internal override void OnViewChanged(ViewChangedContext context)
        {
            base.OnViewChanged(context);

            if (this.shapeLabelLayoutStrategyCache != null && context.NewZoomLevel != context.PreviousZoomLevel)
            {
                // we need to re-evaluate the labels upon each zoom since some labels may depend on the zoom level
                this.ReevaluateShapeLabelStrategy();
            }
        }
예제 #4
0
        private void ExecuteViewChangedCommand(ViewChangedContext context)
        {
            if (context.PreviousCenter == context.NewCenter && context.PreviousZoomLevel == context.NewZoomLevel)
            {
                // no actual change, do not raise the ViewChanged command
                return;
            }

            if (!this.map.CommandService.ExecuteCommand(CommandId.ViewChanged, context))
            {
                // command isn't executed, rollback the previous zoom level (Center value does not need to be rolled back as it hasn't been changed yet).
                this.map.ZoomLevel = context.PreviousZoomLevel;
            }
        }
예제 #5
0
        private void NotifyViewChanged(ViewChangedContext context)
        {
            if (!this.IsTemplateApplied)
            {
                return;
            }

            foreach (var layer in this.layers)
            {
                layer.OnViewChanged(context);
            }

            foreach (MapBehavior behavior in this.behaviors)
            {
                behavior.OnMapViewChanged(context);
            }
        }
예제 #6
0
        /// <summary>
        /// Sets the provided <see cref="LocationRect"/> value as the current view of the map.
        /// </summary>
        /// <param name="boundingRect"></param>
        public void SetView(LocationRect boundingRect)
        {
            boundingRect = this.CoerceLocationRect(boundingRect);
            if (boundingRect.IsEmpty)
            {
                return;
            }

            if (!this.arrangePassed)
            {
                this.deferredBoundingRect = boundingRect;
                return;
            }

            var topLeft       = this.SpatialReference.ConvertGeographicToLogicalCoordinate(boundingRect.Northwest);
            var bottomRight   = this.SpatialReference.ConvertGeographicToLogicalCoordinate(boundingRect.Southeast);
            var logicalCenter = new DoublePoint()
            {
                X = (topLeft.X + bottomRight.X) / 2d, Y = (topLeft.Y + bottomRight.Y) / 2d
            };

            Location center = this.SpatialReference.ConvertLogicalToGeographicCoordinate(logicalCenter);

            double viewportWidth  = bottomRight.X - topLeft.X;
            double viewportHeight = bottomRight.Y - topLeft.Y;

            double zoomWidth  = Math.Log(this.currentSize.Width / TileSize.Width / viewportWidth, 2d);
            double zoomHeight = Math.Log(this.currentSize.Height / TileSize.Height / viewportHeight, 2d);
            double zoomLevel  = Math.Min(zoomWidth, zoomHeight);

            var context = new ViewChangedContext()
            {
                NewCenter         = center,
                NewZoomLevel      = zoomLevel,
                PreviousCenter    = this.Center,
                PreviousZoomLevel = this.ZoomLevel
            };

            this.OnViewChanged(context);
        }
예제 #7
0
        private void ZoomToCenter(double newZoomLevel)
        {
            var logicalSourcePoint = this.map.SpatialReference.ConvertGeographicToLogicalCoordinate(this.map.Center);

            newZoomLevel = Math.Max(newZoomLevel, 1);
            var context = new ViewChangedContext()
            {
                PreviousZoomLevel = this.map.ZoomLevel,
                PreviousCenter    = this.map.Center,
                NewZoomLevel      = newZoomLevel
            };

            this.map.ZoomLevel = newZoomLevel;

            var logicalTargetPoint = this.map.SpatialReference.ConvertGeographicToLogicalCoordinate(this.map.Center);

            Point shift = new Point(logicalSourcePoint.X - logicalTargetPoint.X, logicalSourcePoint.Y - logicalTargetPoint.Y);

            logicalTargetPoint.X += shift.X;
            logicalTargetPoint.Y += shift.Y;

            context.NewCenter = this.map.SpatialReference.ConvertLogicalToGeographicCoordinate(logicalTargetPoint);
            this.ExecuteViewChangedCommand(context);
        }
예제 #8
0
        /// <summary>
        /// A callback from the owning <see cref="RadMap" /> instance that notifies for a view change event.
        /// </summary>
        /// <param name="context">The context.</param>
        protected internal override void OnMapViewChanged(ViewChangedContext context)
        {
            base.OnMapViewChanged(context);

            this.HideToolTip();
        }
예제 #9
0
        internal void OnViewChanged(ViewChangedContext context)
        {
            this.SetView(context.NewZoomLevel, context.NewCenter);

            this.NotifyViewChanged(context);
        }
예제 #10
0
 /// <summary>
 /// A callback from the owning <see cref="RadMap" /> instance that notifies for a view change event.
 /// </summary>
 /// <param name="context">The context.</param>
 protected internal virtual void OnMapViewChanged(ViewChangedContext context)
 {
 }
예제 #11
0
        internal override void OnViewChanged(ViewChangedContext context)
        {
            base.OnViewChanged(context);

            this.UpdateUI();
        }
예제 #12
0
 internal virtual void OnViewChanged(ViewChangedContext context)
 {
 }