internal void OnActivateDesigner(DesignSurface surface)
        {
            IDesignerHost item = null;

            if (surface != null)
            {
                item = surface.GetService(typeof(IDesignerHost)) as IDesignerHost;
            }
            if ((item != null) && ((this._designerList == null) || !this._designerList.Contains(item)))
            {
                this.OnCreateDesigner(surface);
            }
            if (this._activeDesigner != item)
            {
                IDesignerHost provider = this._activeDesigner;
                this._activeDesigner = item;
                if (provider != null)
                {
                    this.SinkChangeEvents(provider, false);
                }
                if (this._activeDesigner != null)
                {
                    this.SinkChangeEvents(this._activeDesigner, true);
                }
                if (this._events != null)
                {
                    ActiveDesignerEventHandler handler = this._events[EventActiveDesignerChanged] as ActiveDesignerEventHandler;
                    if (handler != null)
                    {
                        handler(this, new ActiveDesignerEventArgs(provider, item));
                    }
                }
                this.OnSelectionChanged(this, EventArgs.Empty);
            }
        }
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// activedesignereventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this ActiveDesignerEventHandler activedesignereventhandler, Object sender, ActiveDesignerEventArgs e, AsyncCallback callback)
        {
            if (activedesignereventhandler == null)
            {
                throw new ArgumentNullException("activedesignereventhandler");
            }

            return(activedesignereventhandler.BeginInvoke(sender, e, callback, null));
        }
        /// <include file='doc\DocumentManager.uex' path='docs/doc[@for="DocumentManager.OnActiveDesignerChanged"]/*' />
        /// <devdoc>
        ///     Extending classes must call this when the active document changes.
        /// </devdoc>
        protected void OnActiveDesignerChanged(ActiveDesignerEventArgs e)
        {
            activeDesigner = e.NewDesigner;

            ActiveDesignerEventHandler handler = (ActiveDesignerEventHandler)eventTable[DOCUMENT_CHANGED_EVENT];

            if (handler != null)
            {
                handler.Invoke(this, e);
            }

            // Now update the selection events.
            //
            ISelectionService svc = null;

            if (e.NewDesigner != null)
            {
                svc = (ISelectionService)e.NewDesigner.GetService(typeof(ISelectionService));
            }
            OnSelectionChanged(svc);
        }