/// <Summary> /// Attaches to the DWebBrowserEvents2 connection point. /// </Summary> internal override void CreateSink() { Debug.Assert(_axIWebBrowser2 != null); _cookie = new ConnectionPointCookie(_axIWebBrowser2, _hostingAdaptor.CreateEventSink(), typeof(UnsafeNativeMethods.DWebBrowserEvents2)); }
public void Dispose() { if (_textManagerEventsCookie != null) { _textManagerEventsCookie.Dispose(); _textManagerEventsCookie = null; } }
internal void StopEvents() { if (_connectionPoint is not null) { _connectionPoint.Disconnect(); _connectionPoint = null; } }
internal void StopEvents() { if (connectionPoint != null) { connectionPoint.Disconnect(); connectionPoint = null; } }
protected override void CreateSink() { try { cookie = new ConnectionPointCookie(control, this, typeof(IMyWebBrowserEvents)); } catch { } }
public void Disconnect() { if (this._eventSinkCookie != null) { this._eventSinkCookie.Disconnect(); this._eventSinkCookie = null; } this._element = null; }
public LanguageSettingsStorage(ICoreShell coreShell, Guid languageServiceId, Guid packageId, IEnumerable <string> automationObjectNames) { _shell = coreShell; _languageServiceId = languageServiceId; _packageGuid = packageId; _automationObjectNames = automationObjectNames; _textManager = _shell.GetService <IVsTextManager4>(typeof(SVsTextManager)); _textManagerEventsCookie = new ConnectionPointCookie(_textManager, this, typeof(IVsTextManagerEvents4)); }
protected override void CreateSink() { try { cookie = new ConnectionPointCookie(base.GetOcx(), this, typeof(IWebBrowserEvents)); } catch (Exception e) { Console.Error.WriteLine("Error in CreateSink: " + e.ToString()); } }
public LanguageSettingsStorage(IVsPackage package, IServiceContainer services, Guid languageServiceId, IEnumerable <string> automationObjectNames) { _package = package; _services = services; _languageServiceId = languageServiceId; _automationObjectNames = automationObjectNames; _textManager = _services.GetService <IVsTextManager4>(typeof(SVsTextManager)); _textManagerEventsCookie = new ConnectionPointCookie(_textManager, this, typeof(IVsTextManagerEvents4)); }
/// <summary> /// Connects the specified control and its underlying element to the event sink. /// </summary> /// <param name="_control">Control to connect.</param> /// <param name="element">Underlying element of control.</param> public void Connect(Interop.IHTMLElement element) { try { this._element = element; this._eventSinkCookie = new ConnectionPointCookie(this._element, this, typeof(Interop.IHTMLTextContainerEvents)); } catch (Exception) { } }
protected override void CreateSink() { try { eventMulticaster = new AxShockwaveFlashEventMulticaster(this); cookie = new ConnectionPointCookie(ocx, eventMulticaster, typeof(IFlashEvents)); } catch (Exception) { } }
protected virtual void Dispose(bool disposing) { if (disposing) { if (_textManagerEventsCookie != null) { _textManagerEventsCookie.Dispose(); _textManagerEventsCookie = null; } } }
private void HookTextManagerEvents() { IVsTextManager4 textManager = VsAppShell.Current.GlobalServices.GetService <IVsTextManager4>(typeof(SVsTextManager)); Debug.Assert(textManager != null); if (textManager != null) { // Hook into the "preferences changed" event so that I can update _langPrefs as needed _textManagerEventsCookie = new ConnectionPointCookie(textManager, this, typeof(IVsTextManagerEvents4)); } }
/// <summary> /// </summary> public void CreateMSHTML() { bool created = false; try { // create our base instance this.htmlbaseDocument = (Interop.IHTMLDocument2) new Interop.HTMLDocument(); this.activeObject = (Interop.IOleInPlaceActiveObject)htmlbaseDocument; this.windowHandle = new IntPtr(); this.activeObject.GetWindow(out this.windowHandle); oleDocumentObject = (Interop.IOleObject)htmlbaseDocument; if (oleDocumentObject == null) { throw new ApplicationException("InteropOleObject not created. No document available."); } // hand it our Interop.IOleClientSite implementation Win32.OleRun(htmlbaseDocument); oleDocumentObject.SetClientSite(this); Win32.OleLockRunning(htmlbaseDocument, true, false); created = true; // attach document and window base events propNotifyCookie = new ConnectionPointCookie(htmlbaseDocument, this, typeof(Interop.IPropertyNotifySink), false); // set document properties oleDocumentObject.SetHostNames("NetRix", "NetRix"); // set ole events oleDocumentObject.Advise(this, out adviseSinkCookie); // set IConnectionPointContainer icpc = (IConnectionPointContainer)htmlbaseDocument; //find the source interface ////get IPropertyNotifySink interface //Guid g = new Guid("9BFBBC02-EFF1-101A-84ED-00AA00341D07"); //icpc.FindConnectionPoint(ref g, out icp); ////pass a pointer to the host to the connection point //icp.Advise(this._site, out this._cookie); } catch (Exception ex) { Debug.Fail("CreateHtml failed", ex.Message); } finally { if (created == false) { htmlbaseDocument = null; oleDocumentObject = null; } } }
/// <summary> /// Connects the specified control and its underlying element to the event sink. /// </summary> /// <param name="element">Underlying element of control.</param> /// <param name="editor">Reference to editor control.</param> public void Connect(Interop.IHTMLElement element, IHtmlEditor editor) { this._editor = editor; this._designer = (ControlDesigner)this._behavior.Designer; try { this._element = element; this._elementStyle = this._element.GetStyle(); this._runTimeStyle = ((Interop.IHTMLElement2) this._element).GetRuntimeStyle(); this._eventSinkCookie = new ConnectionPointCookie(this._element, this, typeof(Interop.IHTMLElementEvents)); } catch (Exception) { } EventsEnabled = true; }
internal void StartEvents() { if (connectionPoint != null) { return; } object nativeObject = host.GetOcx(); try { connectionPoint = new ConnectionPointCookie(nativeObject, this, typeof(IPropertyNotifySink)); } catch { } }
/// <summary> /// Connects the specified control and its underlying element to the event sink. /// </summary> /// <param name="control">Control to connect.</param> /// <param name="element">Underlying element of control.</param> /// <param name="editor"></param> public void Connect(XmlControl control, Interop.IHTMLElement element, IHtmlEditor editor) { if (editor == null || control == null) { throw new NullReferenceException("Parameter does not allow null values"); } this._editor = editor; this._control = control; try { this._element = element; this._eventSinkCookie = new ConnectionPointCookie(this._element, this, typeof(Interop.IHTMLElementEvents)); //this._eventSinkCookie = new ConnectionPointCookie(this._element, this, typeof(Interop.IHTMLTextContainerEvents)); } catch (Exception) { } }
public void Disconnect() { if (this._eventSinkCookie != null) { try { this._eventSinkCookie.Disconnect(); this._eventSinkCookie = null; } catch { // on shut down the RCW might be detached alredy } } this._element = null; this._designer = null; this._behavior = null; }
protected override void CreateSink() { cookie = new ConnectionPointCookie(RdpClient, _events, typeof(IMsTscAxEvents)); }
protected override void CreateSink() { try { cookie = new ConnectionPointCookie(control, this, typeof (IWebBrowserEvents)); base.CreateSink(); } catch { } }
protected override void CreateSink() { try { cookie = new ConnectionPointCookie(GetOcx(), this, typeof(IWebBrowserEvents)); } catch { } }
/// <summary> /// Connects the specified control and its underlying element to the event sink. /// </summary> public void Connect() { this._baseElement = _element.GetBaseElement(); string scope = ((Interop.IHTMLElement2)_baseElement).GetScopeName(); if (!scope.Equals("HTML")) { return; // do not attach other than HTML controls } try { Guid guid; switch (_element.TagName.ToLower()) { default: // element guid = typeof(Interop.IHTMLElementEvents).GUID; break; case "": // generic/unknown elements guid = Guid.Empty; break; case "body": case "caption": case "textarea": case "td": case "th": case "fieldset": case "legend": guid = typeof(Interop.IHTMLTextContainerEvents).GUID; break; case "hr": case "tr": case "frame": guid = typeof(Interop.IHTMLControlElementEvents).GUID; break; case "a": guid = typeof(Interop.IHTMLAnchorEvents).GUID; break; case "area": guid = typeof(Interop.IHTMLAreaEvents).GUID; break; case "button": guid = typeof(Interop.IHTMLButtonElementEvents).GUID; break; case "form": guid = typeof(Interop.IHTMLFormElementEvents).GUID; break; case "img": guid = typeof(Interop.IHTMLImgEvents).GUID; break; case "label": guid = typeof(Interop.IHTMLLabelEvents).GUID; break; case "link": guid = typeof(Interop.IHTMLLinkElementEvents).GUID; break; case "map": guid = typeof(Interop.IHTMLMapEvents).GUID; break; case "marquee": guid = typeof(Interop.IHTMLMarqueeElementEvents).GUID; break; case "object": guid = typeof(Interop.IHTMLObjectElementEvents).GUID; break; case "script": guid = typeof(Interop.IHTMLScriptEvents).GUID; break; case "select": guid = typeof(Interop.IHTMLSelectElementEvents).GUID; break; case "style": guid = typeof(Interop.IHTMLStyleElementEvents).GUID; break; case "table": guid = typeof(Interop.IHTMLTableEvents).GUID; break; case "input": object att = _element.GetAttribute("type"); { switch (att.ToString().ToLower()) { case "file": guid = typeof(Interop.IHTMLInputFileElementEvents).GUID; break; case "image": guid = typeof(Interop.IHTMLInputImageEvents).GUID; break; case "text": case "hidden": case "password": guid = typeof(Interop.IHTMLInputTextElementEvents).GUID; break; case "checkbox": case "radio": guid = typeof(Interop.IHTMLOptionButtonElementEvents).GUID; break; case "button": case "submit": case "reset": guid = typeof(Interop.IHTMLButtonElementEvents).GUID; break; default: // control guid = typeof(Interop.IHTMLControlElementEvents).GUID; break; } break; } } specialEvents = new HTMLSpecialEvents(_element); if (!guid.Equals(Guid.Empty)) { this._eventSinkCookie = new ConnectionPointCookie(this._baseElement, specialEvents, guid, false); } } catch (Exception) { } }
internal void StartEvents() { if (connectionPoint != null) return; Object nativeObject = host.GetOcx(); try { connectionPoint = new ConnectionPointCookie(nativeObject, this, typeof(UnsafeNativeMethods.IPropertyNotifySink)); } catch { } }
protected override void CreateSink() { try { cookie = new ConnectionPointCookie(base.GetOcx(), this, typeof(IWebBrowserEvents)); } catch (Exception e){ Console.Error.WriteLine("Error in CreateSink: "+e.ToString()); } }
/// <summary> /// </summary> public void Dispose() { try { int RefCount; if (propNotifyCookie != null) { propNotifyCookie.Dispose(); propNotifyCookie = null; } if (winEvents != null) { winEvents.Dispose(); winEvents = null; } try { Marshal.ReleaseComObject(window); } catch { } try { if (interopDocumentView != null) { try { interopDocumentView.Show(0); } catch { } try { interopDocumentView.UIActivate(0); } catch { } try { interopDocumentView.SetInPlaceSite(null); } catch { } long nullParam = 0L; try { interopDocumentView.Close(nullParam); do { RefCount = Marshal.ReleaseComObject(interopDocumentView); } while (RefCount >= 0); } catch { } finally { Marshal.FinalReleaseComObject(interopDocumentView); interopDocumentView = null; } } } catch { } if (oleDocumentObject != null) { try { if (htmlEditor.Site == null || !htmlEditor.Site.DesignMode) { Marshal.FinalReleaseComObject(oleDocumentObject); oleDocumentObject = null; } } catch { } } if (htmlbaseDocument != null) { do { RefCount = Marshal.ReleaseComObject(htmlbaseDocument); } while (RefCount >= 0); Marshal.FinalReleaseComObject(htmlbaseDocument); htmlbaseDocument = null; } if (interopDocumentView != null) { do { RefCount = Marshal.ReleaseComObject(interopDocumentView); } while (RefCount >= 0); } if (activeObject != null) { do { RefCount = Marshal.ReleaseComObject(activeObject); } while (RefCount >= 0); Marshal.FinalReleaseComObject(activeObject); activeObject = null; } interopDocumentView = null; htmlbaseDocument = null; activeObject = null; } catch (Exception ex) { Debug.WriteLine(ex.Message); } }