Exemplo n.º 1
0
        /// <summary>
        /// Download a File In BackGround
        /// </summary>
        /// <param name="majurl">link of the file</param>
        private void DownloadFileInBackGround(MajUrl majurl)
        {
            Uri uri = new Uri(majurl.Uri);

            client = new WebClient();
            client.DownloadFileCompleted   += new AsyncCompletedEventHandler(Client_DownloadFileCompleted);
            client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(Client_DownloadProgressChanged);
            client.DownloadFileAsync(uri, majurl.Filepath);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Client Download File Completed
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">AsyncCompletedEventArgs</param>
        private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            progressBar1.Value++;
            if (liste.Count > 0)
            {
                label1.Text = string.Format("Download  {0} / {1}", progressBar1.Value, progressBar1.Maximum);
                MajUrl o = liste.Dequeue();
                label2.Text = string.Format("Downloading {0}", Path.GetFileName(o.Uri));
                DownloadFileInBackGround(o);
            }
            else
            {
                if (_showFinishMessage)
                {
                    MessageBox.Show("Update done.");
                }

                this.Close();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Event when Calculate the missing File is complete
        /// </summary>
        /// <param name="sender">Object</param>
        /// <param name="e">Args, Result is a Queue-MajUrl-</param>
        public void Bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            liste = (Queue <MajUrl>)e.Result;
            if (liste.Count > 0)
            {
                progressBar1.Maximum = liste.Count;
                progressBar1.Value   = 0;
                label1.Text          = string.Format("Download  {0} / {1}", progressBar1.Value, liste.Count);
                MajUrl o = liste.Dequeue();
                label2.Text = string.Format("Downloading {0}", Path.GetFileName(o.Uri));
                DownloadFileInBackGround(o);
            }
            else
            {
                if (_showFinishMessage)
                {
                    MessageBox.Show("Everything is there");
                }

                this.Close();
            }
        }