public MainWindow()
 {
     InitializeComponent();
     RssReader = new RssReader();
     AllUris = new List<Uri>
     {
         new Uri("http://alexosigge.libsyn.com/rss"),
         new Uri("http://varvet.libsyn.com/rss"),
         new Uri("http://www.filipandfredrik.com/feed/")
     };
     AllFeeds = new List<Feed>();
 }
示例#2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            bool allGood = true;
            string message = null;
            string url = txbUrl.Text;

            if (!InputValidator.IsUrl(url))
            {
                allGood = false;
                message += "The \"Url-field\" must be in the correct format. \n";
            }
            if (InputValidator.IsEmpty(txbUpdate.Text))
            {
                allGood = false;
                message += "The \"Update Interval-field\" must be filled in. \n";
            }
            if (InputValidator.ContainsChar(txbUpdate.Text))
            {
                allGood = false;
                message += "The \"Update Interval-field\" can´t contain characters. \n";
            }
            //validering

            if (allGood)
            {
                RssReader rr = new RssReader();
                Feed feed = rr.ReadBasicFeed(url);
                rr.UpdateFeedItems(feed);
                feed.UpdateInterval = Convert.ToInt64(txbUpdate.Text) * TimeSpan.TicksPerDay;

                feed.Category = new Category() { Name = cbCategory.Text };
                feed.LastUpdate = DateTime.Today;

                feedList.Add(feed);

                MessageBox.Show("The new feed has been added!", "Sucess!");
                txbUpdate.Clear();
                txbUrl.Clear();

            }
            else
            {
                MessageBox.Show(message, "Error");
            }
        }
 private void textBoxUrl_LostFocus(object sender, RoutedEventArgs e)
 {
     var rssReader = new RssReader();
     try
     {
         FeedOut = rssReader.ReadFeed(new Uri(textBoxUrl.Text));
         labelTitleShow.Content = FeedOut.Title + ", episodes: " + FeedOut.CollectionFeedItems.Count;
     }
     catch (UriFormatException ex)
     {
         labelTitleShow.Content = ex.Message;
         FeedOut = null;
     }
     catch (Exception ex)
     {
         labelTitleShow.Content = ex.Message;
         FeedOut = null;
     }
 }
        private void textBoxURL_Leave(object sender, EventArgs e)
        {
            var rssReader = new RssReader();

            try
            {
                labelTitle.Text = "Title:";
                NewFeed = rssReader.ReadFeed(new Uri(textBoxURL.Text));
                textBoxTitle.Text = NewFeed.Title;
                labelEpisodes.Text = "Episodes: " + NewFeed.CollectionFeedItems.Count;

            }
            catch (UriFormatException ex)
            {
                labelTitle.Text = ex.Message;
                NewFeed = null;
            }
            catch (Exception ex)
            {
                labelTitle.Text = ex.Message;
                NewFeed = null;
            }
        }
 private void textBoxURL_Leave(object sender, EventArgs e)
 {
     var rssReader = new RssReader();
     try
     {
         EditedFeed = rssReader.ReadFeed(new Uri(textBoxURL.Text));
         textBoxTitle.Text = EditedFeed.Title;
         labelEpisode.Text = "Episodes: " + EditedFeed.CollectionFeedItems.Count + "";
     }
     catch (UriFormatException ex)
     {
         MessageBox.Show("Can't read URL: " + textBoxURL.Text + " " + ex.Message);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Can't read URL: " + textBoxURL.Text + " " + ex.Message);
     }
 }
        private void TimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs, Feed feed)
        {
            var rssReader = new RssReader();
            var newFeedItems = rssReader.ReadFeedItems(feed.Url);

            foreach (var f in AllFeeds)
            {
                if (feed.Equals(f))
                {
                    var i = newFeedItems.Count - f.CollectionFeedItems.Count;
                    f.CollectionFeedItems = new List<IFeedItem>(newFeedItems);
                    MessageBox.Show(i + " new episodes for " + f.Title);
                }
            }
        }