Beispiel #1
0
        public void OnEndEdit(ITfContext context, int ecReadOnly, ITfEditRecord editRecord)
        {
            ITfProperty property;

            context.GetProperty(GUID_PROP_COMPOSING, out property);

            ITfRangeACP rangeACP;

            TextServicesContext.Current.ContextOwnerServices.CreateRange(_compositionStart, _compositionStart + _compositionLength, out rangeACP);
            Variant val;

            property.GetValue(ecReadOnly, rangeACP, out val);
            property.Dispose();
            rangeACP.Dispose();
            if (val.Value == null || (int)val.Value == 0)
            {
                if (_commitLength == 0 || _inputBuffer.Count == 0)
                {
                    return;
                }

                //Debug.WriteLine("Composition result: {0}", new object[] { new string(_inputBuffer.GetRange(_commitStart, _commitLength).ToArray()) });

                _commited = true;
                for (int i = _commitStart; i < _commitLength; i++)
                {
                    InputMethod.OnTextInput(this, _inputBuffer[i]);
                }
            }

            if (_commited)
            {
                return;
            }

            if (_inputBuffer.Count == 0 && _compositionLength > 0) // Composition just ended
            {
                return;
            }

            _currentComposition.Clear();
            for (int i = _compositionStart; i < _compositionLength; i++)
            {
                _currentComposition.Add(_inputBuffer[i]);
            }

            InputMethod.OnTextComposition(this, new IMEString(_currentComposition), _acpEnd);

            //var compStr = new string(_currentComposition.ToArray());
            //compStr = compStr.Insert(_acpEnd, "|");
            //Debug.WriteLine("Composition string: {0}, cursor pos: {1}", compStr, _acpEnd);
        }
 public HRESULT OnEndEdit(ITfContext pic, uint ecReadOnly, ITfEditRecord pEditRecord)
 {
     throw new NotImplementedException();
 }