FormRssList.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;
- namespace _3ESoft.WindowsMobile.RSS
- {
- public partial class FormRssList : Form
- {
- Rss MyRss = null;
- Opml myOpml;
- public FormRssList(Opml opml)
- {
- InitializeComponent();
- myOpml = opml;
- }
- private void FormRssList_Load(object sender, EventArgs e)
- {
- Cursor.Current = Cursors.WaitCursor;
- Cursor.Show();
- Application.DoEvents();
- try
- {
- string TopicLinkUrl = myOpml.XmlUrl ;
- string FilePath = Global.FormatUrl(TopicLinkUrl);
- if (MyRss == null)
- {
- MyRss = new Rss();
- if (!File.Exists(FilePath))
- {
- MyRss.UpdateRssNews(TopicLinkUrl);
- if (MyRss.RssNewsList == null)
- {
- return;
- }
- }
- Application.DoEvents();
- MyRss.GetRssNewsList(FilePath);
- }
- BindRssNews();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
- }
- finally
- {
- Cursor.Current = Cursors.Default;
- }
- }
- /// <summary>
- /// 执行绑定
- /// </summary>
- private void BindRssNews()
- {
- lvList.Items.Clear();
- foreach (RssNews myRssNews in MyRss.RssNewsList)
- {
- RssListViewItem lvItem = new RssListViewItem();
- lvItem.RssNews = myRssNews;
- if (myRssNews.IsRead)
- lvItem.ImageIndex = 1;
- else
- lvItem.ImageIndex = 0;
- lvItem.SubItems.Add(myRssNews.Title);
- //lvItem.SubItems.Add(myRssNews.Author);
- lvItem.SubItems.Add(Convert.ToDateTime(myRssNews.PubDate).ToString("M-d H:mm"));
- lvList.Items.Add(lvItem);
- Application.DoEvents();
- }
- }
- private void miGoBack_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void miRead_Click(object sender, EventArgs e)
- {
- if (lvList.FocusedItem == null)
- return;
- FormRssShow frmWebShow = new FormRssShow(((RssListViewItem)lvList.FocusedItem).RssNews);
- frmWebShow.NewsList = MyRss.RssNewsList;
- frmWebShow.ShowDialog();
- //更新状态
- for (int i = 0; i < lvList.Items.Count;i++ )
- {
- if (((RssListViewItem)lvList.Items[i]).RssNews.IsRead)
- lvList.Items[i].ImageIndex = 1;
- }
- }
- private void FormRssList_Closing(object sender, CancelEventArgs e)
- {
- if (MyRss.RssNewsList!=null && MyRss.RssNewsList.Count > 0)
- MyRss.SaveRssNews(Global.FormatUrl(this.myOpml.XmlUrl));
- }
- private void miUpdate_Click(object sender, EventArgs e)
- {
- new FormUpdateRss(myOpml).ShowDialog();
- }
- }
- }