Esempio n. 1
0
        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);
        }