/// <summary> /// loads the articlesView to show the articles of the rss feed that is currently selected in the feedsView /// </summary> private void LoadFeed() { articlesView.Items.Clear(); string baseURL = ((RSSFeed)feedsView.SelectedItem).URL; int index = AddWindow.PreviousWebsites.FindIndex(f => f.NodeChannel.BaseURI == baseURL); currentWebsite = AddWindow.PreviousWebsites[index]; if (currentWebsite != null) { int loopCount = 0; for (int i = 0; i < currentWebsite.NodeChannel.ChildNodes.Count; i++) { if (currentWebsite.NodeChannel.ChildNodes[i].Name == "item") { loopCount++; nodeItem = currentWebsite.NodeChannel.ChildNodes[i]; articlesView.Items.Add(new RSSSite { Number = loopCount.ToString() + ".", Title = nodeItem["title"].InnerText, URL = nodeItem["link"].InnerText }); } } } }
/// <summary> /// gets the string that has been entered in the importText field and checks if it is a url then creates a website class of it /// and adds it to the websites list and the listview /// </summary> private void ImportURL() { string rss = importText.Text; Regex regex = new Regex(@"((https?|ftp|file)\://|www.)[A-Za-z0-9\.\-]+(/[A-Za-z0-9\?\&\=;\+!'\(\)\*\-\._~%]*)*", RegexOptions.IgnoreCase); Match match = regex.Match(rss); if (match.Success) { Website tempWebsite = null; try { tempWebsite = new Website(rss); } catch (Exception) { MessageBox.Show("The reader could not connect to the feed \nplease check your network connection\nand make sure the URL is correct", "ERROR could not resolve URL"); } if (tempWebsite != null) { //add website to list of websites websites.Add(tempWebsite); //add the item to the listview listView.Items.Add(new { Website = tempWebsite.NodeChannel["title"].InnerText, URL = tempWebsite.NodeChannel.BaseURI }); } } else { MessageBox.Show("The URL was not inputted correctly", "ERROR"); } }