Beispiel #1
0
        private bool DownloadGame(string downloadURI)
        {
            downloader = new GameDownloader(downloadURI);
            downloader.DownloadFinished        += new EventHandler(downloader_DownloadFinished);
            downloader.DownloadProgressChanged += new EventHandler <GameDownloader.GameDownloaderProgressChangedEventArgs>(downloader_DownloadProgressChanged);
            downloader.DownloadFailed          += new EventHandler <GameDownloader.GameDownloadFailedEventHandler>(downloader_DownloadFailed);
            downloadPath = System.IO.Path.GetTempFileName();
            downloader.BeginFreshDownload(downloadPath);

            return(true);        // TODO
        }
 void downloader_DownloadProgressChanged(object sender, GameDownloader.GameDownloaderProgressChangedEventArgs e)
 {
     DateTime now = DateTime.Now;
     if ((now - lastGUIUpdate).TotalMilliseconds > 33 || e.TotalBytesToReceive == e.BytesReceived)
     {
         lastGUIUpdate = now;
         progressBar.Minimum = 0;
         progressBar.Maximum = (int)e.TotalBytesToReceive;
         progressBar.Value = (int)e.BytesReceived;
         lastProgressString = String.Format("{0:0.0} of {1:0.0} kB ({2:0.0}%)",
             e.BytesReceived / 1024f,
             e.TotalBytesToReceive / 1024f,
             100f * e.BytesReceived / e.TotalBytesToReceive);
         lblDownloadText.Text = String.Format("Downloading: {0}", lastProgressString);
     }
 }
        private bool DownloadGame(string downloadURI)
        {
            downloader = new GameDownloader(downloadURI);
            downloader.DownloadFinished += new EventHandler(downloader_DownloadFinished);
            downloader.DownloadProgressChanged += new EventHandler<GameDownloader.GameDownloaderProgressChangedEventArgs>(downloader_DownloadProgressChanged);
            downloader.DownloadFailed += new EventHandler<GameDownloader.GameDownloadFailedEventHandler>(downloader_DownloadFailed);
            downloadPath = System.IO.Path.GetTempFileName();
            downloader.BeginFreshDownload(downloadPath);

            return true;        // TODO
        }
 void downloader_DownloadFailed(object sender, GameDownloader.GameDownloadFailedEventHandler e)
 {
     if (e.Reason == GameDownloader.DownloadFailureReason.Cancelled)
         lblDownloadText.Text = "Paused: " + lastProgressString;
     else
         lblDownloadText.Text = "Error getting installer: " + e.Message;
 }