Exemple #1
0
 protected void OnListRefreshedEvent(ListRefreshedEventArgs ev)
 {
     if (ListRefreshedEvent != null)
     {
         ListRefreshedEvent(ev);
     }
 }
Exemple #2
0
		protected void OnListRefreshedEvent(ListRefreshedEventArgs ev)
		{
			if (ListRefreshedEvent != null)
			{
				ListRefreshedEvent(ev);
			}
		}
        void uTorrent_ListRefreshedEvent(ListRefreshedEventArgs ev)
        {
            if (ev.Torrents.Count != Torrents.Count)
            {
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate ()
                {
                    Torrents.Clear();
                    ViewTorrents.Refresh();
                });
            }

            long dSpeed = 0, uSpeed = 0;

            // new or updated torrents
            foreach (Torrent tor in ev.Torrents)
            {
                dSpeed += tor.DownloadSpeed;
                uSpeed += tor.UploadSpeed;

                //logger.Trace(tor.ToString());

                bool foundTorrent = false;
                foreach (Torrent torExisting in Torrents)
                {
                    if (tor.Hash == torExisting.Hash)
                    {
                        foundTorrent = true;

                        // update details
                        torExisting.Availability = tor.Availability;
                        torExisting.Downloaded = tor.Downloaded;
                        torExisting.DownloadSpeed = tor.DownloadSpeed;
                        torExisting.ETA = tor.ETA;
                        torExisting.Label = tor.Label;
                        torExisting.Name = tor.Name;
                        torExisting.PeersConnected = tor.PeersConnected;
                        torExisting.PeersInSwarm = tor.PeersInSwarm;
                        torExisting.PercentProgress = tor.PercentProgress;
                        torExisting.Ratio = tor.Ratio;
                        torExisting.Remaining = tor.Remaining;
                        torExisting.SeedsConnected = tor.SeedsConnected;
                        torExisting.SeedsInSwarm = tor.SeedsInSwarm;
                        torExisting.Size = tor.Size;
                        torExisting.Status = tor.Status;
                        torExisting.TorrentQueueOrder = tor.TorrentQueueOrder;
                        torExisting.Uploaded = tor.Uploaded;
                        torExisting.UploadSpeed = tor.UploadSpeed;

                        break;
                    }
                }

                if (!foundTorrent)
                {
                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate ()
                    {
                        Torrents.Add(tor);
                    });
                }
            }

            DownloadSpeedSummaryFormatted = Utils.FormatByteSize((long)dSpeed) + "/sec";
            UploadSpeedSummaryFormatted = Utils.FormatByteSize((long)uSpeed) + "/sec";

            System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate ()
            {
                ViewTorrents.Refresh();
            });
        }