|
//� 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.
A software developer for a medium sized company with a Microsoft product core development strategy.