コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool withoption = useTorrentLoadDialogCheckBox.Enabled ? useTorrentLoadDialogCheckBox.Checked : false;

            if (Program.DaemonDescriptor.Version >= 1.50 && !withoption)
            {
                Program.Form.SetupAction(CommandFactory.RequestAsync(Requests.TorrentAddByUrl(urlTextBox.Text, addOurCookiesCheckBox.Checked)));
                this.Close();
            }
            else
            {
                try
                {
                    string target = Path.GetTempFileName();
                    toolStripStatusLabel.Text   = OtherStrings.Downloading + "...";
                    downloadProgressBar.Value   = 0;
                    downloadProgressBar.Visible = true;
                    okDialogButton.Enabled      = false;
                    WebClient webClient = new TransmissionWebClient(false, false);
                    webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
                    webClient.DownloadFileCompleted   += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted);
                    webClient.DownloadFileAsync(this.currentUri, target, target);
                }
                catch (Exception ex)
                {
                    HandleException(ex);
                }
            }
        }