Example #1
0
        private void OnSessionPresenterChanged(object sender, EventArgs e)
        {
            // It could have been any of our sessions that fired this event.  That means we've first got to determine which one it
            // was.

            IIntellisenseSession session = sender as IIntellisenseSession;

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

            // Since the presenter changed, we could have a new owner for the keyboard.  Figure it out.

            this.ReleaseKeyboard();

            // We should make sure to re-subscribe to events on this new presenter.

            IPopupIntellisensePresenter popupPresenter = session.Presenter as IPopupIntellisensePresenter;

            if (popupPresenter != null)
            {
                popupPresenter.PresentationSpanChanged += this.OnPresenterPresentationSpanChanged;
                popupPresenter.SurfaceElementChanged   += this.OnPresenterSurfaceElementChanged;
                popupPresenter.PopupStylesChanged      += this.OnPresenterPopupStylesChanged;

                this.RehostSession(session);
            }
            else
            {
                ICustomIntellisensePresenter customPresenter = session.Presenter as ICustomIntellisensePresenter;
                if (customPresenter != null)
                {
                    customPresenter.Render();
                }
            }

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

            this.DoleOutKeyboard();
        }