private void onChanging(object sender, DocumentChangeEventArgs e) { if (!InAutomaticChange) { changedSegments = Segments.FindOverlappingSegments(e.Offset, e.RemovalLength); lastChange = e; } }
public void Replace(ref int offset, ref int replacementLength, SegmentedDocument text) { InAutomaticChange = true; var affectedSegments = new ReadOnlyCollection <DocumentSegment>(new List <DocumentSegment>()); affectedSegments = Segments.FindOverlappingSegments(offset, replacementLength); string textString = text.Text; Replace(affectedSegments, ref offset, ref replacementLength, ref textString); foreach (DocumentSegment segment in text.Segments) { DocumentSegment newsegment = segment.Clone(); newsegment.StartOffset = newsegment.StartOffset + offset; newsegment.EndOffset = newsegment.StartOffset + newsegment.Length; Segments.Add(newsegment); } InAutomaticChange = false; lastChange = null; }