⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 accordionpanecollection.cs

📁 AJAX 应用 实现页面的无刷新
💻 CS
📖 第 1 页 / 共 2 页
字号:

        /// <summary>
        /// Remove an AccordionPane from the collection
        /// </summary>
        /// <param name="item">AccordionPane</param>
        /// <returns>True if we were able to remove, false otherwise</returns>
        public void Remove(AccordionPane item)
        {
            _parent.Controls.Remove(item);
            _version++;
        }

        /// <summary>
        /// Remove the AccordionPane at the given index from the collection
        /// </summary>
        /// <param name="index">Index of the AccordionPane to remove</param>
        public void RemoveAt(int index)
        {
            _parent.Controls.RemoveAt(ToRawIndex(index));
            _version++;
        }

        /// <summary>
        /// Add an AccordionPane to the list
        /// </summary>
        /// <param name="value">AccordionPane</param>
        /// <returns>Always returns 0</returns>
        int IList.Add(object value)
        {
            Add(value as AccordionPane);
            return 0;
        }

        /// <summary>
        /// Check if the list contains the AccordionPane
        /// </summary>
        /// <param name="value">AccordionPane</param>
        /// <returns>True if it contains the pane, false otherwise</returns>
        bool IList.Contains(object value)
        {
            return Contains(value as AccordionPane);
        }

        /// <summary>
        /// Get the inded of the provided AccordionPane
        /// </summary>
        /// <param name="value">AccordionPane</param>
        /// <returns>Index of the AccordionPane</returns>
        int IList.IndexOf(object value)
        {
            return IndexOf(value as AccordionPane);
        }

        /// <summary>
        /// Insert an AccordionPane at the given index
        /// </summary>
        /// <param name="index">Index</param>
        /// <param name="value">AccordionPane</param>
        void IList.Insert(int index, object value)
        {
            Insert(index, value as AccordionPane);
        }

        /// <summary>
        /// The collection is not a fixed size, so this
        /// always returns false
        /// </summary>
        bool IList.IsFixedSize
        {
            get { return false; }
        }

        /// <summary>
        /// Remove an AccordionPane from the list
        /// </summary>
        /// <param name="value">AccordionPane</param>
        void IList.Remove(object value)
        {
            Remove(value as AccordionPane);
        }

        /// <summary>
        /// Get an AccordionPane given its index
        /// </summary>
        /// <param name="index">Index</param>
        /// <returns>AccordionPane</returns>
        object IList.this[int index]
        {
            get { return this[index]; }
            set { }
        }

        /// <summary>
        /// This collection is not synchronized, so it always returns false
        /// </summary>
        bool ICollection.IsSynchronized
        {
            get { return false; }
        }

        /// <summary>
        /// This collection is not synchronized, so this always throws a
        /// NotImplementedException
        /// </summary>
        object ICollection.SyncRoot
        {
            get { throw new NotImplementedException(); }
        }

        /// <summary>
        /// Get an enumerator for the collection
        /// </summary>
        /// <returns>Enumerator</returns>
        IEnumerator IEnumerable.GetEnumerator()
        {
            return new AccordionPaneEnumerator(this);
        }

        /// <summary>
        /// Get an enumerator for the collection
        /// </summary>
        /// <returns>Enumerator</returns>
        public IEnumerator<AccordionPane> GetEnumerator()
        {
            return new AccordionPaneEnumerator(this);
        }

        /// <summary>
        /// Enumerator for the AccordionPaneCollection
        /// </summary>
        private class AccordionPaneEnumerator : IEnumerator<AccordionPane>
        {
            /// <summary>
            /// Reference to the collection
            /// </summary>
            private AccordionPaneCollection _collection;

            /// <summary>
            /// Enumerator for the parent Accordion.Controls collection
            /// </summary>
            private IEnumerator _parentEnumerator;

            /// <summary>
            /// Version of the collection when we began enumeration
            /// (used to check for modifications of the collection)
            /// </summary>
            private int _version;

            /// <summary>
            /// Constructor
            /// </summary>
            /// <param name="parent">AccordionPaneCollection</param>
            public AccordionPaneEnumerator(AccordionPaneCollection parent)
            {
                _collection = parent;
                _parentEnumerator = parent._parent.Controls.GetEnumerator();
                _version = parent._version;
            }

            /// <summary>
            /// Ensure the collection has not been modified while enumerating
            /// </summary>
            [SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", Justification = "Assembly is not localized")]
            private void CheckVersion()
            {
                if (_version != _collection._version)
                    throw new InvalidOperationException("Enumeration can't continue because the collection has been modified.");
            }

            /// <summary>
            /// Dispose of the enumerator
            /// </summary>
            public void Dispose()
            {
                _parentEnumerator = null;
                _collection = null;
                GC.SuppressFinalize(this);
            }

            /// <summary>
            /// Current AccordionPane
            /// </summary>
            public AccordionPane Current
            {
                get
                {
                    CheckVersion();
                    return _parentEnumerator.Current as AccordionPane;
                }
            }

            /// <summary>
            /// Current AccordionPane
            /// </summary>
            object IEnumerator.Current
            {
                get { return Current; }
            }

            /// <summary>
            /// Move to the next AccordionPane
            /// </summary>
            /// <returns>True if we were able to move, false otherwise</returns>
            public bool MoveNext()
            {
                CheckVersion();
                bool result = _parentEnumerator.MoveNext();
                if (result && !(_parentEnumerator.Current is AccordionPane))
                    result = MoveNext();
                return result;
            }

            /// <summary>
            /// Reset the enumerator to the beginning of the list
            /// </summary>
            public void Reset()
            {
                CheckVersion();
                _parentEnumerator.Reset();
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -