Atspi.Text.GetTextBeforeOffset C# (CSharp) Метод

GetTextBeforeOffset() публичный Метод

public GetTextBeforeOffset ( int offset, BoundaryType type, int &startOffset, int &endOffset ) : string
offset int
type BoundaryType
startOffset int
endOffset int
Результат string
        public string GetTextBeforeOffset(int offset, BoundaryType type, out int startOffset, out int endOffset)
        {
            string text;
            proxy.GetTextBeforeOffset (offset, type, out text, out startOffset, out endOffset);
            return text;
        }

Usage Example

Пример #1
0
        public int MoveEndpointByUnit(TextPatternRangeEndpoint endpoint, TextUnit unit, int count)
        {
            if (count == 0)
            {
                return(0);
            }
            switch (unit)
            {
            case TextUnit.Format:
                Log.Debug("AtspiUiaSource: Moving by unit "
                          + unit + " not supported.");
                return(0);

            case TextUnit.Word:
                if (endpoint == TextPatternRangeEndpoint.Start)
                {
                    return(WordMoveStartPoint(count));
                }
                else
                {
                    return(WordMoveEndPoint(count));
                }

            case TextUnit.Page:
            case TextUnit.Document:
                if (endpoint == TextPatternRangeEndpoint.Start)
                {
                    if (count < 0)
                    {
                        if (startOffset <= 0)
                        {
                            return(0);
                        }
                        StartOffset = 0;
                        return(-1);
                    }
                    else
                    {
                        int characterCount = text.CharacterCount;
                        if (startOffset >= characterCount)
                        {
                            return(0);
                        }
                        StartOffset = characterCount;
                        return(1);
                    }
                }
                else
                {
                    if (count < 0)
                    {
                        if (endOffset <= 0)
                        {
                            return(0);
                        }
                        EndOffset = 0;
                        return(-1);
                    }
                    else
                    {
                        int characterCount = text.CharacterCount;
                        if (endOffset >= characterCount)
                        {
                            return(0);
                        }
                        EndOffset = characterCount;
                        return(1);
                    }
                }

            case TextUnit.Paragraph:
                if (endpoint == TextPatternRangeEndpoint.Start)
                {
                    return(ParagraphMoveStartPoint(count));
                }
                else
                {
                    return(ParagraphMoveEndPoint(count));
                }

            default:
                int offset = (endpoint == TextPatternRangeEndpoint.Start
                                        ? startOffset
                                        : endOffset - 1);
                int          newStartOffset = offset;
                int          newEndOffset   = offset;
                int          ret            = 0;
                BoundaryType boundary       = GetAtkBoundaryType(unit, count > 0);
                while (count != 0)
                {
                    int oldStartOffset = newStartOffset;
                    int oldEndOffset   = newEndOffset;
                    if (count < 0)
                    {
                        text.GetTextBeforeOffset(oldStartOffset, boundary, out newStartOffset, out newEndOffset);
                        if (newStartOffset == oldStartOffset &&
                            newEndOffset == oldEndOffset)
                        {
                            break;
                        }
                        count++;
                        ret--;
                    }
                    else
                    {
                        text.GetTextAfterOffset(oldStartOffset, boundary, out newStartOffset, out newEndOffset);
                        if (newStartOffset == oldStartOffset &&
                            newEndOffset == oldEndOffset)
                        {
                            break;
                        }
                        count--;
                        ret++;
                    }
                }
                if (endpoint == TextPatternRangeEndpoint.Start)
                {
                    StartOffset = newStartOffset;
                }
                else
                {
                    EndOffset = newEndOffset;
                }
                return(ret);
            }
        }