private void TorrentLoadBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (e.Result.GetType().Equals(typeof(List <ListViewItem>)))
     {
         filesListView.BeginUpdate();
         foreach (ListViewItem item in (List <ListViewItem>)e.Result)
         {
             filesListView.Items.Add(item);
         }
         Toolbox.StripeListView(filesListView);
         filesListView.Enabled = OkButton.Enabled = altDestDirCheckBox.Enabled = altPeerLimitCheckBox.Enabled = startTorrentCheckBox.Enabled = true;
         filesListView.EndUpdate();
         NameLabel.Text    = torrent.Name;
         CommentLabel.Text = torrent.Comment;
         SizeLabel.Text    = string.Format("{0} ({1} x {2})", Toolbox.GetFileSize(torrent.Size), torrent.Pieces.Count, Toolbox.GetFileSize(torrent.PieceLength));
         DateLabel.Text    = torrent.CreationDate.ToString();
         this.Text         = torrent.Name;
         this.toolStripStatusLabel.Text = "";
     }
     else
     {
         Exception ex = (Exception)e.Result;
         MessageBox.Show(ex.Message, OtherStrings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 2
0
        public void UpdateUi(bool first)
        {
            MainWindow form = Program.Form;

            if (form.InvokeRequired)
            {
                form.Invoke(new UpdateUIDelegate(UpdateUi), new object[] { first });
                return;
            }
            SetText(1, Id.ToString());
            SubItems[1].Tag = Id;
            SetText(2, Toolbox.GetFileSize(SizeWhenDone));
            SubItems[2].Tag = SizeWhenDone;
            SetText(3, Percentage + "%");
            SubItems[3].Tag = Percentage;
            SetText(4, Status);
            SetText(5, string.Format(_seedersColumnFormat, Seeders < 0 ? "?" : Seeders.ToString(), PeersSendingToUs));
            SubItems[5].Tag = Seeders;
            SetText(6, string.Format(_seedersColumnFormat, Leechers < 0 ? "?" : Leechers.ToString(), PeersGettingFromUs));
            SubItems[6].Tag = Leechers;
            SetText(7, DownloadRate > 0 ? Toolbox.GetSpeed(DownloadRate) : "");
            SubItems[7].Tag = DownloadRate;
            SetText(8, UploadRate > 0 ? Toolbox.GetSpeed(UploadRate) : "");
            SubItems[8].Tag = UploadRate;
            SetText(9, Eta > 0 ? TimeSpan.FromSeconds(Eta).ToString() : "");
            SubItems[9].Tag = Eta;
            SetText(10, Toolbox.GetFileSize(Uploaded));
            SubItems[10].Tag = Uploaded;
            SetText(11, LocalRatio < 0 ? "∞" : LocalRatio.ToString());
            SubItems[11].Tag       = LocalRatio;
            SubItems[11].ForeColor = GetRatioColor();
            SetText(12, Added.ToString());
            SubItems[12].Tag = Added;
            if (DoneDate != null)
            {
                SubItems[13].Tag = DoneDate;
                SetText(13, DoneDate.ToString());
            }
            SetText(14, FirstTrackerTrimmed);

            if (first)
            {
                lock (form.stateListBox)
                {
                    if (FirstTrackerTrimmed.Length > 0 && form.stateListBox.FindItem(FirstTrackerTrimmed) == null)
                    {
                        form.stateListBox.Items.Add(new GListBoxItem(FirstTrackerTrimmed, 9));
                    }
                }
                if (Program.Settings.MinToTray && Program.Settings.StartedBalloon && _updateSerial > 2)
                {
                    form.ShowTrayTip(LocalSettingsSingleton.BALLOON_TIMEOUT, TorrentName, String.Format(OtherStrings.NewTorrentIs, Status.ToLower()), ToolTipIcon.Info);
                }
                LogError();
            }
            else if (Program.Settings.MinToTray && CompletionPopupPending)
            {
                CompletionPopupPending = false;
                form.ShowTrayTip(LocalSettingsSingleton.BALLOON_TIMEOUT, TorrentName, OtherStrings.TorrentFinished, ToolTipIcon.Info);
            }
            ForeColor = HasError ? Color.Red : SystemColors.WindowText;
            UpdateIcon();
        }