public void SetToDefaults() { // General SaveSession = true; AutoUpdate = true; PromptForSaveOnShellLinks = true; DeleteTorrentsAfterAdd = false; SeedOnlyWhenIdle = false; // Downloads DefaultDownloadLocation = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads"); PostCompletionDestination = string.Empty; WatchedDirectories = new WatchedDirectory[0]; // Connection IncomingPort = 22239; UseRandomPort = false; MapWithUPnP = false; MaxUploadSpeed = 0; MaxDownloadSpeed = 0; MaxConnections = 500; MaxConnectionsPerTorrent = 100; UploadSlotsPerTorrent = 4; // BitTorrent EnableDHT = true; EncryptionSettings = EncryptionTypes.RC4Header | EncryptionTypes.RC4Full; HoursToSeed = 0; TargetSeedRatio = 0; // Interface ShowTrayIcon = true; CloseToSystemTray = true; MinimizeToSystemTray = false; ShowNotificationOnCompletion = true; ConfirmExitWhenActive = true; ConfirmTorrentRemoval = true; WarnOnDangerousFiles = true; WarnWhenRunningAsAdministrator = true; StartTorrentsImmediately = true; DoubleClickSeeding = DoubleClickAction.OpenFolder; DoubleClickDownloading = DoubleClickAction.OpenFolder; // Completion TorrentCompletionCommand = string.Empty; // RSS RssFeeds = new RssFeed[0]; MinutesBetweenRssUpdates = 5; // Other RecentDownloadLocations = new string[0]; Labels = new TorrentLabel[0]; TotalBytesDownloaded = TotalBytesUploaded = 0; WindowWidth = WindowHeight = -1; Maximized = false; }
private void addNewFeedButtonClick(object sender, RoutedEventArgs e) { addNewFeedButton.IsEnabled = newFeedUrlTextBox.IsEnabled = false; var address = newFeedUrlTextBox.Text; if (Settings.RssFeeds.Any(f => f.Address == address)) { MessageBox.Show("The specified feed has already been added.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); addNewFeedButton.IsEnabled = newFeedUrlTextBox.IsEnabled = true; return; } Task.Factory.StartNew(() => { // Validate feed var client = new WebClient(); try { var feed = client.DownloadString(address); var document = XDocument.Parse(feed); if (!RssFeed.ValidateFeed(document)) throw new Exception(); var rss = new RssFeed(address); Dispatcher.BeginInvoke(new Action(() => { Settings.RssFeeds = Settings.RssFeeds.Concat(new[] { rss }).ToArray(); Settings.OnPropertyChanged("RssFeeds"); addNewFeedButton.IsEnabled = newFeedUrlTextBox.IsEnabled = true; newFeedUrlTextBox.Text = string.Empty; feedListView.SelectedItem = rss; })); } catch { MessageBox.Show("The specified feed is not valid.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Dispatcher.BeginInvoke(new Action(() => addNewFeedButton.IsEnabled = newFeedUrlTextBox.IsEnabled = true)); } }); }