ICSharpCode.AvalonEdit.Document.TextDocument.GetLocation C# (CSharp) Method

GetLocation() public method

Gets the location from an offset.
public GetLocation ( int offset ) : TextLocation
offset int
return TextLocation
        public TextLocation GetLocation(int offset)
        {
            DocumentLine line = GetLineByOffset(offset);
            return new TextLocation(line.LineNumber, offset - line.Offset + 1);
        }

Usage Example

        private static void AddFold(TextDocument document, ICollection<NewFolding> foldMarkers, int startOffset, int endOffset, string label)
        {
            // Do not add folding if start and end are on the same line.
            int startLine = document.GetLocation(startOffset).Line;
            int endLine = document.GetLocation(endOffset).Line;
            if (startLine >= endLine)
                return;

            foldMarkers.Add(new NewFolding(startOffset, endOffset) { Name = label });
        }
All Usage Examples Of ICSharpCode.AvalonEdit.Document.TextDocument::GetLocation