Beispiel #1
0
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// designereventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this DesignerEventHandler designereventhandler, Object sender, DesignerEventArgs e, AsyncCallback callback)
        {
            if (designereventhandler == null)
            {
                throw new ArgumentNullException("designereventhandler");
            }

            return(designereventhandler.BeginInvoke(sender, e, callback, null));
        }
        /// <include file='doc\DocumentManager.uex' path='docs/doc[@for="DocumentManager.OnDesignerCreated"]/*' />
        /// <devdoc>
        ///     The designer should call this after it successfully loads.
        /// </devdoc>
        public void OnDesignerCreated(DesignerEventArgs e)
        {
            designers.Add(e.Designer);
            documents = null;
            DesignerEventHandler handler = (DesignerEventHandler)eventTable[DOCUMENT_CREATED_EVENT];

            if (handler != null)
            {
                handler.Invoke(this, e);
            }
        }
        /// <include file='doc\DocumentManager.uex' path='docs/doc[@for="DocumentManager.OnDesignerDisposed"]/*' />
        /// <devdoc>
        ///     The designer should call this before it disposes itself.
        /// </devdoc>
        public void OnDesignerDisposed(DesignerEventArgs e)
        {
            DesignerEventHandler handler = (DesignerEventHandler)eventTable[DOCUMENT_DISPOSED_EVENT];

            if (handler != null)
            {
                handler.Invoke(this, e);
            }
            if (designers.Contains(e.Designer))
            {
                designers.Remove(e.Designer);
            }
            if (activeDesigner == e.Designer)
            {
                activeDesigner = null;
            }
            documents = null;
        }
        internal void OnCreateDesigner(DesignSurface surface)
        {
            IDesignerHost service = surface.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (this._designerList == null)
            {
                this._designerList = new ArrayList();
            }
            this._designerList.Add(service);
            surface.Disposed += new EventHandler(this.OnDesignerDisposed);
            if (this._events != null)
            {
                DesignerEventHandler handler = this._events[EventDesignerCreated] as DesignerEventHandler;
                if (handler != null)
                {
                    handler(this, new DesignerEventArgs(service));
                }
            }
        }
        private void OnDesignerDisposed(object sender, EventArgs e)
        {
            DesignSurface provider = (DesignSurface)sender;

            provider.Disposed -= new EventHandler(this.OnDesignerDisposed);
            this.SinkChangeEvents(provider, false);
            IDesignerHost service = provider.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (service != null)
            {
                if (this._events != null)
                {
                    DesignerEventHandler handler = this._events[EventDesignerDisposed] as DesignerEventHandler;
                    if (handler != null)
                    {
                        handler(this, new DesignerEventArgs(service));
                    }
                }
                if (this._designerList != null)
                {
                    this._designerList.Remove(service);
                }
            }
        }