コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            JsonArray wanted   = new JsonArray();
            JsonArray unwanted = new JsonArray();
            JsonArray high     = new JsonArray();
            JsonArray normal   = new JsonArray();
            JsonArray low      = new JsonArray();

            foreach (ListViewItem item in filesListView.Items)
            {
                if (!item.Checked)
                {
                    unwanted.Add(item.Index);
                }
                else
                {
                    wanted.Add(item.Index);
                }
                if (item.SubItems[3].Text.Equals(OtherStrings.High))
                {
                    high.Add(item.Index);
                }
                else if (item.SubItems[3].Text.Equals(OtherStrings.Low))
                {
                    low.Add(item.Index);
                }
                else
                {
                    normal.Add(item.Index);
                }
            }
            JsonObject request = Requests.TorrentAddByFile(
                path,
                Program.Settings.DeleteTorrentWhenAdding,
                high.Count > 0 ? high : null,
                normal.Count > 0 ? normal : null,
                low.Count > 0 ? low : null,
                wanted.Count > 0 ? wanted : null,
                unwanted.Count > 0 ? unwanted : null,
                altDestDirCheckBox.Checked ? destinationComboBox.Text : null,
                altPeerLimitCheckBox.Checked ? (int)peerLimitValue.Value : -1,
                startTorrentCheckBox.Checked
                );

            Program.Settings.Current.AddDestinationPath(destinationComboBox.Text);
            Program.Form.SetupAction(CommandFactory.RequestAsync(request));
            this.Close();
        }
コード例 #2
0
 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();
     }
 }