using System;
using System.Collections;
using System.ComponentModel;
namespace DevComponents.Tree
{
///
/// Represents collection for HeaderDefinition objects.
///
public class HeadersCollection:CollectionBase
{
#region Private Variables
private TreeGX m_Parent=null;
#endregion
#region Internal Implementation
///
/// Gets or sets the node this collection is associated with.
///
[Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public TreeGX Parent
{
get {return m_Parent;}
}
///
/// Sets the node collection belongs to.
///
/// HeaderDefinition that is parent of this collection.
internal void SetParent(TreeGX parent)
{
m_Parent=parent;
}
///
/// Adds new object to the collection.
///
/// Object to add.
/// Index of newly added object.
public int Add(HeaderDefinition ch)
{
return List.Add(ch);
}
///
/// Returns reference to the object in collection based on it's index.
///
public HeaderDefinition this[int index]
{
get {return (HeaderDefinition)(List[index]);}
set {List[index] = value;}
}
///
/// Inserts new object into the collection.
///
/// Position of the object.
/// Object to insert.
public void Insert(int index, HeaderDefinition 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(HeaderDefinition 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(HeaderDefinition value)
{
return List.Contains(value);
}
///
/// Removes specified object from the collection.
///
///
public void Remove(HeaderDefinition value)
{
List.Remove(value);
}
protected override void OnRemoveComplete(int index,object value)
{
base.OnRemoveComplete(index,value);
}
protected override void OnInsertComplete(int index,object value)
{
base.OnInsertComplete(index,value);
}
///
/// Copies collection into the specified array.
///
/// Array to copy collection to.
/// Starting index.
public void CopyTo(HeaderDefinition[] array, int index)
{
List.CopyTo(array, index);
}
///
/// Copies contained items to the HeaderDefinition array.
///
/// Array to copy to.
internal void CopyTo(HeaderDefinition[] array)
{
List.CopyTo(array,0);
}
protected override void OnClear()
{
base.OnClear();
}
public HeaderDefinition GetByName(string name)
{
foreach(HeaderDefinition d in this.List)
{
if(d.Name==name)
return d;
}
return null;
}
#endregion
}
}