Ejemplo n.º 1
0
 void PrintArticle(RSSItem article)//Для одной записи
 {
     webBrowser1.NavigateToString("<html>" + "<head>" + "<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'>" + "<style type='text/css'>" + "A{color:#483D8B; text-decoration:none; font:Verdana;}" + "pre{font-family:courier;color:#000000;" +
                                  "background-color:#dfe2e5;padding-top:5pt;padding-left:5pt;" +
                                  "padding-bottom:5pt;border-top:1pt solid #87A5C3;" +
                                  "border-bottom:1pt solid #87A5C3;border-left:1pt solid #87A5C3;" +
                                  "border-right : 1pt solid #87A5C3;	text-align : left;}" +
                                  " img{width:100; height:50;}" +
                                  "</style>" +
                                  "</head>" +
                                  "<body>" +
                                  @"<font size=""2"" face=""Verdana"">" +
                                  "<a href=" + example.imageOfChannel.imgLink + ">" +
                                  "<img src=" + example.imageOfChannel.imgURL + " border=0></a>  " +
                                  "<h3>" + example.title + "</h3></a>" +
                                  @"<table width=""80%"" align=""center"" border=1>" +
                                  "<tr>" +
                                  "<td>" +
                                  @"<br>  <a href=" + article.link + "><b>" + article.title + "</b></a>" +
                                  "(" + article.pubDate + ")<br><br>" +
                                  @"<table width=""95 % "" align=""center"" border=0>" +
                                  "<tr><td>" +
                                  article.description +
                                  "</td></tr></table>" +
                                  "<br>  <a href=" + article.link + ">" +
                                  @"<font size=""1"">читать дальше</font></a><br><br>" +
                                  "</td>" +
                                  "</tr>" +
                                  "</table><br>" +
                                  @"<p align=""center"">" + "</font>" + "</body>" + "</html>");
 }
Ejemplo n.º 2
0
 private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex >= 0)
     {
         RSSItem article = example.Items[listBox1.SelectedIndex];
         PrintArticle(article);
     }
 }
Ejemplo n.º 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            Regex          regex    = new Regex(@"(\w*)" + textBox2.Text + @"(\w*)");
            int            i        = 0;
            List <RSSItem> articles = new List <RSSItem>();

            foreach (var a in listBox1.Items)
            {
                if (regex.IsMatch(a.ToString()))
                {
                    RSSItem article = example.Items[i];
                    articles.Add(article);
                }
                i++;
            }
            PrintArticle(articles);
        }
Ejemplo n.º 4
0
        public RSSChannel(string uri)
        {
            try
            {
                XmlDocument xDoc = new XmlDocument();
                UrlOfChannel = uri;
                LoadingChannel loading = new LoadingChannel(uri);
                loading.ShowDialog();
                string xml = loading.xml;
                xDoc.LoadXml(xml);
                XmlNode channelXmlNode = xDoc.GetElementsByTagName("channel")[0];
                if (channelXmlNode != null)
                {
                    foreach (XmlNode xnode in channelXmlNode.ChildNodes)
                    {
                        switch (xnode.Name)
                        {
                        case "title":
                        {
                            title = xnode.InnerText;
                            break;
                        }

                        case "link":
                        {
                            link = xnode.InnerText;
                            break;
                        }

                        case "description":
                        {
                            description = xnode.InnerText;
                            break;
                        }

                        case "image":
                        {
                            foreach (XmlNode image in xnode.ChildNodes)
                            {
                                if (image.Name == "url")
                                {
                                    imageOfChannel.imgURL = image.InnerText;
                                }
                                if (image.Name == "title")
                                {
                                    imageOfChannel.imgTitle = image.InnerText;
                                }
                                if (image.Name == "link")
                                {
                                    imageOfChannel.imgLink = image.InnerText;
                                }
                            }
                            break;
                        }

                        case "item":
                        {
                            RSSItem item = new RSSItem(xnode);
                            Items.Add(item);
                            break;
                        }
                        }
                    }
                }

                else
                {
                    throw new Exception("Ошибка в XML.Описание канала не найдено!");
                }
            }

            catch (System.Net.WebException ex)
            {
                if (ex.Status == System.Net.WebExceptionStatus.NameResolutionFailure)
                {
                    throw new Exception("Невозможно соединиться с указаным источником.\r\n" + uri);
                }

                else
                {
                    throw new Exception();
                }
            }
            catch (System.IO.FileNotFoundException)
            {
                throw new Exception("Файл " + uri + "не найден!");
            }
            catch (Exception a)
            {
                MessageBox.Show(a.Message);
            }
        }