Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » Samples » Downloads
 
Add your own
alternative version

RSS 2.0 Framework

, 19 Jan 2013 LGPL3
RSS 2.0 framework implements the RSS 2.0 specification in strongly typed classes. The framework enables you to create and consume valid RSS 2.0 feeds in your code in just a few minutes.
rssframework_bin.zip
Raccoom.Xml.dll
Raccoom.Xml.Editors.exe
DockingManagerExtender.dll
MagicLibrary.DLL
Raccoom.Windows.Forms.dll
rssframework_demo.zip
Raccoom.Bin
DockingManagerExtender.dll
MagicLibrary.DLL
nunit.framework.dll
Raccoom.Windows.Forms
Windows
Forms
Design
Raccoom.Xml
Properties
Raccoom.Xml.csproj.user
Xml
atom.xsx
Raccoom.Xml.Editors
ActionList
Actions
Design
App.ico
Raccoom.Xml.Editors.csproj.user
Windows
Forms
Raccoom.Xml.Test
Resources
rsschannel.rss
bin
rssframework_help.zip
Raccoom.Xml.chm
rssframework_src.zip
rsschannel.rss
Raccoom.Xml.csproj.user
atom.xsx
setup.zip
setup.exe
// Copyright � 2006 by Christoph Richner. All rights are reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
//
// website http://www.raccoom.net, email support@raccoom.net, msn chrisdarebell@msn.com

using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using Raccoom.Xml;

namespace Raccoom.Windows.Forms
{
	/// <summary>
	/// Summary description for RssFeedUIManager.
	/// </summary>
	[System.Drawing.ToolboxBitmap(typeof(System.Data.OleDb.OleDbDataAdapter))]
	public class RssFeedDataAdaptor : System.ComponentModel.Component, ISupportInitialize
	{
		#region fields
		private string _favoritePath = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "favorites.opml");
		private RssFeedManager _manager = null;
		private OpmlDocumentFavorites _favorites = null;
		private IRssFeedDataAdaptorOpmlView _favoritesControl;
		private IRssFeedDataAdaptorOpmlView _historyControl;
		private IRssFeedDataAdaptorRssView _browserControl;
		private IEnvironmentWindow _environmentWindow;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		#endregion

		#region constructors
		public RssFeedDataAdaptor(System.ComponentModel.IContainer container)
		{
			
			container.Add(this);
			InitializeComponent();
		}

		public RssFeedDataAdaptor()
		{			
			InitializeComponent();
		}
		#endregion

		#region public interface
		public void ShowOrganizeFavoriteDialog()
		{
			new FavoritesManageDialog(this._favorites).ShowDialog();
		}
		public void ShowNewFavoriteDialog()
		{
			FavoritesAddFavoriteDialog view = new FavoritesAddFavoriteDialog();
			view.InitializeView(this._favorites);
			if(view.ShowDialog() !=System.Windows.Forms.DialogResult.OK) return;
			//
			this.DisplayFeed(view.Favorite);
		}
		public void ShowEditFavoriteDialog(OpmlOutlineFavorite favorite)
		{
			FavoritesAddFavoriteDialog view = new FavoritesAddFavoriteDialog();			
			view.InitializeView(this._favorites);
			view.Favorite = favorite;
			view.ShowDialog();
		}
		[Category("Data"), Description("")]
		public IEnvironmentWindow EnvironmentWindow
		{
			get
			{
				return _environmentWindow;
			}
			set
			{
				_environmentWindow = value;
			}
		}
		[Browsable(false)]
		public RssFeedManager Manager
		{
			get
			{
				return this._manager;
			}
		}		
		[Category("Data"), Description("")]
		public IRssFeedDataAdaptorRssView Browser
		{
			set
			{
				_browserControl = value;
			}
			get
			{
				return _browserControl;
			}
		}
		[Category("Data"), Description("")]
		public IRssFeedDataAdaptorOpmlView Favorites
		{
			set
			{
				_favoritesControl = value;
						
			}
			get
			{
				return _favoritesControl;
			}
		}
		[Category("Data"), Description("")]
		public IRssFeedDataAdaptorOpmlView History
		{
			set
			{
				_historyControl = value;				
			}
			get
			{
				return _historyControl;
			}
		}
		#endregion

