internal void SetMinTileNumber(int tilesCount) { int minNumber = 0; int counter = tilesCount; for (int i = this.LevelCount; i > 0; i--) { minNumber += counter; counter /= 2; if (counter < 4) { minNumber += 4 * i; break; } } this.minTileNumber = minNumber + 1; TilesDownloadManager downloader = this.downloadManager; if (downloader != null) { downloader.MinTileNumber = this.minTileNumber; } }
private void Process() { MultiscaleImageViewport viewport = this.parameters; if (viewport.ActualWidth > 0 && viewport.ViewportWidth > 0) { this.zoomLevelShift = (int)Math.Round(Math.Log(viewport.TileWidth, 2)); double zoom = viewport.ActualWidth / viewport.TileWidth / viewport.ViewportWidth; double zoomLevel = Math.Log(zoom, 2d); double currentZoom = Math.Round(zoomLevel); double scaleFactor = Math.Pow(2, zoomLevel - currentZoom); double tileWidth = viewport.TileWidth * scaleFactor; double tileHeight = viewport.TileHeight * scaleFactor; Rect imageRect = TilesDownloadManager.GetImageBounds(zoom, viewport); if (!imageRect.IsEmpty) { this.endLevel = (int)Math.Ceiling(Math.Log(zoom, 2d)); this.startTileX = (int)(imageRect.X / tileWidth); this.startTileY = (int)(imageRect.Y / tileHeight); this.endTileX = (int)Math.Ceiling(imageRect.Right / tileWidth) - 1; this.endTileY = (int)Math.Ceiling(imageRect.Bottom / tileHeight) - 1; int endLevel3 = this.endLevel - 2; endLevel3 = endLevel3 >= 0 ? endLevel3 : 0; this.RequestTop3Levels(endLevel3); this.RequestOtherLevels(endLevel3); this.UpdateTileChache(); } } }
internal void ProcessTilesDownload(MultiscaleImageViewport state) { if (!(this is EmptyTileMapSource)) { TilesDownloadManager manager = null; if (this.downloadManager == null) { TilesDownloadManager downloader = new TilesDownloadManager(this); downloader.MaxTileCacheSize = this.maxTileCacheSize; downloader.MinTileNumber = this.minTileNumber; this.downloadManager = downloader; downloader.StartDownload(); } manager = this.downloadManager; state.TileWidth = this.tileWidth; state.TileHeight = this.tileHeight; if (manager != null) { manager.DoProcess(state); } } }
internal void StopDownload() { TilesDownloadManager manager = this.downloadManager; if (manager != null) { this.downloadManager = null; manager.StopDownload(); } }
/// <summary> /// Sets maximal size of tile cache. /// </summary> /// <param name="bytes">The size in bytes.</param> public void SetTileCacheSize(int bytes) { this.maxTileCacheSize = bytes; TilesDownloadManager downloader = this.downloadManager; if (downloader != null) { downloader.MaxTileCacheSize = this.maxTileCacheSize; } }
/// <summary> /// Invalidates specified tile layers. /// </summary> /// <param name="tileLevel">Tile level.</param> /// <param name="tilePositionX">X position of the tile.</param> /// <param name="tilePositionY">Y position of the tile.</param> /// <param name="tileLayer">Layer of the tile.</param> public virtual void InvalidateTileLayer(int tileLevel, int tilePositionX, int tilePositionY, int tileLayer) { TilesDownloadManager manager = this.downloadManager; if (manager != null) { TileId tileId = new TileId(tileLevel, tilePositionX, tilePositionY); manager.RemoveRequest(tileId); manager.Refresh(); } }
internal TileSource GetTileSource(TileId tileId) { TileSource tileSource = null; TilesDownloadManager manager = this.downloadManager; if (manager != null) { tileSource = manager.GetTileSource(tileId); } return(tileSource); }
private void UpdateTile(TileDownloadState e) { TilesDownloadManager manager = this.downloadManager; if (manager != null) { TileSource tileSource = new TileSource(e.TileId, e.TileBody); manager.UpdateRequest(tileSource); if (e.TileBody != null && manager.ValidateTile(e.TileId)) { this.OnTileAvailable(); } e.Dispose(); } }
private void AssyncImageCacheReader(TileDownloadState e) { TilesDownloadManager manager = this.downloadManager; if (manager != null) { if (e.TileBody == null) { TileDownloader downloader = new TileDownloader(e.TileId, e.Uri, this.AssyncImageReader, manager.ValidateTile); downloader.StartDownload(this.RequestCacheLevel, this.RequestCredentials, this.HttpUnauthorizedHandler); } else { this.UpdateTile(e); } } }