private void CalculateStartViewBounds(Size size) { if (this._cacheBounds != null && this._origin == null) { Utility.Rectangle2D bounds = this._cacheBounds; double width = size.Width; double height = size.Height; double resWidth = bounds.Width / width; double resHeight = bounds.Height / height; _mapResolution = (resHeight > resWidth) ? resHeight : resWidth; _origin = new Utility.Point2D(bounds.Center.X - width * 0.5 * _mapResolution, bounds.Center.Y + height * 0.5 * _mapResolution); _cacheBounds = new Utility.Rectangle2D(this.ViewBounds); SetOriginAndResolution(_mapResolution, new Utility.Point2D(_origin)); } }
private Utility.Rectangle2D GetFullViewBounds() { if (double.IsNaN(this._mapResolution)) { return null; } Utility.Point2D point = Screen2Map(new Point(0.0, 0.0)); Utility.Point2D point2 = Screen2Map(new Point(0.0, _currentSize.Height)); Utility.Point2D point3 = Screen2Map(new Point(_currentSize.Width, _currentSize.Height)); Utility.Point2D point4 = Screen2Map(new Point(_currentSize.Width, 0.0)); if (point == null || point2 == null || point3 == null || point4 == null) { return null; } Utility.Rectangle2D pointBounds = new Utility.Rectangle2D(point, point); Utility.Rectangle2D point2Bounds = new Utility.Rectangle2D(point2, point2); Utility.Rectangle2D point3Bounds = new Utility.Rectangle2D(point3, point3); Utility.Rectangle2D point4Bounds = new Utility.Rectangle2D(point4, point4); Utility.Rectangle2D bounds = pointBounds; bounds.Union(point2Bounds); bounds.Union(point3Bounds); bounds.Union(point4Bounds); return bounds; }
private void Layers_LayersInitialized(object sender, EventArgs e) { if (_origin == null) { Utility.Rectangle2D bounds = this.Bounds; if (bounds.IsEmpty) { return; } if (ViewBounds != null) { bounds = ViewBounds; } _cacheBounds = bounds; if ((_currentSize.Width == 0.0) || (_currentSize.Height == 0.0)) { base.Dispatcher.BeginInvoke(delegate { this.Layers_LayersInitialized(sender, e); }); return; } } this.CalculateStartViewBounds(_currentSize); foreach (Layer layer in this.Layers) { this.AssignLayerContainer(layer); } this.LoadLayersInView(false, this.GetFullViewBounds()); }