GetSelection() public method

public GetSelection ( int selectionNum, int &startOffset, int &endOffset ) : void
selectionNum int
startOffset int
endOffset int
return void
Esempio n. 1
0
        public ITextPatternRange [] GetSelection()
        {
            int nSelections = text.NSelections;

            TextRangePattern [] range = new TextRangePattern [nSelections];
            for (int i = 0; i < nSelections; i++)
            {
                int startOffset, endOffset;
                text.GetSelection(i, out startOffset, out endOffset);
                range [i] = new TextRangePattern(accessible, startOffset, endOffset);
            }
            return(range);
        }
Esempio n. 2
0
        public void RemoveFromSelection()
        {
            if (!accessible.StateSet.Contains(StateType.Enabled))
            {
                throw new ElementNotEnabledException();
            }

            int nSelections = text.NSelections;

            for (int i = 0; i < nSelections; i++)
            {
                int  start, end;
                bool set = false;
                text.GetSelection(i, out start, out end);
                if (startOffset > start && startOffset < end)
                {
                    startOffset = end;
                    set         = true;
                }
                if (endOffset > start && endOffset < end)
                {
                    endOffset = start;
                    set       = true;
                }
                if (set)
                {
                    if (endOffset < startOffset)
                    {
                        text.RemoveSelection(i);
                        i--;
                    }
                    else
                    {
                        text.SetSelection(i, startOffset, endOffset);
                    }
                    set = false;
                }
            }
        }