FormRssList.cs
上传用户:xtyqhl
上传日期:2022-06-07
资源大小:212k
文件大小:4k
源码类别:

Windows Mobile

开发平台:

Windows_Unix

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.IO;
  9. namespace _3ESoft.WindowsMobile.RSS
  10. {
  11.     public partial class FormRssList : Form
  12.     {
  13.         Rss MyRss = null;
  14.         Opml myOpml;
  15.         public FormRssList(Opml opml)
  16.         {
  17.             InitializeComponent();
  18.             myOpml = opml;
  19.         }
  20.         
  21.         private void FormRssList_Load(object sender, EventArgs e)
  22.         {
  23.             Cursor.Current = Cursors.WaitCursor;
  24.             Cursor.Show();
  25.             Application.DoEvents();
  26.             try
  27.             {
  28.                 string TopicLinkUrl = myOpml.XmlUrl ;
  29.                 string FilePath = Global.FormatUrl(TopicLinkUrl);
  30.                 if (MyRss == null)
  31.                 {
  32.                     MyRss = new Rss();
  33.                     if (!File.Exists(FilePath))
  34.                     {
  35.                         MyRss.UpdateRssNews(TopicLinkUrl);
  36.                         if (MyRss.RssNewsList == null)
  37.                         {
  38.                             return;
  39.                         }
  40.                     }
  41.                     Application.DoEvents();
  42.                     MyRss.GetRssNewsList(FilePath);
  43.                 }
  44.                 BindRssNews();
  45.             }
  46.             catch (Exception ex)
  47.             {
  48.                 MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
  49.             }
  50.             finally
  51.             {
  52.                 Cursor.Current = Cursors.Default;
  53.             }
  54.         }
  55.         /// <summary>
  56.         /// 执行绑定
  57.         /// </summary>
  58.         private void BindRssNews()
  59.         {
  60.             lvList.Items.Clear();
  61.             foreach (RssNews myRssNews in MyRss.RssNewsList)
  62.             {
  63.                 RssListViewItem lvItem = new RssListViewItem();
  64.                 lvItem.RssNews = myRssNews;
  65.                 if (myRssNews.IsRead)
  66.                     lvItem.ImageIndex = 1;
  67.                 else
  68.                     lvItem.ImageIndex = 0;
  69.                 lvItem.SubItems.Add(myRssNews.Title);
  70.                 //lvItem.SubItems.Add(myRssNews.Author);
  71.                 lvItem.SubItems.Add(Convert.ToDateTime(myRssNews.PubDate).ToString("M-d H:mm"));
  72.                 lvList.Items.Add(lvItem);
  73.                 Application.DoEvents();
  74.             }
  75.         }
  76.         private void miGoBack_Click(object sender, EventArgs e)
  77.         {
  78.             this.Close();
  79.         }
  80.         private void miRead_Click(object sender, EventArgs e)
  81.         {
  82.             if (lvList.FocusedItem == null)
  83.                 return;
  84.             FormRssShow frmWebShow = new FormRssShow(((RssListViewItem)lvList.FocusedItem).RssNews);
  85.             frmWebShow.NewsList = MyRss.RssNewsList;
  86.             frmWebShow.ShowDialog();
  87.             //更新状态
  88.             for (int i = 0; i < lvList.Items.Count;i++ )
  89.             {
  90.                 if (((RssListViewItem)lvList.Items[i]).RssNews.IsRead)
  91.                     lvList.Items[i].ImageIndex = 1;
  92.             }
  93.         }
  94.         private void FormRssList_Closing(object sender, CancelEventArgs e)
  95.         {
  96.             if (MyRss.RssNewsList!=null && MyRss.RssNewsList.Count > 0)
  97.                 MyRss.SaveRssNews(Global.FormatUrl(this.myOpml.XmlUrl));
  98.         }
  99.         private void miUpdate_Click(object sender, EventArgs e)
  100.         {
  101.             new FormUpdateRss(myOpml).ShowDialog();
  102.         }
  103.     }
  104. }