Beispiel #1
0
        private void CheckBox_Click(object sender, RoutedEventArgs e)
        {
            CheckBox       s  = sender as CheckBox;
            TorrentListing tl = s.Tag as TorrentListing;

            tl.Import = s.IsChecked == true;
        }
 /// <param name="fast_load">Indicate wither to stop loading at the first torrent found</param>
 public void Load(bool fast_load = false)
 {
     foreach (string dir in uTorrentDirs)
     {
         string p = Path.Combine(dir, "resume.dat");
         if (File.Exists(p))
         {
             using (var fs = new FileStream(p, FileMode.Open))
             {
                 try
                 {
                     var val = BEncodedDictionary.Decode(fs);
                     BEncodedDictionary dict = val as BEncodedDictionary;
                     foreach (var pair in dict)
                     {
                         try
                         {
                             string key = pair.Key.ToString();
                             if (key != ".fileguard") // special case
                             {
                                 TorrentListing tl = new TorrentListing();
                                 tl.Path = Path.Combine(dir, key);
                                 BEncodedDictionary values = pair.Value as BEncodedDictionary;
                                 tl.Name = values[new BEncodedString("caption")].ToString();
                                 tl.SavePath = values[new BEncodedString("path")].ToString();
                                 tl.Import = true;
                                 list.Add(tl);
                                 if (fast_load)
                                 {
                                     fs.Close();
                                     return;
                                 }
                             }
                         }
                         catch
                         { }
                     }
                 }
                 catch (BEncodingException)
                 {
                     //this exception may be thrown by the Decode function if the format is for some reason not recognized (maybe a later format?)
                     //no matter what, let's not crash because of it, and just exit out in a safe manner.
                 }
             }
         }
     }
     App.Current.Dispatcher.Invoke(new Action(() =>
     {
         torrents.Items.Refresh();
     }));
 }
Beispiel #3
0
 /// <param name="fast_load">Indicate wither to stop loading at the first torrent found</param>
 public void Load(bool fast_load = false)
 {
     foreach (string dir in uTorrentDirs)
     {
         string p = Path.Combine(dir, "resume.dat");
         if (File.Exists(p))
         {
             using (var fs = new FileStream(p, FileMode.Open))
             {
                 try
                 {
                     var val = BEncodedDictionary.Decode(fs);
                     BEncodedDictionary dict = val as BEncodedDictionary;
                     foreach (var pair in dict)
                     {
                         try
                         {
                             string key = pair.Key.ToString();
                             if (key != ".fileguard") // special case
                             {
                                 TorrentListing tl = new TorrentListing();
                                 tl.Path = Path.Combine(dir, key);
                                 BEncodedDictionary values = pair.Value as BEncodedDictionary;
                                 tl.Name     = values[new BEncodedString("caption")].ToString();
                                 tl.SavePath = values[new BEncodedString("path")].ToString();
                                 tl.Import   = true;
                                 list.Add(tl);
                                 if (fast_load)
                                 {
                                     fs.Close();
                                     return;
                                 }
                             }
                         }
                         catch
                         { }
                     }
                 }
                 catch (BEncodingException)
                 {
                     //this exception may be thrown by the Decode function if the format is for some reason not recognized (maybe a later format?)
                     //no matter what, let's not crash because of it, and just exit out in a safe manner.
                 }
             }
         }
     }
     App.Current.Dispatcher.Invoke(new Action(() =>
     {
         torrents.Items.Refresh();
     }));
 }