private void AdviseNotifySink(object o) { Debug.Assert(_cookie == UnsafeNativeMethods.TF_INVALID_COOKIE, "Cookie is already set."); UnsafeNativeMethods.ITfSource source = _ipp.Value as UnsafeNativeMethods.ITfSource; // workaround because I can't pass a ref to a readonly constant Guid guid = UnsafeNativeMethods.IID_ITfLanguageProfileNotifySink; source.AdviseSink(ref guid, o, out _cookie); }
private void _RegisterTextStore(TextStore textstore) { int editCookie = -1; int threadFocusCookie = -1; int editSinkCookie = -1; if (this._threadManager == null) { this._threadManager = new SecurityCriticalDataClass <UnsafeNativeMethods.ITfThreadMgr>(TextServicesLoader.Load()); if (this._threadManager.Value == null) { this._threadManager = null; return; } int value; this._threadManager.Value.Activate(out value); this._clientId = new SecurityCriticalData <int>(value); base.Dispatcher.ShutdownFinished += this.OnDispatcherShutdownFinished; } UnsafeNativeMethods.ITfDocumentMgr tfDocumentMgr; this._threadManager.Value.CreateDocumentMgr(out tfDocumentMgr); UnsafeNativeMethods.ITfContext tfContext; tfDocumentMgr.CreateContext(this._clientId.Value, (UnsafeNativeMethods.CreateContextFlags) 0, textstore, out tfContext, out editCookie); tfDocumentMgr.Push(tfContext); if (textstore != null) { Guid guid = UnsafeNativeMethods.IID_ITfThreadFocusSink; UnsafeNativeMethods.ITfSource tfSource = this._threadManager.Value as UnsafeNativeMethods.ITfSource; tfSource.AdviseSink(ref guid, textstore, out threadFocusCookie); } if (textstore != null) { Guid guid = UnsafeNativeMethods.IID_ITfTextEditSink; UnsafeNativeMethods.ITfSource tfSource = tfContext as UnsafeNativeMethods.ITfSource; tfSource.AdviseSink(ref guid, textstore, out editSinkCookie); } Marshal.ReleaseComObject(tfContext); textstore.DocumentManager = tfDocumentMgr; textstore.ThreadFocusCookie = threadFocusCookie; textstore.EditSinkCookie = editSinkCookie; textstore.EditCookie = editCookie; if (textstore.UiScope.IsKeyboardFocused) { textstore.OnGotFocus(); } this._registeredtextstorecount++; }
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods #endregion Public Methods //------------------------------------------------------ // // Public Operators // //------------------------------------------------------ //------------------------------------------------------ // // Public Properties // //------------------------------------------------------ //------------------------------------------------------ // // Public Events // //------------------------------------------------------ //------------------------------------------------------ // // Protected Methods // //------------------------------------------------------ //------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods /// <summary> /// Advise the notify sink of the compartment update. /// </summary> internal void AdviseNotifySink(UnsafeNativeMethods.ITfCompartmentEventSink sink) { Debug.Assert(_cookie == UnsafeNativeMethods.TF_INVALID_COOKIE, "cookie is already set."); UnsafeNativeMethods.ITfCompartment compartment = GetITfCompartment(); if (compartment == null) { return; } UnsafeNativeMethods.ITfSource source = compartment as UnsafeNativeMethods.ITfSource; // workaround because I can't pass a ref to a readonly constant Guid guid = UnsafeNativeMethods.IID_ITfCompartmentEventSink; source.AdviseSink(ref guid, sink, out _cookie); Marshal.ReleaseComObject(compartment); Marshal.ReleaseComObject(source); }
internal static void StartTransitoryExtension(TextStore textstore) { UnsafeNativeMethods.ITfCompartmentMgr tfCompartmentMgr = textstore.DocumentManager as UnsafeNativeMethods.ITfCompartmentMgr; Guid guid = UnsafeNativeMethods.GUID_COMPARTMENT_TRANSITORYEXTENSION; UnsafeNativeMethods.ITfCompartment tfCompartment; tfCompartmentMgr.GetCompartment(ref guid, out tfCompartment); object obj = 2; tfCompartment.SetValue(0, ref obj); guid = UnsafeNativeMethods.IID_ITfTransitoryExtensionSink; UnsafeNativeMethods.ITfSource tfSource = textstore.DocumentManager as UnsafeNativeMethods.ITfSource; if (tfSource != null) { int transitoryExtensionSinkCookie; tfSource.AdviseSink(ref guid, textstore, out transitoryExtensionSinkCookie); textstore.TransitoryExtensionSinkCookie = transitoryExtensionSinkCookie; } Marshal.ReleaseComObject(tfCompartment); }