private void CalculateStartViewBounds(Size size)
{
if (!Rectangle2D.IsNullOrEmpty(cacheViewBounds) && Point2D.IsNullOrEmpty(origin))
{
Rectangle2D cacheBounds = cacheViewBounds;
Point currentOffset = this.panHelper.GetCurrentOffset();
double x = currentOffset.X;
double y = currentOffset.Y;
double width = size.Width;
double height = size.Height;
double resWidth = cacheBounds.Width / width;
double resHeight = cacheBounds.Height / height;
mapResolution = (resHeight > resWidth) ? resHeight : resWidth;
double nearestLevelResolution = MathUtil.GetNearest(this.mapResolution, this.Resolutions, MinResolution, MaxResolution);
mapResolution = nearestLevelResolution;
targetResolution = this.mapResolution = MathUtil.MinMaxCheck(this.mapResolution, MinResolution, MaxResolution);
//origin = new Point2D(bounds.Left + bounds.Width * 0.5 - width * 0.5 * mapResolution, bounds.Top - bounds.Height * 0.5 + height * 0.5 * mapResolution);
origin = new Point2D(cacheBounds.Center.X - width * 0.5 * mapResolution, cacheBounds.Center.Y + height * 0.5 * mapResolution);
//地图的中心 加 减 ViewSize大小乘以分辨率 即 初始化Origin
cacheViewBounds = ViewBounds;//由origin和resolution重新算出来的VB赋给cacheVB,这是真正的VB
RaiseViewBoundsChanged();
}
}