private void button1_Click(object sender, EventArgs e) { bool withoption = useTorrentLoadDialogCheckBox.Enabled && useTorrentLoadDialogCheckBox.Checked; if (Program.DaemonDescriptor.Version >= 1.50 && !withoption) { Program.Form.SetupAction(CommandFactory.RequestAsync(Requests.TorrentAddByUrl(urlTextBox.Text, addOurCookiesCheckBox.Checked))); Close(); } else { try { string target = Path.GetTempFileName(); toolStripStatusLabel.Text = OtherStrings.Downloading + "..."; downloadProgressBar.Value = 0; downloadProgressBar.Visible = true; okDialogButton.Enabled = false; var webClient = new TransmissionWebClient(false, false); webClient.DownloadProgressChanged += webClient_DownloadProgressChanged; webClient.DownloadFileCompleted += webClient_DownloadFileCompleted; webClient.DownloadFileAsync(_currentUri, target, target); } catch (Exception ex) { HandleException(ex); } } }
private void AddTorrentFromRss(bool options) { try { RssItem ri = rssItemsListView.SelectedItems[0].Tag as RssItem; string target = Path.GetTempFileName(); toolStripStatusLabel1.Text = OtherStrings.Downloading + "..."; toolStripDownloadProgressBar.Value = 0; toolStripDownloadProgressBar.Visible = true; WebClient webClient = new TransmissionWebClient(false, false); webClient.DownloadProgressChanged += webClient_DownloadProgressChanged; webClient.DownloadFileCompleted += delegate(object sender, AsyncCompletedEventArgs e) { webClient_DownloadFileCompleted(sender, e, target, options); }; webClient.DownloadFileAsync(new Uri(ri.Link), target); } catch (Exception ex) { HandleException(ex); } }