Exemplo n.º 1
0
        internal TileSource GetTileSource(TileId tileId)
        {
            TileSource           tileSource = null;
            TilesDownloadManager manager    = this.downloadManager;

            if (manager != null)
            {
                tileSource = manager.GetTileSource(tileId);
            }

            return(tileSource);
        }
Exemplo n.º 2
0
        private void RemoveTile(TileId key)
        {
            TileSource tileSource = this.requests[key];

            if (tileSource != null)
            {
                this.tileCacheSize -= tileSource.Size;
                tileSource.Dispose();
            }

            this.requestList.Remove(key);
            this.requests.Remove(key);
        }
Exemplo n.º 3
0
        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();
            }
        }
Exemplo n.º 4
0
        internal TileSource GetTileSource(TileId tileId)
        {
            TileSource tileSource = null;

            if (!this.abort)
            {
                lock (this.requestsSyncronizer)
                {
                    if (this.requests.ContainsKey(tileId))
                    {
                        tileSource = this.requests[tileId] as TileSource;
                    }
                }
            }

            return(tileSource);
        }
Exemplo n.º 5
0
        private void SetTileSource(MapTile tile, TileId tileId, MultiScaleTileSource source)
        {
            bool refresh = false;

            if (!tileId.Equals(tile.TileId))
            {
                tile.TileId = tileId;
                refresh     = true;
            }

            while (true)
            {
                TileSource tileSource = source.GetTileSource(tileId);
                if (tileSource != null)
                {
                    if (tile.Source != tileSource || refresh)
                    {
                        tile.Source = tileSource;
                    }

                    if (tileSource.IsUsed)
                    {
                        this.usedTiles.Add(tileSource);
                        this.unusedTiles.Remove(tileSource);

                        break;
                    }
                    else
                    {
                        tileSource = null;
                    }
                }

                if (tileSource == null)
                {
                    tileId = this.ReduceTileId(tileId);
                    if (tileId == null)
                    {
                        tile.Source = null;
                        break;
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void UpdateTileChache()
        {
            int tilesCounter;

            lock (this.requestsSyncronizer)
            {
                tilesCounter = this.requestList.Count;
            }

            for (int i = 0;
                 i < MaxRemovedTiles &&
                 tilesCounter > this.MinTileNumber &&
                 this.tileCacheSize > this.MaxTileCacheSize;
                 i++)
            {
                lock (this.requestsSyncronizer)
                {
                    TileId     removed    = this.requestList[0];
                    TileSource tileSource = this.requests[removed];
                    if (tileSource != null && !tileSource.IsUsed)
                    {
                        this.tileCacheSize -= tileSource.Size;
                        tileSource.Dispose();

                        this.requestList.RemoveAt(0);
                        this.requests.Remove(removed);
                    }
                    else
                    {
                        this.requestList.Remove(removed);
                        this.requestList.Add(removed);
                        break;
                    }

                    tilesCounter = this.requestList.Count;
                }
            }
        }