CreateAnchor() public method

Creates a new TextAnchor at the specified offset.
public CreateAnchor ( int offset ) : TextAnchor
offset int
return TextAnchor
Beispiel #1
0
 public AnchorSegment(TextDocument document, int offset, int length)
 {
     Debug.Assert(document != null);
     this.start = document.CreateAnchor(offset);
     this.start.SurviveDeletion = true;
     this.end = document.CreateAnchor(offset + length);
     this.end.SurviveDeletion = true;
 }
Beispiel #2
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");
     }
     this.start = document.CreateAnchor(offset);
     this.start.SurviveDeletion = true;
     this.start.MovementType    = AnchorMovementType.AfterInsertion;
     this.end = document.CreateAnchor(offset + length);
     this.end.SurviveDeletion = true;
     this.start.MovementType  = AnchorMovementType.BeforeInsertion;
 }
Beispiel #3
0
        public void AnchorInEmptyDocument()
        {
            TextAnchor a1 = document.CreateAnchor(0);
            TextAnchor a2 = document.CreateAnchor(0);

            a1.MovementType = AnchorMovementType.BeforeInsertion;
            a2.MovementType = AnchorMovementType.AfterInsertion;
            Assert.AreEqual(0, a1.Offset);
            Assert.AreEqual(0, a2.Offset);
            document.Insert(0, "x");
            Assert.AreEqual(0, a1.Offset);
            Assert.AreEqual(1, a2.Offset);
        }