Exemple #1
0
      public BitMonster(string file)
      {
         _torrentApplication = new TorrentApplication();
         InitializeComponent();

         this.Text += string.Format(" [v{0}]", TorrentApplication.Version);

         if (!string.IsNullOrEmpty(file))
         {
            AddTorrent(file);
         }
      }
Exemple #2
0
      private void Deserialize()
      {
         var path = Path.Combine(TorrentApplication.GlobalLocation, "data");
         if (File.Exists(path))
         {
            try
            {
               using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read))
               {
                  var bf = new BinaryFormatter();
                  _torrentApplication = (TorrentApplication)bf.Deserialize(fs);
                  TorrentApplication.Torrents = (Dictionary<string, Torrent>)bf.Deserialize(fs);

                  foreach (var torrent in TorrentApplication.Torrents.Values)
                  {
                     listTorrent.Add(torrent);
                  }
               }

               foreach (var torrent in TorrentApplication.Torrents.Values)
               {
                  torrent.Updated += Updated;
                  torrent.Downloaded += torrent_Downloaded;
               }

               TorrentApplication.WakeUp();

//               UpdateTorrentList();
            }
            catch (Exception ex)
            {
               Logger.Error(ex);
               Error(ex.Message);
            }
         }
      }