Click here to Skip to main content
15,896,154 members
Articles / Desktop Programming / WPF

(Hybrid Smart Client) RSS Media Player

Rate me:
Please Sign up or sign in to vote.
3.92/5 (8 votes)
9 Mar 2009CPOL4 min read 68.7K   1K   17  
A WPF application for viewing RSS video feeds. Built using the MVVM pattern.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using RSSVideoPlayer.Data;
using RSSVideoPlayer.Model;
using System.Windows.Controls;
namespace RSSVideoPlayer.ViewModel
{
    class RSSViewModel : TabViewModel
    {
        private List<FeedItem> _Articals;
       
        public RSSViewModel()
        {
            base.TabName = "RSS Items";
            _Articals = new RSSRepository("http://windowsclient.net/blogs/MainFeed.aspx?GroupID=11&Type=AllBlogs").GetFeedItems;
        }


        #region "Properties"

        private string _RSSURL;
        public string RSSURL
        {
            get { return _RSSURL; }
            set { 
                _RSSURL = value;
                _Articals = new RSSRepository(_RSSURL).GetFeedItems;
                OnPropertyChanged("Articals");
                OnPropertyChanged("RSSURL");
            }
        }

        public List<FeedItem> Articals
        {
            get { return _Articals; }
        }
        public List<MediaItem> MediaItems
        {
            get { return SelectedArtical.MediaItems; }
        }

        private FeedItem _SelectedArtical;
        public FeedItem SelectedArtical
        {
            get { return _SelectedArtical; }
            set
            {
                _SelectedArtical = value;
                OnPropertyChanged("SelectedArtical");
                 OnPropertyChanged("SelectedMedia");
                 OnPropertyChanged("MediaItems");
            }
        }

        private MediaItem _SelectedMedia;
        public MediaItem SelectedMedia
        {
            get { return _SelectedMedia; }
            set
            {
                _SelectedMedia = value;
                OnPropertyChanged("SelectedMedia");
                OnNewMedia(SelectedMedia.FullURL);
            }
        }

        public List<ComboBoxItem> SavedURLS
        {
            get
            {
                List<ComboBoxItem> lst = new List<ComboBoxItem>();

                foreach (string s in Properties.Settings.Default.RSSURLS)
                {
                    ComboBoxItem cmb = new ComboBoxItem();
                    cmb.Content = s;
                    lst.Add(cmb);
                }
                return lst;
            }
        }

        #endregion

        public event EventHandler<Common.MediaChangedEventArgs> NewMediaItem;
        private void OnNewMedia(string Media)
        {
            if (NewMediaItem != null)
                NewMediaItem(this,new RSSVideoPlayer.Common.MediaChangedEventArgs(Media));
        }


    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Anytime Fitness
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions