Exemple #1
0
        private static void imageDownloadCompleteCallback(object otile, DownloadInfo info, string imageFileName, byte[] dataDownloaded)
        {
#if DEBUG
            LibSys.StatusBar.Trace("IP: TileCache:imageDownloadCompleteCallback() - " + info.baseName + " " + (dataDownloaded == null? "null" : "" + dataDownloaded.Length) + " bytes loaded");
#endif
            Backdrop backdrop = (Backdrop)m_backdropCache[info.baseName];
            Tile     tile     = (Tile)otile;

            if (dataDownloaded == null || info.is404 || Project.is404(dataDownloaded))
            {
                string comment = dataDownloaded == null ? "no data" : "404";
                if (backdrop != null)
                {
                    backdrop.IsEmpty = true;                            // proven empty
                }
                ProgressMonitor.markComplete(info.monitored, false, comment);
            }
            else
            {
                FileStream fs = null;
                try
                {
                    string comment = "" + dataDownloaded.Length + " bytes";
                    fs = new FileStream(imageFileName, FileMode.Create);
                    fs.Write(dataDownloaded, 0, dataDownloaded.Length);
                    fs.Close();
                    fs = null;
#if DEBUG
                    LibSys.StatusBar.Trace("OK: file " + imageFileName + " created");
#endif
                    if (backdrop != null)
                    {
                        backdrop.Fill();
                    }
                    ProgressMonitor.markComplete(info.monitored, true, comment);
                }
                catch (Exception e)
                {
#if DEBUG
                    LibSys.StatusBar.Error("" + e);
#endif
                    if (backdrop != null)
                    {
                        backdrop.IsEmpty = true;                                // proven empty
                    }
                    ProgressMonitor.markComplete(info.monitored, false, e.Message);
                }
                finally
                {
                    if (fs != null)
                    {
                        fs.Close();
                    }
                }
            }

            if (tile != null)
            {
                tile.backdropArrived(backdrop);
            }
        }
Exemple #2
0
        private static void imageDownloadCompleteCallback(object otile, DownloadInfo info, string imageFileName, byte[] dataDownloaded)
        {
#if DEBUG
            LibSys.StatusBar.Trace("IP: TerraserverCache:imageDownloadCompleteCallback() - " + info.baseName + " " + (dataDownloaded == null? "null" : "" + dataDownloaded.Length) + " bytes loaded");
#endif

//			tilesBeingLoadedCount = tilesBeingLoadedCount > 0 ? tilesBeingLoadedCount - 1 : 0;

            Backdrop  backdrop = (Backdrop)m_backdropCache[info.baseName];
            TileTerra tile     = (TileTerra)otile;              // can be null for preload

            if (dataDownloaded == null || dataDownloaded.Length < 100 || Project.is404(dataDownloaded))
            {
                string comment = dataDownloaded == null ? "no data" : "404";
                if (backdrop != null)
                {
                    backdrop.IsEmpty = true;                            // proven empty
                }
                ProgressMonitor.markComplete(info.monitored, false, comment);
            }

            /*
             * else if(dataDownloaded.Length == 8321)		// cottage cheese
             * {
             *      string comment = "cottage cheese tile";
             *      backdrop.IsEmpty = true;	// proven empty
             *      tile.IsCottageCheese = true;
             *      ProgressMonitor.markComplete(info.monitored, false, comment);
             * }
             */
            else
            {
                FileStream fs = null;
                try
                {
                    string comment = "" + dataDownloaded.Length + " bytes";
                    if (dataDownloaded.Length == 8321)                                  // cottage cheese
                    {
                        if (tile != null)
                        {
                            tile.IsCottageCheese = true;
                        }
                        comment = "cottage cheese tile";
                    }
                    fs = new FileStream(imageFileName, FileMode.Create);
                    fs.Write(dataDownloaded, 0, dataDownloaded.Length);
                    fs.Close();
                    fs = null;
#if DEBUG
                    LibSys.StatusBar.Trace("OK: file " + imageFileName + " created");
#endif
                    if (backdrop != null)
                    {
                        backdrop.Fill();
                    }
                    ProgressMonitor.markComplete(info.monitored, true, comment);
                }
                catch (Exception e)
                {
#if DEBUG
                    LibSys.StatusBar.Error("" + e.Message);
#endif
                    if (backdrop != null)
                    {
                        backdrop.IsEmpty = true;                                // proven empty
                    }
                    ProgressMonitor.markComplete(info.monitored, false, e.Message);
                }
                finally
                {
                    if (fs != null)
                    {
                        fs.Close();
                    }
                }
            }

            if (tile != null)
            {
                tile.backdropArrived(backdrop);
            }
        }