using System; using System.Text; using System.Collections; #if AdvTree namespace DevComponents.Tree.TextMarkup #elif DOTNETBAR namespace DevComponents.DotNetBar.TextMarkup #elif SUPERGRID namespace DevComponents.SuperGrid.TextMarkup #endif { internal class MarkupElementCollection : CollectionBase { #region Private Variables private MarkupElement m_Parent = null; #endregion #region Internal Implementation /// Creates new instance of the class. public MarkupElementCollection(MarkupElement parent) { m_Parent = parent; } /// /// Gets or sets the collection parent element. /// public MarkupElement Parent { get { return m_Parent; } set { m_Parent = value; } } /// /// Adds new object to the collection. /// /// Object to add. /// Index of newly added object. public int Add(MarkupElement MarkupElement) { return List.Add(MarkupElement); } /// /// Returns reference to the object in collection based on it's index. /// public MarkupElement this[int index] { get {return (MarkupElement)(List[index]);} set {List[index] = value;} } /// /// Inserts new object into the collection. /// /// Position of the object. /// Object to insert. public void Insert(int index, MarkupElement 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(MarkupElement 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(MarkupElement value) { return List.Contains(value); } /// /// Removes specified object from the collection. /// /// public void Remove(MarkupElement value) { List.Remove(value); } protected override void OnRemoveComplete(int index,object value) { base.OnRemoveComplete(index,value); MarkupElement me=value as MarkupElement; if (m_Parent != null) { me.SetParent(null); m_Parent.IsSizeValid = false; } } protected override void OnInsertComplete(int index,object value) { base.OnInsertComplete(index,value); MarkupElement me=value as MarkupElement; if (m_Parent != null) { me.SetParent(m_Parent); m_Parent.IsSizeValid = false; } } /// /// Copies collection into the specified array. /// /// Array to copy collection to. /// Starting index. public void CopyTo(MarkupElement[] array, int index) { List.CopyTo(array, index); } /// /// Copies contained items to the MarkupElement array. /// /// Array to copy to. internal void CopyTo(MarkupElement[] array) { List.CopyTo(array,0); } protected override void OnClear() { base.OnClear(); } #endregion } }