using System;
using System.Collections;
namespace DevComponents.Tree
{
///
/// Represents collection for Node objects.
///
public class ElementStyleCollection:CollectionBase
{
#region Private Variables
private TreeGX m_TreeControl=null;
//private Hashtable m_InnerHashtable=new Hashtable();
#endregion
#region Internal Implementation
/// Creates new instance of the object.
public ElementStyleCollection()
{
}
internal TreeGX TreeControl
{
get {return m_TreeControl;}
set {m_TreeControl=value;}
}
///
/// Adds new object to the collection.
///
/// Object to add.
/// Index of newly added object.
public int Add(ElementStyle style)
{
return List.Add(style);
}
///
/// Returns reference to the object in collection based on it's index.
///
public ElementStyle this[int index]
{
get {return (ElementStyle)(List[index]);}
set {List[index] = value;}
}
///
/// Returns reference to the object in collection based on it's name.
///
public ElementStyle this[string name]
{
get
{
foreach(ElementStyle style in this.List)
{
if(style.Name==name)
return style;
}
return null;
}
}
///
/// Inserts new object into the collection.
///
/// Position of the object.
/// Object to insert.
public void Insert(int index, ElementStyle value)
{
List.Insert(index, value);
}
///
/// Returns index of the object inside of the collection.
///
/// Reference to the object.
/// Index of the object.
public int IndexOf(ElementStyle value)
{
return List.IndexOf(value);
}
///
/// Returns whether collection contains specified object.
///
/// Object to look for.
/// true if object is part of the collection, otherwise false.
public bool Contains(ElementStyle value)
{
return List.Contains(value);
}
///
/// Removes specified object from the collection.
///
///
public void Remove(ElementStyle value)
{
List.Remove(value);
}
protected override void OnRemoveComplete(int index,object value)
{
base.OnRemoveComplete(index,value);
ElementStyle style=value as ElementStyle;
style.Parent=null;
//m_InnerHashtable.Remove(style.Name);
}
protected override void OnInsertComplete(int index,object value)
{
base.OnInsertComplete(index,value);
ElementStyle style=value as ElementStyle;
if(style.Parent!=null && style.Parent!=this)
style.Parent.Remove(style);
style.Parent=this;
//m_InnerHashtable.Add(style.Name,style);
}
///
/// Copies collection into the specified array.
///
/// Array to copy collection to.
/// Starting index.
public void CopyTo(ElementStyle[] array, int index)
{
List.CopyTo(array, index);
}
///
/// Copies contained items to the Node array.
///
/// Array to copy to.
internal void CopyTo(ElementStyle[] array)
{
List.CopyTo(array,0);
}
protected override void OnClear()
{
base.OnClear();
}
#endregion
}
#region ElementStyleCollectionEditor
///
/// Support for ElementStyle design-time editor.
///
public class ElementStyleCollectionEditor:System.ComponentModel.Design.CollectionEditor
{
/// Creates new instance of the object.
public ElementStyleCollectionEditor(Type type):base(type)
{
}
protected override Type CreateCollectionItemType()
{
return typeof(ElementStyle);
}
protected override Type[] CreateNewItemTypes()
{
return new Type[] {typeof(ElementStyle)};
}
protected override object CreateInstance(Type itemType)
{
object item=base.CreateInstance(itemType);
return item;
}
}
#endregion
}