Example #1
0
        private void OnSessionDismissed(object sender, EventArgs e)
        {
            // Whenever a session is dismissed, we'll want to remove it from the stack, as it's no longer a "valid" session.

            IIntellisenseSession session = sender as IIntellisenseSession;

            if (session == null)
            {
                throw new ArgumentException("Expected 'sender' to be of type IIntellisenseSession", "sender");
            }

            if (!_sessions.Contains(session))
            {
                throw new ArgumentException("Expected session that is already on the stack", "sender");
            }

            // If it's the top session that was dismissed, our job is easy, we just have to pop() it off.

            if ((session.TextView != null) && (_tipManager != null))
            {
                var tip = session.Presenter as IObscuringTip;
                if (tip != null)
                {
                    _tipManager.RemoveTip(session.TextView, tip);
                }
            }

            if (session == this.TopSession)
            {
                this.PopSession();
                return;
            }

            // Must not have been the top session.  We'll have to remove it from the stack manually, then remove all of our
            // event handlers, etc.

            _sessions.Remove(session);
            this.RemoveSession(session);

            // If the session being removed is the one that's holding-on to the keyboard, we need to figure out who owns the
            // keyboard once again.

            if (session == _keyboardSession)
            {
                this.DoleOutKeyboard();
            }
        }