Click here to Skip to main content
15,886,362 members
Articles / Desktop Programming / Windows Forms

Storm - the world's best IDE framework for .NET

Rate me:
Please Sign up or sign in to vote.
4.96/5 (82 votes)
4 Feb 2010LGPL311 min read 274.6K   6.5K   340  
Create fast, flexible, and extensible IDE applications easily with Storm - it takes nearly no code at all!
//
//    ___ _____ ___  ___ __  __ 
//   / __|_   _/ _ \| _ \  \/  |
//   \__ \ | || (_) |   / |\/| |
//   |___/ |_| \___/|_|_\_|  |_|
// 
//   Storm.TabControl.dll
//   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//     Storm.TabControl.dll was created under the LGPL license.
//     It was based on another .dll and evolved from that one.
//     The original .dll was created by Hadi Eskandari.
//
//   What is Storm?
//   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//     Storm is a set of dynamic link libraries used in Theodor
//     "Vestras" Storm Kristensen's application "Moonlite".
//     
//
//   Thanks:
//   ¯¯¯¯¯¯¯
//     - Hadi Eskandari for creating and publishing the library.
//
//
//   Copyright (c) Theodor "Vestras" Storm Kristensen 2009
//   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//

namespace Storm.TabControl.Helpers
{
    using System;
    using System.Collections;
    using System.ComponentModel;

    #region Delegates
    public delegate void CollectionClear();
    public delegate void CollectionChange(int index, object value);
    #endregion

    #region Base class
    public abstract class EventCollection : CollectionBase
    {
        #region Members
        private int _suspendCount;

        [Browsable(false)]
        public event CollectionClear Clearing;

        [Browsable(false)]
        public event CollectionClear Cleared;

        [Browsable(false)]
        public event CollectionChange Inserting;

        [Browsable(false)]
        public event CollectionChange Inserted;

        [Browsable(false)]
        public event CollectionChange Removing;

        [Browsable(false)]
        public event CollectionChange Removed;
        #endregion

        #region Members
        #region Public
        public void SuspendEvents()
        {
            _suspendCount++;
        }

        public void ResumeEvents()
        {
            _suspendCount--;
        }

        // Property
        [Browsable(false)]
        public bool IsSuspended
        {
            get { return (_suspendCount > 0); }
        }
        #endregion

        #region Protected
        protected override void OnClear()
        {
            if (!IsSuspended)
            {
                if (Clearing != null)
                    Clearing();
            }
        }

        protected override void OnClearComplete()
        {
            if (!IsSuspended)
            {
                if (Cleared != null)
                    Cleared();
            }
        }

        protected override void OnInsert(int index, object value)
        {
            if (!IsSuspended)
            {
                if (Inserting != null)
                    Inserting(index, value);
            }
        }

        protected override void OnInsertComplete(int index, object value)
        {
            if (!IsSuspended)
            {
                if (Inserted != null)
                    Inserted(index, value);
            }
        }

        protected override void OnRemove(int index, object value)
        {
            if (!IsSuspended)
            {
                if (Removing != null)
                    Removing(index, value);
            }
        }

        protected override void OnRemoveComplete(int index, object value)
        {
            if (!IsSuspended)
            {
                if (Removed != null)
                    Removed(index, value);
            }
        }

        protected int IndexOf(object value)
        {
            return List.IndexOf(value);
        }
        #endregion
        #endregion

        /// <summary>
        /// Initializes the EventCollection
        /// </summary>
        public EventCollection()
        {
            _suspendCount = 0;
        }
    }
    #endregion
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)



Comments and Discussions