/// <summary> /// Sets the mark at the line <c>lineNr</c> if it is not set, if the /// line is already marked the mark is cleared. /// </summary> /// <param name="lineNr">The line number.</param> public void ToggleMarkAt(int lineNr) { Bookmark newMark; if (factory != null) { newMark = factory.CreateBookmark(document, lineNr); } else { newMark = new Bookmark(document, lineNr); } Type newMarkType = newMark.GetType(); for (int i = 0; i < bookmark.Count; ++i) { Bookmark mark = bookmark[i]; if (mark.LineNumber == lineNr && mark.CanToggle && mark.GetType() == newMarkType) { bookmark.RemoveAt(i); OnRemoved(new BookmarkEventArgs(mark)); return; } } bookmark.Add(newMark); OnAdded(new BookmarkEventArgs(newMark)); }
/// <summary> /// Sets the mark at the line <code>location.Line</code> if it is not set. If the /// line is already marked the mark is cleared. /// </summary> public void ToggleMarkAt(TextLocation location) { Bookmark newMark = (Factory != null) ? Factory.CreateBookmark(_document, location) : new Bookmark(_document, location); Type newMarkType = newMark.GetType(); for (int i = 0; i < _bookmarks.Count; ++i) { Bookmark mark = _bookmarks[i]; if (mark.LineNumber == location.Line && mark.CanToggle && mark.GetType() == newMarkType) { _bookmarks.RemoveAt(i); OnRemoved(new BookmarkEventArgs(mark)); return; } } _bookmarks.Add(newMark); OnAdded(new BookmarkEventArgs(newMark)); }