		#region private interface
		private void DisplayFeed(OpmlOutlineFavorite favorite)
		{
			System.Diagnostics.Debug.Assert(_browserControl!=null);
			//
			System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
			try
			{
				SetProgress(0,3);
				SetProgress(1,-1);
				SetStatusText("Retrieve " + favorite.XmlUrl);
				IRssChannel channel = this._manager.GetFeed(favorite);
				SetProgress(2,-1);
				_browserControl.Populate(favorite, channel);
				SetStatusText("complete...");
			}
			catch (System.Exception ex)
			{
				System.Diagnostics.Debug.WriteLine(ex.Message);
				SetStatusText(ex.Message);
			}
			finally
			{	
				SetProgress(3,-1);
				System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
			}
		}
		private void SetStatusText(string text)
		{
			if(this.EnvironmentWindow.Status==null) return;
			this.EnvironmentWindow.Status.SetStatusText(text);
		}
		private void SetProgress(int min,int max)
		{
			if(this.EnvironmentWindow.Progress==null) return;
			if(max!=-1)
			{
				this.EnvironmentWindow.Progress.Init(min,max);
			} 
			else
			{
				this.EnvironmentWindow.Progress.Value = min;
			}
		}
		#endregion

		#region events		
		private void OnFavoriteClick(object sender, OpmlFavoriteItemClickedEventArgs e)
		{
			this.OnFavoriteClick(e);
		}
		protected virtual void OnFavoriteClick(OpmlFavoriteItemClickedEventArgs e)
		{
			DisplayFeed(e.Favorite);
		}
		#endregion

		#region Component Designer generated code
		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
				this._favorites.Save(_favoritePath);
			}
			base.Dispose( disposing );
		}


		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			components = new System.ComponentModel.Container();
		}
		#endregion

		#region ISupportInitialize Members

		public void BeginInit()
		{
			// TODO:  Add RssFeedUIManager.BeginInit implementation
		}

		public void EndInit()
		{
			if(DesignMode) return;
			//
			Uri uri = new Uri(_favoritePath);
			_favorites = new OpmlDocumentFavorites(uri);
			//
			this._manager = new RssFeedManager(System.Windows.Forms.Application.StartupPath, this._favorites);
			//
			if(_favoritesControl!=null)
			{	
				_favoritesControl.Populate(this._favorites);
				_favoritesControl.FavoriteClick += new OpmlFavoriteItemClickDelegate(OnFavoriteClick);
			}
			//
			if(_historyControl!=null)
			{
				_historyControl.Populate(this._manager.History);
				_historyControl.FavoriteClick += new OpmlFavoriteItemClickDelegate(OnFavoriteClick);
			}
		}

		#endregion
	}
	public delegate void OpmlFavoriteItemClickDelegate(object sender, OpmlFavoriteItemClickedEventArgs e);
	public class OpmlFavoriteItemClickedEventArgs : EventArgs
	{
		#region fields
		private OpmlOutlineFavorite _outline;
		#endregion

		#region constructors
		public OpmlFavoriteItemClickedEventArgs(OpmlOutlineFavorite outline)
		{
			_outline= outline;
		}
		#endregion

		#region public inteface
		public OpmlOutlineFavorite Favorite
		{
			get
			{
				return _outline;
			}
		}
		#endregion
	}
	/// <summary>Defines the interface to a opml view control.</summary>
	public interface IRssFeedDataAdaptorOpmlView
	{
		void Populate(OpmlDocumentFavorites document);
		event OpmlFavoriteItemClickDelegate FavoriteClick;

	}
	/// <summary>Defines the interface to a rss view control.</summary>
	public interface IRssFeedDataAdaptorRssView
	{
        void Populate(OpmlOutlineFavorite favorite, IRssChannel rssChannel);
	}
	/// <summary>Defines the interface to a add favorite view control.</summary>
	public interface IRssFeedDataAdaptorAddFavoriteView : System.Windows.Forms.IContainerControl
	{
		void InitializeView(OpmlDocumentFavorites favorites);
		OpmlOutlineFavorite Favorite { get; set;}
	}
	/// <summary>Defines the interface to a organize favorites view control.</summary>
	public interface IRssFeedDataAdaptorOrganizeFavoriteView
	{
		void InitializeView(OpmlDocumentFavorites favorites);
	}
}

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 GNU Lesser General Public License (LGPLv3)

Share

About the Author

Chris Richner
Software Developer (Senior) Zeit AG
Switzerland Switzerland
Biography
  • 1996 - 1998 PC Board PPL, HTML, DHTML, Javascript and ASP
  • 1999 - 2001 coding Centura against Sql Database (SqlBase,MSSQL,Oracle)
  • 2002 - 2004 C# Windows Forms
  • 2005 - 2006 C# ASP.NET, Windows Forms
  • 2006 - 2009 C#, WCF, WF, WPF
  • 2010 - 2012 C#, Dynamics CRM, Sharepoint, Silverlight
  • 2013 - now C#, WCF DS (OData), WF, WPF
Interests
  • family & friends
  • chilaxing ,)
  • coding
Follow on   Twitter   Google+   LinkedIn

| Advertise | Privacy | Mobile
Web01 | 2.8.141015.1 | Last Updated 20 Jan 2013
Article Copyright 2003 by Chris Richner
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid