Click here to Skip to main content
15,881,882 members
Articles / Web Development / IIS

OverLibWrapper -- C# wrapper of the overLIB DHTML popup JavaScript library

Rate me:
Please Sign up or sign in to vote.
4.67/5 (12 votes)
15 Feb 2005CPOL12 min read 114.4K   1.1K   53  
An article on the use of the OverlibPageControl and OverlibPopupAnchor for extended manipulation of the overLIB popup JavaScript library.
//� 2005 Thaddaeus Parker thaddparker(at)usa(dot)net
//This code is free to use and modify as long as this statement is left intact.
//All other copyrights are held by their respective owners
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Web.UI;
using System.Drawing.Design;
using System.ComponentModel.Design.Serialization;

namespace OverLibWrapper.Collections
{
	/// <summary>
	/// OverlibPopupCollection holds a strongly typed collection of <see cref="OverlibPopup"/>s
	/// </summary>
	[Editor(typeof(CollectionEditor),typeof(UITypeEditor))]
	[TypeConverter(typeof(CollectionConverter))]
	public class OverlibPopupCollection : CollectionWithEvents
	{
		/// <summary>
		/// Creates a new <see cref="OverlibPopupCollection"/> instance.
		/// </summary>
		public OverlibPopupCollection():base(){}
		/// <summary>
		/// Creates a new <see cref="OverlibPopupCollection"/> instance.
		/// </summary>
		/// <param name="ic">Ic.</param>
		public OverlibPopupCollection(ICollection ic){
			base.InnerList.AddRange(ic);
		}
		/// <summary>
		/// Overlibs the collection.
		/// </summary>
		/// <returns></returns>
		public ICollection OverlibCollection(){
			return base.InnerList;
		}

		/// <summary>
		/// Adds the specified value.
		/// </summary>
		/// <param name="value">Value.</param>
		/// <returns>An integer index of the added OverlibPopup</returns>
		public int Add(OverLibWrapper.OverlibPopup value)
		{
			return base.List.Add(value as object);
		}

		/// <summary>
		/// Removes the specified value.
		/// </summary>
		/// <param name="value">Value.</param>
		public void Remove(OverLibWrapper.OverlibPopup value)
		{
			base.List.Remove(value as object);
		}

		/// <summary>
		/// Inserts the OverlibPopup at the specified index.
		/// </summary>
		/// <param name="index">Index.</param>
		/// <param name="value">Value.</param>
		public void Insert(int index, OverLibWrapper.OverlibPopup value)
		{
			base.List.Insert(index, value as object);
		}

		/// <summary>
		/// Containses the specified value.
		/// </summary>
		/// <param name="value">Value.</param>
		/// <returns><c>true</c> if the OverlibPopup is contained in the collection; otherwise <c>false</c></returns>
		public bool Contains(OverLibWrapper.OverlibPopup value)
		{
			return base.List.Contains(value as object);
		}

		/// <summary>
		/// Gets the <see cref="OverlibPopup"/> at the specified index.
		/// </summary>
		/// <value>An OverlibPopup at the particular index input</value>
		public OverLibWrapper.OverlibPopup this[int index]
		{
			get { return (base.List[index] as OverLibWrapper.OverlibPopup); }
		}
	}

	/// <summary>
	/// OverlibPopupCollectionConverter converts the <see cref="OverlibPopupCollection"/> to and from a string
	/// </summary>
	public class OverlibPopupCollectionConverter:CollectionConverter{
		/// <summary>
		/// Determines whether this instance [can convert from] the specified context.
		/// </summary>
		/// <param name="context">Context.</param>
		/// <param name="sourceType">Source type.</param>
		/// <returns>
		/// 	<c>true</c> if this instance [can convert from] the specified context; otherwise, <c>false</c>.
		/// </returns>
		public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
			if(sourceType == typeof(string)){
				return true;
			}
			return base.CanConvertFrom (context, sourceType);
		}
		/// <summary>
		/// Converts to another representation.
		/// </summary>
		/// <param name="context">Context.</param>
		/// <param name="culture">Culture.</param>
		/// <param name="value">Value.</param>
		/// <param name="destinationType">Destination type.</param>
		/// <returns>An object that represents the the conversion to </returns>
		public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) {
			if(destinationType == typeof(InstanceDescriptor)) {
				System.Reflection.ConstructorInfo constructor;
				constructor = typeof(OverlibPopupCollection).GetConstructor(new Type[]{typeof(ICollection)});
				OverlibPopupCollection otc = (OverlibPopupCollection)value;

				return new InstanceDescriptor(constructor,
					new Object[] {otc.OverlibCollection()});
			}
			return base.ConvertTo (context, culture, value, destinationType);
		}

	}
}

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
Technical Lead Avanade, Inc
United States United States
A software developer for a medium sized company with a Microsoft product core development strategy.

Comments and Discussions