void CreateNewEntry_Click(object sender, EventArgs e) { var dlg = new EntryCreateOrEditDialog(); if (dlg.ShowDialog() == DialogResult.OK) { try { // create a new entry // create new entry for feed SyndicationItem item = new SyndicationItem(); var urlOfArticle = new Uri(dlg.URL); // set the entry id to the URL for the item string url = urlOfArticle.AbsoluteUri; // TODO: create the GetArticleUrl method item.Id = url; // Add the URL for the item as a link var link = new SyndicationLink(urlOfArticle); item.Links.Add(link); // Fill some properties for the item item.Title = new TextSyndicationContent(dlg.TITLE); item.Summary = new TextSyndicationContent(WebUtility.HtmlEncode(dlg.MSG)); var dateTime = DateTime.Now; item.LastUpdatedTime = dateTime; item.PublishDate = dateTime; var it = CreateItem(item, 1 + listView1.Items.Count); listView1.Items.Add(it); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
void EditExistingEntry_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count == 0) { return; } var dlg = new EntryCreateOrEditDialog(); // prepare dialog fields var item = listView1.SelectedItems [0]; var entry = (SyndicationItem)item.Tag; dlg.URL = entry.Id; dlg.TITLE = entry.Title.Text; dlg.MSG = WebUtility.HtmlDecode(entry.Summary.Text); if (dlg.ShowDialog() == DialogResult.OK) { // change selected entry entry.BaseUri = new Uri(dlg.URL); entry.Content = new TextSyndicationContent(WebUtility.HtmlEncode(dlg.MSG)); } }