AvalonStudio.TextEditor.Document.TextDocument.CreateAnchor C# (CSharp) Method

CreateAnchor() public method

Creates a new TextAnchor at the specified offset.
public CreateAnchor ( int offset ) : TextAnchor
offset int
return TextAnchor
		public TextAnchor CreateAnchor(int offset)
		{
			VerifyAccess();
			if (offset < 0 || offset > rope.Length)
			{
				throw new ArgumentOutOfRangeException("offset", offset,
					"0 <= offset <= " + rope.Length.ToString(CultureInfo.InvariantCulture));
			}
			return anchorTree.CreateAnchor(offset);
		}

Usage Example

Example #1
0
 /// <summary>
 ///     Creates a new AnchorSegment that creates new anchors.
 /// </summary>
 public AnchorSegment(TextDocument document, int offset, int length)
 {
     if (document == null)
     {
         throw new ArgumentNullException("document");
     }
     start = document.CreateAnchor(offset);
     start.SurviveDeletion = true;
     start.MovementType    = AnchorMovementType.AfterInsertion;
     end = document.CreateAnchor(offset + length);
     end.SurviveDeletion = true;
     end.MovementType    = AnchorMovementType.BeforeInsertion;
 }