ComponentFactory.Krypton.Toolkit.VisualPopup.Dispose C# (CSharp) Method

Dispose() protected method

Clean up any resources being used.
protected Dispose ( bool disposing ) : void
disposing bool true if managed resources should be disposed; otherwise, false.
return void
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                // Remove our show instance
                if (_shadow != null)
                {
                    _shadow.Dispose();
                    _shadow = null;
                }
            }

            base.Dispose(disposing);

            // Remove the active view, so the last view element to
            // have mouse input has a chance to cleanup processing
            if (ViewManager != null)
            {
                ViewManager.ActiveView = null;
                ViewManager.Dispose();
            }

            // Do we have a delegate to fire when popup is dismissed?
            if (_dismissedDelegate != null)
            {
                _dismissedDelegate(this, EventArgs.Empty);
                _dismissedDelegate = null;
            }
        }

Usage Example

        /// <summary>
        /// Finish tracking all popups.
        /// </summary>
        public void EndAllTracking()
        {
            // Are we tracking a popup?
            if (_current != null)
            {
                // Kill the popup window
                if (!_current.IsDisposed)
                {
                    _current.Dispose();
                    _current = null;
                }

                // Is there anything stacked?
                while (_stack.Count > 0)
                {
                    // Pop back the popup
                    _current = _stack.Pop();

                    // Kill the popup
                    _current.Dispose();
                    _current = null;
                }

                // No longer need to filter
                FilterMessages(false);
            }
        }