private void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         HandleException(e.Error);
         okDialogButton.Enabled = true;
     }
     else
     {
         bool withoption = useTorrentLoadDialogCheckBox.Enabled ? useTorrentLoadDialogCheckBox.Checked : false;
         if (withoption)
         {
             TorrentLoadDialog dialog = new TorrentLoadDialog((string)e.UserState);
             dialog.ShowDialog();
         }
         else
         {
             Program.Form.SetupAction(CommandFactory.RequestAsync(Requests.TorrentAddByFile((string)e.UserState, true)));
         }
         this.Close();
     }
 }
 public void Upload(string[] args, bool uploadprompt)
 {
     foreach (string s in args)
     {
         if (s == null || s.Length == 0)
             continue;
         if (File.Exists(s))
         {
             if (uploadprompt)
             {
                 TorrentLoadDialog dialog = new TorrentLoadDialog(s);
                 dialog.ShowDialog();
             }
             else
             {
                 try
                 {
                     Program.Form.SetupAction(CommandFactory.RequestAsync(Requests.TorrentAddByFile(s, false)));
                 }
                 catch (Exception e)
                 {
                     MessageBox.Show(e.Message, OtherStrings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
         else
         {
             Program.Form.SetupAction(CommandFactory.RequestAsync(Requests.TorrentAddByUrl(s, Program.Settings.UseLocalCookies)));
         }
     }
 }
 private void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         HandleException(e.Error);
         okDialogButton.Enabled = true;
     }
     else
     {
         bool withoption = useTorrentLoadDialogCheckBox.Enabled ? useTorrentLoadDialogCheckBox.Checked : false;
         if (withoption)
         {
             TorrentLoadDialog dialog = new TorrentLoadDialog((string)e.UserState);
             dialog.ShowDialog();
         }
         else
             Program.Form.SetupAction(CommandFactory.RequestAsync(Requests.TorrentAddByFile((string)e.UserState, true)));
         this.Close();
     }
 }