using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using System.Xml.Linq;

namespace RssReader
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        private Dictionary<string, RssItem> items
            = new Dictionary<string, RssItem>();

        public MainWindow()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            #region 设置RSS访问位置
            string url = "";
            switch (comboBox1.SelectedIndex)
            {
                case 0:
                    url = "http://tw.news.yahoo.com/rss/life";
                    break;
                case 1:
                    url = "http://udn.com/udnrss/latest.xml";
                    break;
                default:
                    url = "http://tw.news.yahoo.com/rss/life";
                    break;
            }
            #endregion

            try
            {
                //TODO: 1.加载RSS新闻数据

                listBox1.Items.Clear();
                items.Clear();

                //TODO: 2.取出新闻标题，转成RssItem对象，并暂存到列表控件中

            }
            catch (Exception ex)
            {

            }

        }

        private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (listBox1.SelectedIndex != -1)
            {
                //TODO: 3.取出用户选取项目，显示新闻内容

            }
        }
    }
}

