private void Insert(BookmarkViewModel viewModel) { int i; for (i = 0; i < _bookmarks.Count; ++i) { var bookmark = _bookmarks[i]; if (bookmark.Bookmark.Index > viewModel.Bookmark.Index) { break; } } _bookmarks.Insert(i, viewModel); }
public override void Update() { var bookmarks = _dataSources.Bookmarks; if (bookmarks != null) { // Add bookmarks we haven't added yet foreach (var bookmark in bookmarks) { BookmarkViewModel viewModel; if (!_viewModelByBookmark.TryGetValue(bookmark, out viewModel)) { viewModel = new BookmarkViewModel(bookmark, OnNavigateToBookmark, OnRemoveBookmark); _viewModelByBookmark.Add(bookmark, viewModel); Insert(viewModel); } } // Remove bookmarks that shouldn't be there for (int i = 0; i < _bookmarks.Count;) { var viewModel = _bookmarks[i]; if (!bookmarks.Contains(viewModel.Bookmark)) { _viewModelByBookmark.Remove(viewModel.Bookmark); _bookmarks.RemoveAt(i); } else { ++i; } } } CanAddBookmarks = Any(_currentDataSource?.SelectedLogLines); QuickInfo = FormatBookmarksCount(); }
private void AddBookmark() { var dataSource = _currentDataSource; var lines = _currentDataSource?.SelectedLogLines; if (dataSource == null || lines == null) { return; } var originalIndices = dataSource.FilteredLogFile.GetColumn(lines.ToList(), LogFileColumns.OriginalIndex); foreach (var line in originalIndices) { var bookmark = _dataSources.TryAddBookmark(dataSource, line); if (bookmark != null) { var viewModel = new BookmarkViewModel(bookmark, OnNavigateToBookmark, OnRemoveBookmark); _viewModelByBookmark.Add(bookmark, viewModel); Insert(viewModel); } } }
private void OnRemoveBookmark(BookmarkViewModel viewModel) { _viewModelByBookmark.Remove(viewModel.Bookmark); _bookmarks.Remove(viewModel); _dataSources.RemoveBookmark(viewModel.Bookmark); }
private void OnNavigateToBookmark(BookmarkViewModel viewModel) { _navigateToBookmark(viewModel.Bookmark); }