コード例 #1
0
 public Transfer(TorrentTransfer transfer)
 {
     TorrentTransfer = transfer;
     TorrentTransfer.StateChanged += transfer_StateChanged;
     TorrentTransfer.ReportStats += transfer_ReportStats;
     TorrentTransfer.RaisedException += TorrentTransfer_RaisedException;
     Mode = Mode.Idle;
     Name = transfer.Data.Name;
     StartCommand = new RelayCommand(Start);
     StopCommand = new RelayCommand(Stop);
     OpenFolderCommand = new RelayCommand(OpenFolder);
     numericProgress.BytesTotal = TorrentTransfer.Data.TotalLength;
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: NewFuture/BitTorrent
 private void Run()
 {
     try
     {
         while (true)
         {
             torrent = new TorrentTransfer(Console.ReadLine());
             torrent.GotPeers += torrent_GotPeers;
             torrent.Start();
             for (; ; ) ;
         }
     }
     finally
     {
         Console.Read();
     }
 }
コード例 #3
0
        public void GetPeers(string path)
        {
            try
            {
                Peers.Clear();
                Announces.Clear();
                Files.Clear();
                AddMessage("Attempting to open torrent file.");
                torrent = new TorrentTransfer(path);
                PieceLength = torrent.Data.PieceLength;
                PieceCount = torrent.Data.Checksums.Count;
                Name=torrent.Data.Name;
                Hash = BitConverter.ToString(torrent.Data.InfoHash).Replace("-", string.Empty);
                PieceLength = torrent.Data.PieceLength;
                AnnounceURL = torrent.Data.AnnounceURL;

                torrent.Data.Files.ForEach(f => Files.Add(f));
                if (torrent.Data.AnnounceList != null)
                    torrent.Data.AnnounceList.ForEach(a => Announces.Add(a));

                filesSize = 0;
                foreach (var file in files)
                {
                    filesSize += file.Length;
                }
                totalSize = Global.Instance.FileSizeFormat(filesSize);

                torrent.RaisedException += torrent_RaisedException;
                torrent.ReportStats += torrent_ReportStatsChanged;
                torrent.StateChanged += torrent_StateChanged;
                torrent.Start();

            }
            catch (Exception e)
            {
                HandleException(e);
                System.Windows.MessageBox.Show("Damn: " + e);
            }
        }