private void AddView(Publisher publisher)
 {
     var news = new NewsView(publisher);
     news.Header = publisher.Name;
     views.Add(publisher, news);
     this.newsContainer.SelectedIndex = this.newsContainer.Items.Add(news);
 }
        public Publisher ParsePublisher(XmlDocument document)
        {
            if (document == null)
                throw new ArgumentNullException("document");

            Publisher publisher = null;
            XmlElement root = document.DocumentElement;
            if (root.Name.Equals(AtomTag.Feed)) {

                publisher = new Publisher();
                publisher.Name = ParserUtility.GetValueOfElement(root, AtomTag.Title);
                publisher.Description = ParserUtility.GetValueOfElement(root, AtomTag.Subtitle);
                publisher.Address = ParserUtility.GetValueOfAtribute(root, AtomTag.Link, "href");

                XmlNodeList entries = root.GetElementsByTagName(AtomTag.Entry);
                if (entries.Count > 0) {
                    publisher.Messages = new List<Message>();
                    Message message;
                    for (int i = 0; i < entries.Count; i++) {
                        message = new Message();
                        message.Name = ParserUtility.GetValueOfElement((XmlElement)entries.Item(i), AtomTag.Title);
                        message.Address = ParserUtility.GetValueOfAtribute((XmlElement)entries.Item(i), AtomTag.Link, "href");
                        string desc = ParserUtility.GetValueOfElement((XmlElement)entries.Item(i), AtomTag.Summary);
                        message.Value = (desc != null) ? desc : ParserUtility.GetValueOfElement((XmlElement)entries.Item(i), AtomTag.Content);
                        message.PublishDate = DateTime.Parse(ParserUtility.GetValueOfElement((XmlElement)entries.Item(i), AtomTag.Published));
                        message.Author = ParserUtility.GetValueOfElement((XmlElement)entries.Item(i), AtomTag.Author);
                        message.Viewed = false;
                        publisher.Messages.Add(message);
                    }
                }
                return publisher;
            }
            throw new ParserException("Bad header xml");
        }
Exemple #3
0
 public Publisher ParsePublisher(XmlDocument document)
 {
     Publisher publisher = new Publisher();
     XmlElement root = document.DocumentElement;
     if (root.Name.Equals(RssTag.Rss)) {
         XmlNodeList list = root.GetElementsByTagName(RssTag.Channel);
         if (root.FirstChild.Name == RssTag.Channel) {
             XmlElement channel = (XmlElement)root.FirstChild;
             publisher.Name = ParserUtility.GetValueOfElement(channel, RssTag.Title);
             publisher.Description = ParserUtility.GetValueOfElement(channel, RssTag.Description);
             publisher.Address = ParserUtility.GetValueOfElement(channel, RssTag.Link);
             publisher.AddDate = DateTime.Now.ToUniversalTime();
             publisher.Messages = new List<Message>();
             XmlNodeList items = channel.GetElementsByTagName(RssTag.Item);
             if (items.Count > 0) {
                 Message message;
                 for (int i = 0; i < items.Count; i++) {
                     message = new Message();
                     message.Publisher = publisher;
                     message.Name = ParserUtility.GetValueOfElement((XmlElement)items.Item(i), RssTag.Title);
                     message.Address = ParserUtility.GetValueOfElement((XmlElement)items.Item(i), RssTag.Link);
                     message.Value = HTMLConverter.HtmlToXamlConverter.ConvertHtmlToXaml(ParserUtility.GetValueOfElement((XmlElement)items.Item(i), RssTag.Description), false);
                     message.PublishDate = DateTime.Parse(ParserUtility.GetValueOfElement((XmlElement)items.Item(i), RssTag.PublishDate));
                     message.Author = ParserUtility.GetValueOfElement((XmlElement)items.Item(i), RssTag.Author);
                     message.Viewed = false;
                     publisher.Messages.Add(message);
                 }
             }
             return publisher;
         }
         throw new ParserException("Bad xml tag. Expected " + RssTag.Channel + " but was: " + root.FirstChild);
     }
     throw new ParserException("Bad root xml tag. Expected " + RssTag.Rss + " but was: " + root);
 }
 public void AddToCategory(Category category, Publisher publisher)
 {
     if (this.categories.Keys.Contains(category.Id)) {
         var categoryItem = this.categories[category.Id];
         categoryItem.AddPublisher(publisher);
     }
 }
 public void ShowView(Publisher publisher)
 {
     if (views.ContainsKey(publisher)) {
         this.newsContainer.SelectedItem = views[publisher];
     } else {
         AddView(publisher);
     }
 }
 public NewsView(Publisher publisher)
 {
     InitializeComponent();
     this.publisher = publisher;
     this.newsList.SelectionChanged +=
         new System.Windows.Controls.SelectionChangedEventHandler(newsList_SelectionChanged);
     foreach (var message in this.publisher.Messages) {
         ListViewItem item = new ListViewItem();
         item.Content = message;
         if (!message.Viewed)
             item.FontWeight = FontWeights.Bold;
         this.newsList.Items.Add(item);
     }
 }
 public void AddPublisher(Publisher publisher)
 {
     this.publishers.Add(publisher);
     this.publishersList.Items.Add(publisher);
 }
 private void categoryList_SelectionChanged(EtherSoftware.NewsPresenter.View.Component.CategoryItem category, Publisher publisher)
 {
     Facade.SendNotification(ApplicationFacade.ShowPublisher, publisher);
 }
 private void category_SelectedPublisherChanged(CategoryItem obj, Publisher sndr)
 {
     if (SelectionChanged != null)
         SelectionChanged(obj, sndr);
 }
 public void Store(Publisher publisher)
 {
     publisherRepository.Save(publisher);
 }