private void addFeedRuleButtonClick(object sender, RoutedEventArgs e)
        {
            var feed = (RssFeed)feedListView.SelectedItem;

            if (string.IsNullOrEmpty(ruleRegexTextBox.Text))
            {
                return;
            }
            var path = Settings.DefaultDownloadLocation;

            if (rssOtherLocationRadioButton.IsChecked.Value)
            {
                path = rssSaveDirectoryTextBox.Text;
            }
            if (!Directory.Exists(path))
            {
                MessageBox.Show("The specified directory does not exist.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            Regex regex;

            try
            {
                regex = new Regex(ruleRegexTextBox.Text, RegexOptions.IgnoreCase);
            }
            catch
            {
                MessageBox.Show("The specified regular expression is not valid.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            var type = (RssTorrentRule.RuleType)ruleTypeComboBox.SelectedIndex;

            if (feed.TorrentRules.Any(r => r.Type == type && r.Regex.ToString() == regex.ToString()))
            {
                MessageBox.Show("This rule has already been added.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            var rule = new RssTorrentRule(type, regex);

            rule.Label        = (rssLabelComboBox.SelectedItem as ComboBoxItem).Tag as TorrentLabel;
            rule.DownloadPath = path;
            feed.TorrentRules.Add(rule);
            ruleRegexTextBox.Text = string.Empty;
        }
 private void addFeedRuleButtonClick(object sender, RoutedEventArgs e)
 {
     var feed = (RssFeed)feedListView.SelectedItem;
     if (string.IsNullOrEmpty(ruleRegexTextBox.Text))
         return;
     var path = Settings.DefaultDownloadLocation;
     if (rssOtherLocationRadioButton.IsChecked.Value)
         path = rssSaveDirectoryTextBox.Text;
     if (!Directory.Exists(path))
     {
         MessageBox.Show("The specified directory does not exist.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     Regex regex;
     try
     {
         regex = new Regex(ruleRegexTextBox.Text, RegexOptions.IgnoreCase);
     }
     catch
     {
         MessageBox.Show("The specified regular expression is not valid.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     var type = (RssTorrentRule.RuleType)ruleTypeComboBox.SelectedIndex;
     if (feed.TorrentRules.Any(r => r.Type == type && r.Regex.ToString() == regex.ToString()))
     {
         MessageBox.Show("This rule has already been added.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     var rule = new RssTorrentRule(type, regex);
     rule.Label = (rssLabelComboBox.SelectedItem as ComboBoxItem).Tag as TorrentLabel;
     rule.DownloadPath = path;
     feed.TorrentRules.Add(rule);
     ruleRegexTextBox.Text = string.Empty;
 }