using System; using System.Collections; using System.ComponentModel; namespace DevComponents.Tree { /// /// Represents collection for ColumnHeader objects. /// public class ColumnHeaderCollection:CollectionBase { #region Private Variables private Node m_ParentNode=null; #endregion #region Internal Implementation /// /// Default constructor. /// public ColumnHeaderCollection() { } /// /// Gets or sets the node this collection is associated with. /// [Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Node ParentNode { get {return m_ParentNode;} } /// /// Sets the node collection belongs to. /// /// ColumnHeader that is parent of this collection. internal void SetParentNode(Node parent) { m_ParentNode=parent; } /// /// Adds new object to the collection. /// /// Object to add. /// Index of newly added object. public int Add(ColumnHeader ch) { return List.Add(ch); } /// /// Returns reference to the object in collection based on it's index. /// public ColumnHeader this[int index] { get {return (ColumnHeader)(List[index]);} set {List[index] = value;} } /// /// Inserts new object into the collection. /// /// Position of the object. /// Object to insert. public void Insert(int index, ColumnHeader 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(ColumnHeader 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(ColumnHeader value) { return List.Contains(value); } /// /// Removes specified object from the collection. /// /// public void Remove(ColumnHeader 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(ColumnHeader[] array, int index) { List.CopyTo(array, index); } /// /// Copies contained items to the ColumnHeader array. /// /// Array to copy to. internal void CopyTo(ColumnHeader[] array) { List.CopyTo(array,0); } protected override void OnClear() { base.OnClear(); } #endregion } #region ColumnHeaderCollectionEditor /// /// Support for ColumnHeader tabs design-time editor. /// public class ColumnHeaderCollectionEditor:System.ComponentModel.Design.CollectionEditor { /// Creates new instance of the class /// Type to initialize editor with. public ColumnHeaderCollectionEditor(Type type):base(type) { } protected override Type CreateCollectionItemType() { return typeof(ColumnHeader); } protected override Type[] CreateNewItemTypes() { return new Type[] {typeof(ColumnHeader)}; } protected override object CreateInstance(Type itemType) { object item=base.CreateInstance(itemType); if(item is ColumnHeader) { ColumnHeader ch=item as ColumnHeader; ch.Text=ch.Name; } return item; } } #endregion }