public TextMarker TryCreate(int startOffset, int length) { if (_markers == null) throw new InvalidOperationException("Cannot create a marker when not attached to a document"); var textLength = _document.TextLength; if (startOffset < 0 || startOffset > textLength) return null; if (length < 0 || startOffset + length > textLength) return null; var marker = new TextMarker(this, startOffset, length); _markers.Add(marker); return marker; }
public void AddMarker(TextMarker marker) { _markers.Add(marker); }
public void Remove(TextMarker marker) { if (marker == null) throw new ArgumentNullException(nameof(marker)); var m = marker; if (_markers != null && _markers.Remove(m)) { Redraw(m); m.OnDeleted(); } }