コード例 #1
0
        internal TextServicesCompartment GetThreadCompartment(Guid guid)
        {
            // No TextServices are installed so that the compartment won't work.
            if (!TextServicesLoader.ServicesInstalled ||
                TextServicesContext.DispatcherCurrent == null)
            {
                return(null);
            }

            UnsafeNativeMethods.ITfThreadMgr threadmgr = TextServicesContext.DispatcherCurrent.ThreadManager;
            if (threadmgr == null)
            {
                return(null);
            }

            if (_compartmentTable == null)
            {
                _compartmentTable = new Hashtable();
            }

            TextServicesCompartment compartment;

            compartment = _compartmentTable[guid] as TextServicesCompartment;
            if (compartment == null)
            {
                compartment = new TextServicesCompartment(guid,
                                                          threadmgr as UnsafeNativeMethods.ITfCompartmentMgr);
                _compartmentTable[guid] = compartment;
            }

            return(compartment);
        }
コード例 #2
0
ファイル: TextServicesContext.cs プロジェクト: sososu/wpf
        //------------------------------------------------------
        //
        //  Private Methods
        //
        //------------------------------------------------------

        // Cal ITfThreadMgr.SetFocus() with dim
        private void SetFocusOnDim(UnsafeNativeMethods.ITfDocumentMgr dim)
        {
            UnsafeNativeMethods.ITfThreadMgr threadmgr = ThreadManager;

            if (threadmgr != null)
            {
                threadmgr.SetFocus(dim);
            }
        }
コード例 #3
0
ファイル: TextServicesContext.cs プロジェクト: sososu/wpf
        // Called by framework's TextStore class.  This method registers a
        // document with TSF.  The TextServicesContext must maintain this list
        // to ensure all native resources are released after gc or uninitialization.
        internal void RegisterTextStore(DefaultTextStore defaultTextStore)
        {
            // We must cache the DefaultTextStore because we'll need it from
            // a worker thread if the AppDomain is torn down before the Dispatcher
            // is shutdown.
            _defaultTextStore = defaultTextStore;

            UnsafeNativeMethods.ITfThreadMgr threadManager = ThreadManager;

            if (threadManager != null)
            {
                UnsafeNativeMethods.ITfDocumentMgr doc;
                UnsafeNativeMethods.ITfContext     context;
                int editCookie = UnsafeNativeMethods.TF_INVALID_COOKIE;

                // Activate TSF on this thread if this is the first TextStore.
                if (_istimactivated == false)
                {
                    //temp variable created to retrieve the value
                    // which is then stored in the critical data.
                    int clientIdTemp;
                    threadManager.Activate(out clientIdTemp);
                    _clientId       = new SecurityCriticalData <int>(clientIdTemp);
                    _istimactivated = true;
                }

                // Create a TSF document.
                threadManager.CreateDocumentMgr(out doc);
                doc.CreateContext(_clientId.Value, 0 /* flags */, _defaultTextStore, out context, out editCookie);
                doc.Push(context);

                // Release any native resources we're done with.
                Marshal.ReleaseComObject(context);

                // Same DocumentManager and EditCookie in _defaultTextStore.
                _defaultTextStore.DocumentManager = doc;
                _defaultTextStore.EditCookie      = editCookie;

                // Start the transitory extenstion so we can have Level 1 composition window from Cicero.
                StartTransitoryExtension();
            }
        }