SuperMap.WindowsPhone.Mapping.Map.zoomTo C# (CSharp) Method

zoomTo() private method

private zoomTo ( Rectangle2D bounds, bool skipAnimation ) : void
bounds SuperMap.WindowsPhone.Core.Rectangle2D
skipAnimation bool
return void
        private void zoomTo(Rectangle2D bounds, bool skipAnimation)
        {
            if ((!Rectangle2D.IsNullOrEmpty(bounds)) && (bounds.Width != 0.0 || bounds.Height != 0.0))
            {
                Rectangle2D other = this.ViewBounds;
                if (Rectangle2D.IsNullOrEmpty(other))
                {
                    this.mapResolution = this.targetResolution = MathUtil.MinMaxCheck(Math.Max(bounds.Width / currentSize.Width, bounds.Height / currentSize.Height), MinResolution, MaxResolution);
                    Point2D center = bounds.Center;
                    this.origin = new Point2D(center.X - ((currentSize.Width * 0.5) * this.mapResolution), center.Y + ((currentSize.Height * 0.5) * this.mapResolution));
                    this.LoadLayersInView(false, this.GetFullViewBounds());
                }
                else if (double.IsNaN(this.mapResolution))
                {
                    this.cacheViewBounds = bounds;
                }//终于判断了
                else
                {
                    if (!bounds.IntersectsWith(other))
                    {
                        skipAnimation = true;
                    }//有相交的跳过动画

                    Point2D point2 = bounds.Center;
                    double nearestLevelResolution = MathUtil.GetNearest(MathUtil.MinMaxCheck(Math.Max(bounds.Width / currentSize.Width, bounds.Height / currentSize.Height), MinResolution, MaxResolution), this.Resolutions, MinResolution, MaxResolution);
                    bounds = new Rectangle2D(point2.X - ((currentSize.Width * nearestLevelResolution) * 0.5),
                        point2.Y - ((currentSize.Height * nearestLevelResolution) * 0.5),
                        point2.X + ((currentSize.Width * nearestLevelResolution) * 0.5),
                        point2.Y + ((currentSize.Height * nearestLevelResolution) * 0.5));


                    bounds = getAdjustedViewBounds(bounds, currentSize);

                    bool pan = DoubleUtil.AreClose(1.0, bounds.Width / other.Width);
                    if (!pan && (bounds.Width != 0.0 || bounds.Height != 0.0))
                    {
                        beginZoomToTargetBounds(bounds, skipAnimation);
                    }
                    else
                    {
                        //PanTo(bounds.Center, skipAnimation);//pan到这个点的bounds其实
                        panTo(bounds, skipAnimation);//10/3/12
                    }
                }
            }
        }