Exemplo n.º 1
0
        void DownloadComplete(WebDownload downloadInfo)
        {
            if (this.InvokeRequired)
            {
                Invoke(new DownloadCompleteHandler(DownloadComplete), new object[] { downloadInfo });
                return;
            }

            try
            {
                downloadInfo.Verify();
                Image = System.Drawing.Image.FromStream(downloadInfo.ContentStream);
            }
            catch (Exception caught)
            {
                this.Visible = false;
                MessageBox.Show(caught.Message, "Legend image download failed.",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                if (downloadInfo != null)
                {
                    downloadInfo.Dispose();
                }
                Text = oldText;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Called when download is complete.
 /// </summary>
 /// <param name="dl">The download.</param>
 private void OnDownloadComplete(WebDownload dl)
 {
     if (retryDownloads.Contains(dl))
     {
         retryDownloads.Remove(dl);
     }
     dl.Dispose();
 }
Exemplo n.º 3
0
 public virtual void Dispose()
 {
     if (download != null)
     {
         download.Dispose();
         download = null;
     }
     GC.SuppressFinalize(this);
 }
Exemplo n.º 4
0
        private void UpdateImages()
        {
            try
            {
                System.Collections.ArrayList remoteImageList = new System.Collections.ArrayList();

                try
                {
                    // Offline check
                    if (World.Settings.WorkOffline)
                    {
                        throw new Exception("Offline mode active.");
                    }

                    WebDownload download         = new WebDownload(m_remoteUrl);
                    FileInfo    currentIndexFile = new FileInfo(m_imageDirectoryPath + "\\current.txt");
                    if (!currentIndexFile.Directory.Exists)
                    {
                        currentIndexFile.Directory.Create();
                    }

                    download.DownloadFile(currentIndexFile.FullName, DownloadType.Unspecified);
                    download.Dispose();

                    using (StreamReader reader = currentIndexFile.OpenText())
                    {
                        string data = reader.ReadToEnd();

                        string[] parts = data.Split('"');

                        for (int i = 0; i < parts.Length; i++)
                        {
                            if (parts[i].StartsWith("/GlobalCloudsArchive/PastDay/"))
                            {
                                remoteImageList.Add(parts[i].Replace("/GlobalCloudsArchive/PastDay/", ""));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Write(ex);
                }

                System.Collections.ArrayList imageDisplayList = new System.Collections.ArrayList();

                DirectoryInfo cloudImageDirectory = new DirectoryInfo(m_imageDirectoryPath);

                FileInfo[] archiveImageFiles = new FileInfo[0];

                if (cloudImageDirectory.Exists)
                {
                    archiveImageFiles = cloudImageDirectory.GetFiles("*.png");
                }

                for (int i = remoteImageList.Count - 1; i >= 0; i--)
                {
                    string currentRemoteFile = (string)remoteImageList[i];

                    bool found = false;
                    for (int j = 0; j < archiveImageFiles.Length; j++)
                    {
                        if (archiveImageFiles[j].Name == currentRemoteFile.Replace(".jpg", ".png"))
                        {
                            found = true;
                        }
                    }

                    if (!found)
                    {
                        // Offline check
                        if (World.Settings.WorkOffline)
                        {
                            throw new Exception("Offline mode active.");
                        }

                        FileInfo    jpgFile  = new FileInfo(cloudImageDirectory.FullName + "\\" + currentRemoteFile);
                        WebDownload download = new WebDownload(
                            m_remoteUrl + "/" + currentRemoteFile);

                        if (!jpgFile.Directory.Exists)
                        {
                            jpgFile.Directory.Create();
                        }

                        download.DownloadFile(jpgFile.FullName, DownloadType.Unspecified);

                        ImageHelper.CreateAlphaPngFromBrightness(jpgFile.FullName, jpgFile.FullName.Replace(".jpg", ".png"));
                    }
                }

                //reload the list of downloaded images
                if (cloudImageDirectory.Exists)
                {
                    archiveImageFiles = cloudImageDirectory.GetFiles("*.png");
                }

                for (int i = archiveImageFiles.Length - 1; i >= 0; i--)
                {
                    imageDisplayList.Insert(0, archiveImageFiles[i].FullName);
                }

                double north = 90, south = -90, west = -180, east = 180;

                for (int i = 0; i < imageDisplayList.Count; i++)
                {
                    string currentImageFile = (string)imageDisplayList[i];

                    string ddsFilePath = currentImageFile.Replace(".png", ".dds");
                    if (!File.Exists(ddsFilePath))
                    {
                        ImageHelper.ConvertToDxt3(currentImageFile, ddsFilePath, false);
                    }
                    DynamicCloudFrame frame = new DynamicCloudFrame();
                    frame.ImageFile = currentImageFile;
                    frame.Texture   = ImageHelper.LoadTexture(ddsFilePath);
                    CreateMesh(north, south, west, east, m_samples, currentImageFile, ref frame.Vertices, ref frame.Indices);

                    m_frames.Add(frame);
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Called when download is complete.
 /// </summary>
 /// <param name="dl">The download.</param>
 private void OnDownloadComplete(WebDownload dl)
 {
     if (retryDownloads.Contains(dl)) {
         retryDownloads.Remove(dl);
     }
     dl.Dispose();
 }
Exemplo n.º 6
0
 private void DownloadComplete(WebDownload oDownload)
 {
     // --- Sending it is what matters, we don't care what comes back ---
     oDownload.Dispose();
 }