/// <summary>Add or remove a bookmark at 'row_index'</summary> private void SetBookmark(int row_index, Bit.EState bookmarked) { if (row_index < 0 || row_index >= m_line_index.Count) { return; } var line = m_line_index[row_index]; SetBookmark(line, bookmarked); // Restore the selected row SelectedRowIndex = row_index; }
/// <summary>Sets or clears the bookmark at file address 'addr'</summary> private void SetBookmark(RangeI line, Bit.EState bookmarked) { // Look for the bookmark var idx = Bookmarks.BinarySearch(b => b.Position.CompareTo(line.Beg)); if (idx >= 0 && bookmarked != Bit.EState.Set) { // Bookmark was found, remove it Bookmarks.RemoveAt(idx); } else if (idx < 0 && bookmarked != Bit.EState.Clear) { // Bookmark not found, insert it Bookmarks.Insert(~idx, new Bookmark(line, ReadLine(line).RowText)); } m_batch_refresh_bkmks.Signal(); }