Esempio n. 1
0
        private void AssyncImageReaderComplete(TileDownloader downloader)
        {
            TileDownloadState e = new TileDownloadState()
            {
                TileId   = downloader.TileId,
                TileBody = downloader.TileBody
            };

            downloader.Dispose();

            this.UpdateTile(e);
        }
Esempio n. 2
0
        internal void DownloadTile(TileId tileId)
        {
            IList <object> objects = null;

            using (ManualResetEvent complete = new ManualResetEvent(false))
            {
                this.Dispatcher.BeginInvoke(new Action(() =>
                {
                    objects = this.GetTileLayers(tileId.Level, tileId.X, tileId.Y);
                    complete.Set();
                }));

                complete.WaitOne();
            }

            if (objects.Count > 0)
            {
                Uri    uri    = objects[0] as Uri;
                Stream stream = objects[0] as Stream;
                if (uri != null)
                {
                    TileDownloadState e = new TileDownloadState()
                    {
                        TileId   = tileId,
                        Uri      = uri,
                        Callback = this.AssyncImageCacheReader
                    };

                    this.GetCachedTileAsync(tileId.Level, tileId.X, tileId.Y, e.RaiseEvent);
                }
                else if (stream != null)
                {
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        TileDownloader tile = new TileDownloader(tileId, stream, this.AssyncImageReader);
                        tile.StartDownload();
                    }));
                }
                else
                {
                    TileDownloadState e = new TileDownloadState()
                    {
                        TileId = tileId
                    };

                    this.UpdateTile(e);
                }
            }
        }
Esempio 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();
            }
        }
Esempio n. 4
0
        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);
                }
            }
        }