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

RSS 2.0 Framework

, 19 Jan 2013
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 System.Drawing;
using System.Windows.Forms;

namespace Actions
{
	/// <summary>
	/// An ActionList is a list of Actions.
	/// </summary>
	[
		ToolboxBitmap(typeof(ActionList)),
		DefaultProperty("Actions"),
		ProvideProperty("Action", typeof(Component))
	]
	public class ActionList : System.ComponentModel.Component, IExtenderProvider
	{
		#region member variables
		private ActionCollection	_actions;
		private ImageList			_imageList;
		private	object				_tag;
		private	bool				_showTextOnToolBar = false;
		private	bool				_init = false;
		// As there is now way to ensure that the designer calls the SetAction method after the call to ActionList.AddRange method, 
		// we need to duplicate the list of assocations between actions and component already contained in the ActionCollection member. 
		// It's not really a problem, because it speeds up all operations based on iteration on the components.
		private Hashtable			_components = new Hashtable();
		internal System.Windows.Forms.ToolTip _toolTip;
		private System.ComponentModel.IContainer components;
		#endregion
		#region public interface
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="container"></param>
		public ActionList(System.ComponentModel.IContainer container)
		{
			container.Add(this);
			InitializeComponent();
			//
			Init();
		}
		/// <summary>
		/// Constructor
		/// </summary>
		public ActionList()
		{
			InitializeComponent();
			//
			Init();
		}
		/// <summary>
		/// The number of Actions in this ActionList
		/// </summary>
		[Browsable(false)]
		public int Count
		{
			get
			{
				return _actions.Count;
			}
			set
			{
			}
		}
		/// <summary>
		/// The collection of Actions that makes up this ActionList
		/// </summary>
		[
			DesignerSerializationVisibility(DesignerSerializationVisibility.Content), 
			Category("Behavior"), 
			Description("The collection of Actions that makes up this ActionList")
		]
		public ActionCollection Actions
		{
			get
			{
				return _actions;
			}
			set
			{
				_actions = value;
			}
		}
		/// <summary>
		/// The ImageList from which this ActionList will get all of the action images.
		/// </summary>
		[
		Category("Behavior"), 
		Description("The ImageList from which this ActionList will get all of the action images.")
		]
		public ImageList ImageList
		{
			get
			{
				return _imageList;
			}
			set
			{
				_imageList = value;
				foreach(Action a in Actions)
				{
					a.ImageList = _imageList;
				}
			}
		}
		/// <summary>
		/// User defined data associated with this ActionList.
		/// </summary>
		[
		Category("Data"), 
		Description("User defined data associated with this ActionList.")
		]
		public object Tag
		{
			get
			{
				return _tag;
			}
			set 
			{
				_tag = value;
			}
		}
		/// <summary>
		/// User defined data associated with this ActionList.
		/// </summary>
		[
		Category("Behavior"), 
		Description("User defined data associated with this ActionList.")
		]
		public bool ShowTextOnToolBar
		{
			get
			{
				return _showTextOnToolBar;
			}
			set 
			{
				_showTextOnToolBar = value;
				foreach(Action a in Actions)
				{
					a.ShowTextOnToolBar = value;
				}
			}
		}
		/// <summary>
		/// Indicates whether or not labels of ToolBar Buttons are displayed or not.
		/// </summary>
		[
		ExtenderProvidedProperty(),
		TypeConverter(typeof(ActionConverter)),
		Description("Indicates whether or not labels of ToolBar Buttons are displayed or not."),
		Category("Behavior")
		]
		public Action GetAction(Component comp)
		{
			Debug.Assert(comp != null);
			Action res = (Action)_components[comp];
			if (res == null)
			{
				return Actions.Null;
			}
			return res;
		}
		/// <summary>
		/// The set method of the extended property Action
		/// </summary>
		[ExtenderProvidedProperty()]
		public void SetAction(Component comp, Action value) 
		{
			Debug.Assert(comp != null && value != null);
			Action res = (Action)_components[comp];

			if (res != null)
			{
				if (value == res)
				{
					return;
				}
				res.SetComponent(comp, false);
				_components.Remove(comp);
			}

			if (value != Actions.Null)
			{
				value._owner = this;
				value.SetComponent(comp, true);
				_components.Add(comp, value);
			}
		}
		/// <summary>
		/// We need only to serialize Components wich have associated to an Action
		/// </summary>
		public bool ShouldSerializeAction(object o) 
		{
			Debug.Assert(o != null);
			foreach (Action a in Actions)
			{
				if (a.HandleComponent((Component)o))
				{
					return true;
				}
			}
			return false;
		}
		/// <summary>
		/// Specifies whether this object can provide its extender properties to the specified object.
		/// </summary>
		/// <param name="target">The Object to receive the extender properties</param>
		public bool CanExtend(Object target) 
		{
			return (target is Component) && !(target is ActionList) && !(target is Action);
		}
		#endregion
		#region Component Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			this._toolTip = new System.Windows.Forms.ToolTip(this.components);

		}
		#endregion
		#region  internal
		/// <summary>
		/// Common code for initialising the instance
		/// </summary>
		private void Init()
		{
			_actions = new ActionCollection(this);
			if (!DesignMode)
			{
				Application.Idle += new EventHandler(OnIdle);
			}
		}
		/// <summary>
		/// Occurs when the application is idle so that the action list can update the actions in the list.
		/// </summary>
		/// <param name="sender">The source of the event</param>
		/// <param name="e">An EventArgs that contains the event data</param>
		private void OnIdle(Object sender, EventArgs e)
		{
			// the designer don't put necesseraly the initialisation code in the right order
			// Especially, toolbarbuttons can be assigned to their corresponding toolbar after their corresponding action has been assigned
			// So in this case, we are not able to add an event handler to toolbarbutton.Parent.click

			// so if it was not done, we do the job here
			if (!_init)
			{
				foreach(Action a in Actions)
				{
					a.FinishInit();
				}
				_init = true;
			}

			// the real work begins here
			foreach(Action a in Actions)
			{
				a.OnUpdate(this, e);
			}
		}
		/// <summary>
		/// Cleans the action list when an associated component is destroyed
		/// </summary>
		internal void OnComponentDisposed(Object sender, EventArgs e)
		{
			Component comp = (Component)sender;
			Debug.Assert(comp != null);
			Action a = (Action)_components[comp];

			if (a != null)
			{
				a.SetComponent(comp, false);
				_components.Remove(comp);
			}
		}
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (!DesignMode)
				{
					Application.Idle -= new EventHandler(OnIdle);
				}
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
		#endregion
	}
}

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
Web04 | 2.8.140922.1 | Last Updated 20 Jan 2013
Article Copyright 2003 by Chris Richner
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid