示例#1
0
        public void GetSelection(uint index, ref TsSelectionAcp selection, out uint cFetched)
        {
            cFetched = 0;

            //does the caller have a lock
            if (!_IsLocked(TsLfFlags.Read))
            {
                //the caller doesn't have a lock
                //return NativeMethods.TS_E_NOLOCK;
                throw new COMException("", (int)TsErrors.TsENolock);
            }

            //check the requested index
            if (-1 == (int)index)
            {
                index = 0;
            }
            else if (index > 1)
            {
                /*
                 * The index is too high. This app only supports one selection.
                 */
                throw new COMException("", Result.InvalidArg.Code);
            }

            selection.AcpStart           = _acpStart;
            selection.AcpEnd             = _acpEnd;
            selection.Style.FInterimChar = _interimChar;

            if (_interimChar)
            {
                /*
                 * fInterimChar will be set when an intermediate character has been
                 * set. One example of when this will happen is when an IME is being
                 * used to enter characters and a character has been set, but the IME
                 * is still active.
                 */
                selection.Style.Ase = TsActiveSelEnd.TsAeNone;
            }
            else
            {
                selection.Style.Ase = _activeSelectionEnd;
            }

            cFetched = 1;
        }
示例#2
0
        public void SetSelection(uint count, ref TsSelectionAcp selections)
        {
            //this implementaiton only supports a single selection
            if (count != 1)
            {
                throw new COMException("", Result.InvalidArg.Code);
            }

            //does the caller have a lock
            if (!_IsLocked(TsLfFlags.Readwrite))
            {
                //the caller doesn't have a lock
                //return NativeMethods.TS_E_NOLOCK;
                throw new COMException("", (int)TsErrors.TsENolock);
            }

            _acpStart    = selections.AcpStart;
            _acpEnd      = selections.AcpEnd;
            _interimChar = selections.Style.FInterimChar;

            if (_interimChar)
            {
                /*
                 * fInterimChar will be set when an intermediate character has been
                 * set. One example of when this will happen is when an IME is being
                 * used to enter characters and a character has been set, but the IME
                 * is still active.
                 */
                _activeSelectionEnd = TsActiveSelEnd.TsAeNone;
            }
            else
            {
                _activeSelectionEnd = selections.Style.Ase;
            }

            //if the selection end is at the start of the selection, reverse the parameters
            int lStart = _acpStart;
            int lEnd   = _acpEnd;

            if (TsActiveSelEnd.TsAeStart == _activeSelectionEnd)
            {
                lStart = _acpEnd;
                lEnd   = _acpStart;
            }
        }
示例#3
0
        public void SetText(int dwFlags, int acpStart, int acpEnd, string pchText, uint cch, out TsfSharp.TsTextchange change)
        {
            /*
             * dwFlags can be:
             * TS_ST_CORRECTION
             */

            //set the selection to the specified range
            TsSelectionAcp tsa = new TsSelectionAcp();

            tsa.AcpStart           = acpStart;
            tsa.AcpEnd             = acpEnd;
            tsa.Style.Ase          = TsActiveSelEnd.TsAeStart;
            tsa.Style.FInterimChar = false;

            SetSelection(1, ref tsa);

            int start, end;

            InsertTextAtSelection(TsIasFlags.Noquery, pchText, cch, out start, out end, out change);
        }