FormRssShow.cs
资源名称:MobileRss.rar [点击查看]
上传用户:xtyqhl
上传日期:2022-06-07
资源大小:212k
文件大小:4k
源码类别:
Windows Mobile
开发平台:
Windows_Unix
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- using _3ESoft.WindowsMobile.Process;
- namespace _3ESoft.WindowsMobile.RSS
- {
- public partial class FormRssShow : Form
- {
- /// <summary>
- /// 当前RSS对象
- /// </summary>
- RssNews CurrRssNews;
- RssNews PreRssNews;
- RssNews NextRssNews;
- /// <summary>
- /// 当前频道所有News列表,全局的
- /// </summary>
- public List<RssNews> NewsList { get; set; }
- bool IsNavigated = false;
- public FormRssShow(RssNews _CurrRssNews)
- {
- InitializeComponent();
- CurrRssNews = _CurrRssNews;
- }
- private void FormRssShow_Load(object sender, EventArgs e)
- {
- PreRssAndNextRss();
- GetDocumentText();
- //IsNavigated = true;
- }
- /// <summary>
- /// 构建Html文档
- /// </summary>
- private void GetDocumentText()
- {
- StreamReader reader = new StreamReader(Global.AppRssStylePath() + "Style1.htm");
- string News = reader.ReadToEnd();
- News = News.Replace("#TITLE#", CurrRssNews.Title);
- News = News.Replace("#lblAuthor#", "作者");
- News = News.Replace("#Author#", CurrRssNews.Author);
- News = News.Replace("#PubDate#", CurrRssNews.PubDate);
- News = News.Replace("#Description#", CurrRssNews.Description);
- News = News.Replace("#LINK#", CurrRssNews.Link);
- News = News.Replace("#READ#", "在线阅读...");
- News = News.Replace("#PreRSS#", PreRssNews !=null?"阅读上一篇":"");
- News = News.Replace("#NextRSS#", NextRssNews != null ? "阅读下一篇" : "");
- CurrRssNews.IsRead = true;
- RssBrowser.DocumentText = News;
- }
- private void RssBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
- {
- string strUrl = e.Url.ToString();
- if (strUrl.ToUpper().EndsWith("&3ESOFT"))
- {
- //e.Cancel = true;
- if (strUrl.IndexOf("previous") > 0)
- {
- CurrRssNews = PreRssNews;
- }
- else if (strUrl.IndexOf("next") > 0)
- {
- CurrRssNews = NextRssNews;
- }
- PreRssAndNextRss();
- GetDocumentText();
- //IsNavigated = false;
- }
- //非向DocumentText赋值产生,非制定的连结,则用新IE打开
- else if (e.Url != new Uri("about:blank"))
- {
- e.Cancel = true;
- MobileProcess.CreateProcess("iexplore.exe", e.Url.ToString(), null);
- }
- }
- /// <summary>
- /// 生成上一篇,下一篇
- /// </summary>
- private void PreRssAndNextRss()
- {
- for (int i = 0; i < NewsList.Count; i++)
- {
- if (CurrRssNews == NewsList[i])
- {
- if (i == 0)
- {
- PreRssNews = null;
- NextRssNews = NewsList[i + 1];
- }
- else if (i == NewsList.Count-1)
- {
- PreRssNews = NewsList[i - 1];
- NextRssNews = null;
- }
- else
- {
- PreRssNews = NewsList[i - 1];
- NextRssNews = NewsList[i + 1];
- }
- }
- }
- }
- private void RssBrowser_Validating(object sender, CancelEventArgs e)
- {
- e.Cancel = true;
- }
- private void RssBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
- {
- //if (!IsNavigated)
- //{
- // GetDocumentText();
- // IsNavigated = true;
- //}
- }
- }
- }