Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Documents / TableRowGroupCollection.cs / 1305600 / TableRowGroupCollection.cs
//---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // // File: TableRowGorupCollection.cs // // Description: Collection of TableRowGroup objects. // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using MS.Internal.Documents; namespace System.Windows.Documents { ////// A TableRowGroupCollection is an ordered collection of TableRowGroups. /// ////// TableRowGroupCollection provides public access for TableRowGroups /// reading and manipulating. /// public sealed class TableRowGroupCollection : IList, IList { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors internal TableRowGroupCollection(Table owner) { _rowGroupCollectionInternal = new TableTextElementCollectionInternal (owner); } #endregion Constructors //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- #region Public Methods ///
/// ////// /// ////// /// ////// /// ////// /// public void CopyTo(Array array, int index) { _rowGroupCollectionInternal.CopyTo(array, index); } /// /// Strongly typed version of ICollection.CopyTo. /// ////// ////// /// ////// /// ////// /// /// /// public void CopyTo(TableRowGroup[] array, int index) { _rowGroupCollectionInternal.CopyTo(array, index); } ////// /// IEnumerator IEnumerable.GetEnumerator() { return _rowGroupCollectionInternal.GetEnumerator(); } ////// /// IEnumerator/// IEnumerable .GetEnumerator() { return ((IEnumerable )_rowGroupCollectionInternal).GetEnumerator(); } /// /// Appends a TableRowGroup to the end of the TableRowGroupCollection. /// /// The TableRowGroup to be added to the end of the TableRowGroupCollection. ///The TableRowGroupCollection index at which the TableRowGroup has been added. ///Adding a null is prohibited. ////// If the ///item value is null. ////// If the new child already has a parent. /// public void Add(TableRowGroup item) { _rowGroupCollectionInternal.Add(item); } ////// Removes all elements from the TableRowGroupCollection. /// ////// Count is set to zero. Capacity remains unchanged. /// To reset the capacity of the TableRowGroupCollection, call TrimToSize /// or set the Capacity property directly. /// public void Clear() { _rowGroupCollectionInternal.Clear(); } ////// Determines whether a TableRowGroup is in the TableRowGroupCollection. /// /// The TableRowGroup to locate in the TableRowGroupCollection. /// The value can be a null reference. ///true if TableRowGroup is found in the TableRowGroupCollection; /// otherwise, false. public bool Contains(TableRowGroup item) { return _rowGroupCollectionInternal.Contains(item); } ////// Returns the zero-based index of the TableRowGroup. If the TableRowGroup is not /// in the TableRowGroupCollection, -1 is returned. /// /// The TableRowGroup to locate in the TableRowGroupCollection. public int IndexOf(TableRowGroup item) { return _rowGroupCollectionInternal.IndexOf(item); } ////// Inserts a TableRowGroup into the TableRowGroupCollection at the specified index. /// /// The zero-based index at which value should be inserted. /// The TableRowGroup to insert. ////// ///index c> is less than zero. /// -or- ///index is greater than Count. ////// If the ///item value is null. ////// If Count already equals Capacity, the capacity of the /// TableRowGroupCollection is increased before the new TableRowGroup is inserted. /// /// If index is equal to Count, TableRowGroup is added to the /// end of TableRowGroupCollection. /// /// The TableRowGroups that follow the insertion point move down to /// accommodate the new TableRowGroup. The indexes of the TableRowGroups that are /// moved are also updated. /// public void Insert(int index, TableRowGroup item) { _rowGroupCollectionInternal.Insert(index, item); } ////// Removes the specified TableRowGroup from the TableRowGroupCollection. /// /// The TableRowGroup to remove from the TableRowGroupCollection. ////// If the ///item value is null. ////// If the specified TableRowGroup is not in this collection. /// ////// The TableRowGroups that follow the removed TableRowGroup move up to occupy /// the vacated spot. The indices of the TableRowGroups that are moved /// also updated. /// public bool Remove(TableRowGroup item) { return _rowGroupCollectionInternal.Remove(item); } ////// Removes the TableRowGroup at the specified index. /// /// The zero-based index of the TableRowGroup to remove. ////// ///index is less than zero /// - or - ///index is equal or greater than count. ////// The TableRowGroups that follow the removed TableRowGroup move up to occupy /// the vacated spot. The indices of the TableRowGroups that are moved /// also updated. /// public void RemoveAt(int index) { _rowGroupCollectionInternal.RemoveAt(index); } ////// Removes a range of TableRowGroups from the TableRowGroupCollection. /// /// The zero-based index of the range /// of TableRowGroups to remove /// The number of TableRowGroups to remove. ////// ///index is less than zero. /// -or- ///count is less than zero. ////// ///index andcount do not denote a valid range of TableRowGroups in the TableRowGroupCollection. ////// The TableRowGroups that follow the removed TableRowGroups move up to occupy /// the vacated spot. The indices of the TableRowGroups that are moved are /// also updated. /// public void RemoveRange(int index, int count) { _rowGroupCollectionInternal.RemoveRange(index, count); } ////// Sets the capacity to the actual number of elements in the TableRowGroupCollection. /// ////// This method can be used to minimize a TableRowGroupCollection's memory overhead /// if no new elements will be added to the collection. /// /// To completely clear all elements in a TableRowGroupCollection, call the Clear method /// before calling TrimToSize. /// public void TrimToSize() { _rowGroupCollectionInternal.TrimToSize(); } #endregion Public Methods //-------------------------------------------------------------------- // // IList Members // //-------------------------------------------------------------------- #region IList Members int IList.Add(object value) { return ((IList)_rowGroupCollectionInternal).Add(value); } void IList.Clear() { this.Clear(); } bool IList.Contains(object value) { return ((IList)_rowGroupCollectionInternal).Contains(value); } int IList.IndexOf(object value) { return ((IList)_rowGroupCollectionInternal).IndexOf(value); } void IList.Insert(int index, object value) { ((IList)_rowGroupCollectionInternal).Insert(index, value); } bool IList.IsFixedSize { get { return ((IList)_rowGroupCollectionInternal).IsFixedSize; } } bool IList.IsReadOnly { get { return ((IList)_rowGroupCollectionInternal).IsReadOnly; } } void IList.Remove(object value) { ((IList)_rowGroupCollectionInternal).Remove(value); } void IList.RemoveAt(int index) { ((IList)_rowGroupCollectionInternal).RemoveAt(index); } object IList.this[int index] { get { return ((IList)_rowGroupCollectionInternal)[index]; } set { ((IList)_rowGroupCollectionInternal)[index] = value; } } #endregion IList Members //----------------------------------------------------- // // Public Properties // //------------------------------------------------------ #region Public Properties ////// public int Count { get { return _rowGroupCollectionInternal.Count; } } ////// /// public bool IsReadOnly { get { return _rowGroupCollectionInternal.IsReadOnly; } } ////// /// public bool IsSynchronized { get { return _rowGroupCollectionInternal.IsSynchronized; } } ////// /// ////// public object SyncRoot { get { return _rowGroupCollectionInternal.SyncRoot; } } ////// /// Gets or sets the number of elements that the TableRowGroupCollection can contain. /// ////// The number of elements that the TableRowGroupCollection can contain. /// ////// Capacity is the number of elements that the TableRowGroupCollection is capable of storing. /// Count is the number of Visuals that are actually in the TableRowGroupCollection. /// /// Capacity is always greater than or equal to Count. If Count exceeds /// Capacity while adding elements, the capacity of the TableRowGroupCollection is increased. /// /// By default the capacity is 8. /// ////// Capacity is set to a value that is less than Count. /// ///public int Capacity { get { return _rowGroupCollectionInternal.Capacity; } set { _rowGroupCollectionInternal.Capacity = value; } } /// /// Indexer for the TableRowGroupCollection. Gets the TableRowGroup stored at the /// zero-based index of the TableRowGroupCollection. /// ///This property provides the ability to access a specific TableRowGroup in the /// TableRowGroupCollection by using the following systax: ///TableRowGroup myTableRowGroup = myTableRowGroupCollection[index] . ////// public TableRowGroup this[int index] { get { return _rowGroupCollectionInternal[index]; } set { _rowGroupCollectionInternal[index] = value; } } #endregion Public Properties #region Internal Methods ///index is less than zero -or-index is equal to or greater than Count. ////// Performs the actual work of adding the item into the array, and notifying it when it is connected /// internal void InternalAdd(TableRowGroup item) { _rowGroupCollectionInternal.InternalAdd(item); } ////// Performs the actual work of notifying item it is leaving the array, and disconnecting it. /// internal void InternalRemove(TableRowGroup item) { _rowGroupCollectionInternal.InternalRemove(item); } #endregion Internal Methods //----------------------------------------------------- // // Private Methods // //----------------------------------------------------- #region Private Methods ////// Ensures that the capacity of this list is at least the given minimum /// value. If the currect capacity of the list is less than min, the /// capacity is increased to min. /// private void EnsureCapacity(int min) { _rowGroupCollectionInternal.EnsureCapacity(min); } ////// Sets the specified TableRowGroup at the specified index; /// Connects the item to the model tree; /// Notifies the TableRowGroup about the event. /// ////// If the new item has already a parent or if the slot at the specified index is not null. /// ////// Note that the function requires that _item[index] == null and /// it also requires that the passed in item is not included into another TableRowGroupCollection. /// private void PrivateConnectChild(int index, TableRowGroup item) { _rowGroupCollectionInternal.PrivateConnectChild(index, item); } ////// Removes specified TableRowGroup from the TableRowGroupCollection. /// /// TableRowGroup to remove. private void PrivateDisconnectChild(TableRowGroup item) { _rowGroupCollectionInternal.PrivateDisconnectChild(item); } // helper method: return true if the item belongs to the collection's owner private bool BelongsToOwner(TableRowGroup item) { return _rowGroupCollectionInternal.BelongsToOwner(item); } // Helper method - Searches the children collection for the index an item currently exists at - // NOTE - ITEM MUST BE IN TEXT TREE WHEN THIS IS CALLED. private int FindInsertionIndex(TableRowGroup item) { return _rowGroupCollectionInternal.FindInsertionIndex(item); } #endregion Private Methods //----------------------------------------------------- // // Private Properties // //------------------------------------------------------ #region Private Properties ////// PrivateCapacity sets/gets the Capacity of the collection. /// private int PrivateCapacity { get { return _rowGroupCollectionInternal.PrivateCapacity; } set { _rowGroupCollectionInternal.PrivateCapacity = value; } } #endregion Private Properties private TableTextElementCollectionInternal