using System;
using System.Text;
using System.Collections;
namespace DevComponents.DotNetBar.Rendering
{
    /// 
    /// Represents typed collection of Office2007ButtonItemColorTable type.
    /// 
    public class Office2007ButtonItemColorTableCollection : CollectionBase
    {
        #region Internal Implementation
        private Hashtable m_Keys = new Hashtable();
        /// Creates new instance of the class.
        public Office2007ButtonItemColorTableCollection() { }
		/// 
		/// Adds new object to the collection.
		/// 
		/// Object to add.
		/// Index of newly added object.
		public int Add(Office2007ButtonItemColorTable colorTable)
		{
            return List.Add(colorTable);
		}
		/// 
		/// Returns reference to the object in collection based on it's index.
		/// 
		public Office2007ButtonItemColorTable this[int index]
		{
			get {return (Office2007ButtonItemColorTable)(List[index]);}
			set {List[index] = value;}
		}
        /// 
        /// Returns reference to the object in collection based on it's index.
        /// 
        public Office2007ButtonItemColorTable this[string name]
        {
            get
            {
                return m_Keys[name] as Office2007ButtonItemColorTable;
                //foreach (Office2007ButtonItemColorTable ct in this.List)
                //{
                //    if (ct.Name == name)
                //        return ct;
                //}
                //return null;
            }
        }
		/// 
		/// Inserts new object into the collection.
		/// 
		/// Position of the object.
		/// Object to insert.
		public void Insert(int index, Office2007ButtonItemColorTable 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(Office2007ButtonItemColorTable 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(Office2007ButtonItemColorTable value) 
		{
			return List.Contains(value);
		}
        /// 
        /// Returns whether collection contains object with specified name.
        /// 
        /// Name of the object to look for
        /// true if object with given name is part of the collection otherwise false
        public bool Contains(string name)
        {
            return m_Keys.ContainsKey(name);
            //foreach (Office2007ButtonItemColorTable ct in this.List)
            //{
            //    if (ct.Name == name)
            //        return true;
            //}
            //return false;
        }
		/// 
		/// Removes specified object from the collection.
		/// 
		/// 
		public void Remove(Office2007ButtonItemColorTable value) 
		{
			List.Remove(value);
		}
        protected override void OnRemoveComplete(int index, object value)
        {
            base.OnRemoveComplete(index, value);
            Office2007ButtonItemColorTable me = value as Office2007ButtonItemColorTable;
            m_Keys.Remove(me.Name);
        }
        protected override void OnInsertComplete(int index, object value)
        {
            base.OnInsertComplete(index, value);
            Office2007ButtonItemColorTable me = value as Office2007ButtonItemColorTable;
            m_Keys.Add(me.Name, me);
        }
		/// 
		/// Copies collection into the specified array.
		/// 
		/// Array to copy collection to.
		/// Starting index.
		public void CopyTo(Office2007ButtonItemColorTable[] array, int index) 
		{
			List.CopyTo(array, index);
		}
		/// 
		/// Copies contained items to the Office2007ButtonItemColorTable array.
		/// 
		/// Array to copy to.
		internal void CopyTo(Office2007ButtonItemColorTable[] array)
		{
			List.CopyTo(array,0);
		}
		protected override void OnClear()
		{
            m_Keys.Clear();
			base.OnClear();
		}
		#endregion
    }
}