private void createTorrent()
		{
			creator = new TorrentCreator();
			
			progressDialog = new CreateTorrentProgressDialog();
			
			// TODO: Read the multi-tracker spec -- learn the proper way to add multiple trackers
			creator.Announces.Add(new MonoTorrentCollection<string>());
            		foreach(string s in GetTrackers())
            			creator.Announces[0].Add(s);
            		
			creator.Comment = Comment;
			creator.CreatedBy = "MonoTorrent";
			
			creator.Path = SavePath;

			creator.Hashed += OnHashed;
			
			TorrentCreatorAsyncResult creatorResult = creator.BeginCreate(null, BeginCreateCb);
			
			ResponseType cancelResult = (ResponseType) progressDialog.Run();
			if(cancelResult == ResponseType.Cancel){
				creatorResult.Abort();
				try{
					creator.EndCreate(creatorResult);
					progressDialog.Destroy();
				} catch (Exception e) {
					logger.ErrorException("Unable to end creation" + e.Message, e);
				}
			}
		}
        private void createTorrent()
        {
            creator = new TorrentCreator();

            progressDialog = new CreateTorrentProgressDialog();

            // TODO: Read the multi-tracker spec -- learn the proper way to add multiple trackers
            creator.Announces.Add(new RawTrackerTier ());
            foreach(string s in GetTrackers())
                creator.Announces[0].Add(s);

            creator.Comment = Comment;
            creator.CreatedBy = Defines.ApplicationName;

            creator.Hashed += delegate(object o, TorrentCreatorEventArgs e) {
                GLib.Idle.Add(delegate {
                    OnHashed(o, e);
                    return false;
                });
            };

            var result = creator.BeginCreate(new TorrentFileSource (SavePath), delegate (IAsyncResult r) {
                GLib.Idle.Add (delegate {
                    BeginCreateCb (r);
                    return false;
                });
            }, null);

            ResponseType cancelResult = (ResponseType) progressDialog.Run();
            if(cancelResult == ResponseType.Cancel){
                creator.AbortCreation ();
                try{
                    creator.EndCreate(result);
                    progressDialog.Destroy();
                } catch (Exception e) {
                    logger.ErrorException("Unable to end creation" + e.Message, e);
                }
            }
        }
 private void createButtonClicked(object sender, RoutedEventArgs e)
 {
     var sourcePath = pathTextBox.Text;
     if (string.IsNullOrEmpty(sourcePath))
     {
         MessageBox.Show("Please select a file or files to add.");
         return;
     }
     if (singleFileRadioButton.IsChecked.Value)
     {
         if (!File.Exists(sourcePath))
         {
             MessageBox.Show("The selected file does not exist!");
             return;
         }
     }
     if (entireFolderRadioButton.IsChecked.Value)
     {
         if (!Directory.Exists(sourcePath))
         {
             MessageBox.Show("The selected folder does not exist!");
             return;
         }
     }
     Creator = new TorrentCreator();
     var source = new TorrentFileSource(sourcePath, ignoreHiddenFilesCheckBox.IsChecked.Value);
     var tier = new RawTrackerTier(trackerListBox.Items.Cast<string>());
     Creator.Announces.Add(tier);
     Creator.Comment = commentTextBox.Text;
     Creator.Private = privateTorrentCheckBox.IsChecked.Value;
     Creator.CreatedBy = "Patchy BitTorrent Client";
     Creator.PieceLength = TorrentCreator.RecommendedPieceSize(source.Files);
     var dialog = new SaveFileDialog();
     dialog.Filter = "Torrent Files (*.torrent)|*.torrent|All Files (*.*)|*.*";
     dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
     FilePath = sourcePath;
     if (dialog.ShowDialog().Value)
     {
         // Create the torrent
         Path = dialog.FileName;
         if (!Path.EndsWith(".torrent"))
             Path += ".torrent";
         pathGrid.IsEnabled = trackerGrid.IsEnabled = optionsGrid.IsEnabled = createButton.IsEnabled = false;
         Creator.Hashed += Creator_Hashed;
         Creator.BeginCreate(source, CreationComplete, null);
     }
 }