예제 #1
0
파일: HtmlShim.cs 프로젝트: JianwenSun/cc
 protected HtmlToClrEventProxy AddEventProxy(string eventName, EventHandler eventHandler) {
     if (attachedEventList == null) {
         attachedEventList = new Dictionary<EventHandler, HtmlToClrEventProxy>();
     }     
     HtmlToClrEventProxy proxy = new HtmlToClrEventProxy(this, eventName, eventHandler);
     attachedEventList[eventHandler] = proxy;
     return proxy;
 }
            public override void DetachEventHandler(string eventName, EventHandler eventHandler)
            {
                HtmlToClrEventProxy pdisp = base.RemoveEventProxy(eventHandler);

                if (pdisp != null)
                {
                    ((System.Windows.Forms.UnsafeNativeMethods.IHTMLDocument3) this.NativeHtmlDocument2).DetachEvent(eventName, pdisp);
                }
            }
            /// Support IHTMLWindow3.DetachHandler
            public override void DetachEventHandler(string eventName, System.EventHandler eventHandler)
            {
                HtmlToClrEventProxy proxy = RemoveEventProxy(eventHandler);

                if (proxy != null)
                {
                    ((UnsafeNativeMethods.IHTMLWindow3) this.NativeHtmlWindow).DetachEvent(eventName, proxy);
                }
            }
            public override void DetachEventHandler(string eventName, EventHandler eventHandler)
            {
                HtmlToClrEventProxy proxy = RemoveEventProxy(eventHandler);

                if (proxy != null)
                {
                    ((IHTMLDocument3)NativeHtmlDocument2).DetachEvent(eventName, proxy);
                }
            }
            public override void DetachEventHandler(string eventName, EventHandler eventHandler)
            {
                HtmlToClrEventProxy proxy = RemoveEventProxy(eventHandler);

                if (proxy is not null)
                {
                    ((IHTMLWindow3)NativeHtmlWindow).DetachEvent(eventName, proxy);
                }
            }
            public override void AttachEventHandler(string eventName, EventHandler eventHandler)
            {
                // IE likes to call back on an IDispatch of DISPID=0 when it has an event,
                // the HtmlToClrEventProxy helps us fake out the CLR so that we can call back on
                // our EventHandler properly.

                HtmlToClrEventProxy proxy = AddEventProxy(eventName, eventHandler);

                ((IHTMLDocument3)NativeHtmlDocument2).AttachEvent(eventName, proxy);
            }
예제 #7
0
 protected HtmlToClrEventProxy RemoveEventProxy(EventHandler eventHandler)
 {
     if ((this.attachedEventList != null) && this.attachedEventList.ContainsKey(eventHandler))
     {
         HtmlToClrEventProxy proxy = this.attachedEventList[eventHandler];
         this.attachedEventList.Remove(eventHandler);
         return(proxy);
     }
     return(null);
 }
예제 #8
0
        protected HtmlToClrEventProxy AddEventProxy(string eventName, EventHandler eventHandler)
        {
            if (attachedEventList == null)
            {
                attachedEventList = new Dictionary <EventHandler, HtmlToClrEventProxy>();
            }
            HtmlToClrEventProxy proxy = new HtmlToClrEventProxy(this, eventName, eventHandler);

            attachedEventList[eventHandler] = proxy;
            return(proxy);
        }
            /// Support IHtmlDocument3.AttachHandler
            public override void AttachEventHandler(string eventName, System.EventHandler eventHandler)
            {
                // IE likes to call back on an IDispatch of DISPID=0 when it has an event,
                // the HtmlToClrEventProxy helps us fake out the CLR so that we can call back on
                // our EventHandler properly.

                HtmlToClrEventProxy proxy = AddEventProxy(eventName, eventHandler);
                bool success = ((UnsafeNativeMethods.IHTMLWindow3) this.NativeHtmlWindow).AttachEvent(eventName, proxy);

                Debug.Assert(success, "failed to add event");
            }
예제 #10
0
 public virtual void DisconnectFromEvents()
 {
     if (this.attachedEventList != null)
     {
         EventHandler[] array = new EventHandler[this.attachedEventList.Count];
         this.attachedEventList.Keys.CopyTo(array, 0);
         foreach (EventHandler handler in array)
         {
             HtmlToClrEventProxy proxy = this.attachedEventList[handler];
             this.DetachEventHandler(proxy.EventName, handler);
         }
     }
 }
예제 #11
0
        /// disconnect from connectionpoint cookie
        /// inheriting classes should override to disconnect from ConnectionPoint and call base.
        public virtual void DisconnectFromEvents()
        {
            if (attachedEventList != null)
            {
                EventHandler[] events = new EventHandler[attachedEventList.Count];
                attachedEventList.Keys.CopyTo(events, 0);

                foreach (EventHandler eh in events)
                {
                    HtmlToClrEventProxy proxy = attachedEventList[eh];
                    DetachEventHandler(proxy.EventName, eh);
                }
            }
        }
예제 #12
0
        protected HtmlToClrEventProxy RemoveEventProxy(EventHandler eventHandler)
        {
            if (attachedEventList == null)
            {
                return(null);
            }

            if (attachedEventList.ContainsKey(eventHandler))
            {
                HtmlToClrEventProxy proxy = attachedEventList[eventHandler] as HtmlToClrEventProxy;
                attachedEventList.Remove(eventHandler);
                return(proxy);
            }
            return(null);
        }
            public override void AttachEventHandler(string eventName, EventHandler eventHandler)
            {
                HtmlToClrEventProxy pdisp = base.AddEventProxy(eventName, eventHandler);

                ((System.Windows.Forms.UnsafeNativeMethods.IHTMLDocument3) this.NativeHtmlDocument2).AttachEvent(eventName, pdisp);
            }