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); }
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); }
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"); }
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); } } }
/// 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); } } }
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); }