//------------------------------------------------------ // // Public Methods - ITfTransitoryExtensionSink // //------------------------------------------------------ #region ITfTransitoryExtensionSink // Transitory Document has been updated. // This is the notification of the changes of the result string and the composition string. public void OnTransitoryExtensionUpdated(UnsafeNativeMethods.ITfContext context, int ecReadOnly, UnsafeNativeMethods.ITfRange rangeResult, UnsafeNativeMethods.ITfRange rangeComposition, out bool fDeleteResultRange) { fDeleteResultRange = true; TextCompositionManager compmgr = InputManager.Current.PrimaryKeyboardDevice.TextCompositionManager; if (rangeResult != null) { string result = StringFromITfRange(rangeResult, ecReadOnly); if (result.Length > 0) { if (_composition == null) { // We don't have the composition now and we got the result string. // The result text is result and automatic termination is true. _composition = new DefaultTextStoreTextComposition(InputManager.Current, Keyboard.FocusedElement, result, TextCompositionAutoComplete.On); TextCompositionManager.StartComposition(_composition); // relese composition. _composition = null; } else { // Finalize the composition. _composition.SetCompositionText(""); _composition.SetText(result); // We don't call _composition.Complete() here. We just want to generate // TextInput events. TextCompositionManager.CompleteComposition(_composition); // relese composition. _composition = null; } } } if (rangeComposition != null) { string comp = StringFromITfRange(rangeComposition, ecReadOnly); if (comp.Length > 0) { if (_composition == null) { // Start the new composition. _composition = new DefaultTextStoreTextComposition(InputManager.Current, Keyboard.FocusedElement, "", TextCompositionAutoComplete.Off); _composition.SetCompositionText(comp); TextCompositionManager.StartComposition(_composition); } else { // Update the current composition. _composition.SetCompositionText(comp); _composition.SetText(""); TextCompositionManager.UpdateComposition(_composition); } } } }
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ /// <summary> /// Finalize the composition. /// </summary> public virtual void Complete() { // VerifyAccess(); TextCompositionManager.CompleteComposition(this); }