private void DisplayTorrents(List <Torrent> TorrentsAll) { long downloadSpeed = 0; int downs = 0; long uploadSpeed = 0; long seeding = 0; double avgProgress = 0.0; int unfinished = 0; int ActiveTorrents = 0; foreach (Torrent torrent in TorrentsAll) { if (torrent.Started()) { if (torrent.DownloadSpeed > 0 || torrent.UploadSpeed > 0) { ActiveTorrents++; } downloadSpeed += torrent.DownloadSpeed; uploadSpeed += torrent.UploadSpeed; if (torrent.Progress >= 100) { //only seeding seeding = seeding + 1; } else { downs++; } } if (torrent.Progress < 100.0) { avgProgress += torrent.Progress; unfinished += 1; } } UpdateScreen(); GUIPropertyManager.SetProperty("#MyTorrents.IsConnected", TorrentEngine.Instance().IsConnected.ToString()); GUIPropertyManager.SetProperty("#MyTorrents.CombinedDownloadSpeed", UnitConvert.TransferSpeedToString(downloadSpeed)); GUIPropertyManager.SetProperty("#MyTorrents.CombinedUploadSpeed", UnitConvert.TransferSpeedToString(uploadSpeed)); GUIPropertyManager.SetProperty("#MyTorrents.Downloads.Count", string.Format("{0}", downs)); GUIPropertyManager.SetProperty("#MyTorrents.Uploads.Count", string.Format("{0}", seeding)); GUIPropertyManager.SetProperty("#MyTorrents.Active.Count", string.Format("{0}", ActiveTorrents)); //GUIPropertyManager.SetProperty("#MyTorrents.Ready.Count", string.Format("{0}", TorrentsAll.Count - TorrentsActive.Count)); //GUIPropertyManager.SetProperty("#MyTorrents.Unfinished.Count", string.Format("{0}", unfinished)); //GUIPropertyManager.SetProperty("#MyTorrents.AverageProgressOfUnfinished", string.Format("{0:F2}", avgProgress / unfinished)); if (Notifier.Instance() != null && Notifier.Instance().IsNotificationBarAvailable() && (_config.Notify)) { Notifier.Instance().ChangeText(); } }
public List <GUIListItem> GetTorrentDetails(Torrent utorrent) { List <GUIListItem> fileList = new List <GUIListItem>(); SelectedHash = utorrent.Hash; if (utorrent == null) { //torrent got removed! } List <File> files = TorrentEngine.Instance().TorrentSession.GetFiles(utorrent.Hash); foreach (var file in files) { GUIListItem item = new GUIListItem(); item.Label = file.Filename; item.IconImage = System.IO.Path.Combine(GUIGraphicsContext.Skin, @"\Media\icon_empty_focus1.png"); item.AlbumInfoTag = file; fileList.Add(item); item.Label2 = string.Format("{0} ({1:F2}%)", UnitConvert.SizeToString(file.Filesize), (double)file.Downloaded / file.Filesize * 100.0); } GUIPropertyManager.SetProperty("#MyTorrents.Details.Name", utorrent.Name); GUIPropertyManager.SetProperty("#MyTorrents.Details.Progress", string.Format("{0:F2}", utorrent.Progress)); GUIPropertyManager.SetProperty("#MyTorrents.Details.Ratio", string.Format("{0:F2}", (float)utorrent.Ratio * 0.001)); GUIPropertyManager.SetProperty("#MyTorrents.Details.ETA", UnitConvert.TimeRemainingToString(utorrent.ETA)); GUIPropertyManager.SetProperty("#MyTorrents.Details.UploadSpeed", UnitConvert.TransferSpeedToString(utorrent.UploadSpeed)); GUIPropertyManager.SetProperty("#MyTorrents.Details.DownloadSpeed", UnitConvert.TransferSpeedToString(utorrent.DownloadSpeed)); GUIPropertyManager.SetProperty("#MyTorrents.Details.Peers", string.Format("{0} ({1})", utorrent.PeersConnected, utorrent.PeersInSwarm)); GUIPropertyManager.SetProperty("#MyTorrents.Details.Seeds", string.Format("{0} ({1})", utorrent.SeedsConnected, utorrent.SeedsInSwarm)); GUIPropertyManager.SetProperty("#MyTorrents.Details.Size", UnitConvert.SizeToString(utorrent.Size)); return(fileList); }