using System; using System.Collections; namespace DevComponents.DotNetBar { /// /// Collection of DocumentBaseContainer objects. /// public class DocumentBaseContainerCollection:CollectionBase { #region Private Variables and Events public event EventHandler DocumentRemoved; public event EventHandler DocumentAdded; private DocumentBaseContainer m_Owner=null; #endregion #region Internal Implementation public DocumentBaseContainerCollection() { //m_Owner=owner; } /// /// Adds new object to the collection. /// /// Object to add. /// Index of newly added object. public int Add(DocumentBaseContainer tab) { return List.Add(tab); } /// /// Adds new objects to the collection. /// /// Array of documents to add. public void AddRange(DocumentBaseContainer[] documents) { foreach(DocumentBaseContainer doc in documents) List.Add(doc); } /// /// Returns reference to the object in collection based on it's index. /// public DocumentBaseContainer this[int index] { get {return (DocumentBaseContainer)(List[index]);} set {List[index] = value;} } /// /// Inserts new object into the collection. /// /// Position of the object. /// Object to insert. public void Insert(int index, DocumentBaseContainer 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(DocumentBaseContainer 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(DocumentBaseContainer value) { return List.Contains(value); } /// /// Removes specified object from the collection. /// /// public void Remove(DocumentBaseContainer value) { List.Remove(value); } protected override void OnRemoveComplete(int index,object value) { base.OnRemoveComplete(index,value); DocumentBaseContainer item=value as DocumentBaseContainer; item.SetParent(null); if(DocumentRemoved!=null) DocumentRemoved(item,new EventArgs()); } protected override void OnInsertComplete(int index,object value) { base.OnInsertComplete(index,value); DocumentBaseContainer item=value as DocumentBaseContainer; if(m_Owner!=null) item.SetParent(m_Owner); if(DocumentAdded!=null) DocumentAdded(item,new EventArgs()); } /// /// Copies collection into the specified array. /// /// Array to copy collection to. /// Starting index. public void CopyTo(DocumentBaseContainer[] array, int index) { List.CopyTo(array, index); } /// /// Copies contained items to the DocumentBaseContainer array. /// /// Array to copy to. internal void CopyTo(DocumentBaseContainer[] array) { List.CopyTo(array,0); } internal DocumentBaseContainer Owner { get {return m_Owner;} set {m_Owner=value;} } protected override void OnClear() { //m_Owner.OnTabsCleared(); base.OnClear(); } public int VisibleCount { get { int count = 0; foreach (DocumentBaseContainer item in this.List) { if (item.Visible) count++; } return count; } } #endregion } }