Ejemplo n.º 1
0
        private void DownloadNext()
        {
            if (ToDownload.Any())
            {
                DownloadEntry next = ToDownload.Dequeue();
                webc.DownloadFileAsync(new Uri(next.Url), next.Path);

                progressBar.Value = progressBar.Maximum - ((ToDownload.Count + 1) * 100);
            }
            else
            {
                System.Windows.MessageBox.Show("Done");

                CanChange = true;

                progressBar.Value = 0;

                buttonDownload.Content = "Download";
            }
        }
Ejemplo n.º 2
0
        private void buttonDownload_Click(object sender, RoutedEventArgs e)
        {
            if (CanChange)
            {
                try
                {
                    webc.Headers.Set(HttpRequestHeader.Cookie, textBoxCookies.Text.Trim().Replace("\n", ";").Replace("\r", ""));
                }
                catch (Exception ex)
                {
                    System.Windows.MessageBox.Show($"Could not use cookie: {ex.Message}");
                    return;
                }

                CanChange = false;

                ToDownload.Clear();
                foreach (var entry in GetDownloadEntries())
                {
                    ToDownload.Enqueue(entry);
                }

                progressBar.Maximum = ToDownload.Count * 100;

                DownloadEntry first = ToDownload.Dequeue();

                webc.DownloadFileAsync(new Uri(first.Url), first.Path);

                buttonDownload.Content = "Cancel";
            }
            else
            {
                ToDownload.Clear();
                webc.CancelAsync();
                CanChange = true;

                progressBar.Value = 0;

                buttonDownload.Content = "Download";
            }
        }