Exemplo n.º 1
0
        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;
                //throw new ArgumentOutOfRangeException(nameof(startOffset), startOffset, "Value must be between 0 and " + textLength);
            if (length < 0 || startOffset + length > textLength) return null;
                //throw new ArgumentOutOfRangeException(nameof(length), length, "length must not be negative and startOffset+length must not be after the end of the document");

            var marker = new TextMarker(this, startOffset, length);
            _markers.Add(marker);
            return marker;
        }
Exemplo n.º 2
0
 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();
     }
 }