private void setWebBrowserUrlToFeedItemLinkUrl(FeedItem fi) { if (webBrowser1.Url == null || webBrowser1.Url.AbsoluteUri != fi.LinkUrl) { webBrowser1.Navigate(fi.LinkUrl); } }
private void setFeedSubNodeText(TreeNode node, FeedSubscription fs) { string text; bool errorCapturedAsItem = false; if (fs.Feed.ReadSuccess == false && fs.Feed.ReadException != null) { //text = fs.DisplayName + "(" + fs.Feed.ReadException.ToString() + ")"; FeedItem fi = new FeedItem(); fi.Author = "BetterReader"; fi.Description = string.Format("Error during read of feed: {0}", fs.Feed.ReadException); fi.DownloadDate = DateTime.Now; fi.HasBeenRead = false; fi.ParentFeed = fs.Feed; fi.PubDate = DateTime.Now; fi.Title = string.Format("Error reading feed: {0}", fs.Feed.ReadException.Message); fi.SetGuid(); fs.Feed.FeedItems.AddOrUpdate(fi); errorCapturedAsItem = true; } if (fs.Feed.ReadSuccess || errorCapturedAsItem) { text = fs.ToString(); if (fs.Feed.UnreadCount > 0) { node.NodeFont = feedsBoldFont; } else { node.NodeFont = feedsNormalFont; } if (fs.Feed.UnreadCount == 0 && hideReadFeedsBTN.Checked) { //user has selected hideReadFeeds option and this feed has no unread items feedsTreeView.HideNode(node); } else { feedsTreeView.ShowNode(fs); } } else { //if (fs.Feed.ReadException != null) //{ // //text = fs.DisplayName + "(" + fs.Feed.ReadException.ToString() + ")"; // FeedItem fi = new FeedItem(); // fi.Author = "BetterReader"; // fi.Description = string.Format("Error during read of feed: {0}", fs.Feed.ReadException); // fi.DownloadDate = DateTime.Now; // fi.HasBeenRead = false; // fi.ParentFeed = fs.Feed; // fi.PubDate = DateTime.Now; // fi.Title = string.Format("Error reading feed: {0}", fs.Feed.ReadException.Message); //} //else //{ text = "Loading . . ."; //} } node.Text = text; }
private void displayFeedItemDefaultMethod(FeedItem fi) { if (fi != null) { string docText = getFeedItemDescription(fi); if (docText != "") { setWebBrowserText(docText); } else { webBrowser1.DocumentText = formatDescriptionHTML("Loading page . . ."); setWebBrowserUrlToFeedItemLinkUrl(fi); } } }
private string getFeedItemDescription(FeedItem fi) { string docText = ""; if (fi.EncodedContent != null && fi.EncodedContent.Length > 0) { docText = formatDescriptionHTML(fi.EncodedContent); } else if (fi.Description != null && fi.Description.Length > 0) { docText = formatDescriptionHTML(fi.Description); } return docText; }
private int smartSort(FeedItem feedItemX, FeedItem feedItemY) { int result = 0; if (feedItemX.HasBeenRead != feedItemY.HasBeenRead) { if (feedItemX.HasBeenRead) { result = 1; } else { result = -1; } } //if (result == 0) //{ // if (feedItemX.PubDate != feedItemY.PubDate) // { // if (feedItemX.PubDate == null) // { // result = -1; // } // else if (feedItemY.PubDate == null) // { // result = 1; // } // else // { // if (feedItemX.PubDate > feedItemY.PubDate) // { // result = -1; // } // else // { // result = 1; // } // } // } // if (result == 0) // { // if (feedItemX.DownloadDate != feedItemY.DownloadDate) // { // if (feedItemX.DownloadDate > feedItemY.DownloadDate) // { // result = -1; // } // else // { // result = 1; // } // } // } //} return result; }
private void setListViewItemSubItems(ListViewItem lvi, FeedItem fi, FeedItemProperties itemProps) { if ((itemProps & FeedItemProperties.PubDate) == FeedItemProperties.PubDate) { lvi.SubItems.Add(fi.PubDate.ToString()); } if ((itemProps & FeedItemProperties.HasBeenRead) == FeedItemProperties.HasBeenRead) { lvi.SubItems.Add(fi.HasBeenRead.ToString()); } if (((itemProps & FeedItemProperties.DownloadDate) == FeedItemProperties.DownloadDate) && ((itemProps & FeedItemProperties.PubDate) != FeedItemProperties.PubDate)) { //only show downloadDate if pubDate is unavailable lvi.SubItems.Add(fi.DownloadDate.ToString()); } if ((itemProps & FeedItemProperties.Category) == FeedItemProperties.Category) { lvi.SubItems.Add(fi.Category.ToString()); } if ((itemProps & FeedItemProperties.Author) == FeedItemProperties.Author) { lvi.SubItems.Add(fi.Author.ToString()); } }
internal void MarkFeedItemRead(FeedItem fi) { if (fi.HasBeenRead == false) { fi.MarkRead(); } feedItemsLV.SelectedItems[0].Font = feedItemsNormalFont; feedSubManager.UpdateNodeFromFeedSubscription(fi.ParentFeed.ParentSubscription); fi.ParentFeed.FeedItems.ArchiveItems(); }
public static FeedItem GetFromRssOrRdfItemNode(XmlNode node) { FeedItem fi = new FeedItem(); fi.hasBeenRead = false; foreach (XmlNode childNode in node.ChildNodes) { string innerText = childNode.InnerText; switch (childNode.Name.ToLower()) { case "title": fi.title = Feed.HtmlDecode(innerText); break; case "link": fi.linkUrl = innerText; break; case "category": fi.category = Feed.HtmlDecode(innerText); break; case "author": fi.author = Feed.HtmlDecode(innerText); break; case "pubdate": case "dc:date": fi.pubDate = fi.safeDateTimeParse(innerText); break; case "guid": //a linefeed in a guid causes problems with uniquely identifying items fi.guid = innerText.Replace("\r\n", ""); break; case "description": fi.description = innerText; break; case "content:encoded": fi.encodedContent = innerText; break; default: if (fi.unsupportedFeedItemProperties.ContainsKey(childNode.Name)) { fi.unsupportedFeedItemProperties[childNode.Name] += "|" + innerText; } else { fi.unsupportedFeedItemProperties.Add(childNode.Name, innerText); } break; } } fi.SetGuid(); fi.downloadDate = DateTime.Now; fi.setIncludedProperties(); return fi; }
public static FeedItem GetFromAtomEntryNode(XmlNode node) { FeedItem fi = new FeedItem(); fi.hasBeenRead = false; foreach (XmlNode childNode in node.ChildNodes) { string innerText = childNode.InnerText; switch (childNode.Name.ToLower()) { case "title": fi.title = Feed.HtmlDecode(innerText); break; case "link": if (innerText != null && innerText != string.Empty) { fi.linkUrl = innerText; } else { fi.linkUrl = childNode.Attributes["href"].Value; } break; case "category": fi.category = Feed.HtmlDecode(innerText); break; case "author": foreach (XmlNode authorNode in childNode.ChildNodes) { if (authorNode.Name == "name") { fi.author = Feed.HtmlDecode(authorNode.InnerText); } } break; case "modified": fi.pubDate = fi.safeDateTimeParse(innerText); break; case "id": //a linefeed in the guid causes uniqueness problems fi.guid = innerText.Replace("\r\n", ""); break; case "content": fi.description = innerText; break; default: if (fi.unsupportedFeedItemProperties.ContainsKey(childNode.Name)) { fi.unsupportedFeedItemProperties[childNode.Name] += "|" + innerText; } else { fi.unsupportedFeedItemProperties.Add(childNode.Name, innerText); } break; } } fi.SetGuid(); fi.downloadDate = DateTime.Now; fi.setIncludedProperties(); return fi; }