Exemple #1
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public virtual void Dispose()
        {
            //Debug.Print("Control.Base: Disposing {0} {1:X}", this, GetHashCode());
            if (m_Disposed)
            {
#if DEBUG
                throw new ObjectDisposedException(String.Format("Control.Base [{1:X}] disposed twice: {0}", this, GetHashCode()));
#else
                return;
#endif
            }

            if (InputHandler.HoveredControl == this)
            {
                InputHandler.HoveredControl = null;
            }
            if (InputHandler.KeyboardFocus == this)
            {
                InputHandler.KeyboardFocus = null;
            }
            if (InputHandler.MouseFocus == this)
            {
                InputHandler.MouseFocus = null;
            }

            DragAndDrop.ControlDeleted(this);
            Animation.Cancel(this);

            foreach (ControlBase child in m_Children)
            {
                child.Dispose();
            }

            m_Children.Clear();

            m_Disposed = true;
            GC.SuppressFinalize(this);
        }