public static void GotoBookmark(ConcurrentDictionary <int, Bookmark> dico, int keyNumber) { if (dico == null) { dico = _dico; } Bookmark bmk; ITextBuffer buffer; IWpfTextView wpfView; if (dico.TryGetValue(keyNumber, out bmk)) { var dte = NumberedBookmarksPackage.Instance.DTE; for (int i = 0; i < dte.Documents.Count; i++) { var doc = dte.Documents.Item(i + 1); if (DocumentUtilities.GetTextBufferAndView(dte, doc, out buffer, out wpfView)) { if (buffer == bmk.Buffer) { doc.Activate(); try { var pos = bmk.TrackingPoint.GetPosition(buffer.CurrentSnapshot); var newSnap = new SnapshotPoint(buffer.CurrentSnapshot, pos); wpfView.Caret.MoveTo(newSnap); wpfView.DisplayTextLineContainingBufferPosition(newSnap, wpfView.ViewportHeight / 2, ViewRelativePosition.Top); } catch (Exception ex) { //send exception into task list window var errorProvider = new ErrorListProvider(NumberedBookmarksPackage.Instance); var t = new ErrorTask(ex); t.Line = bmk.Line; t.Column = 1; t.Document = doc.Name; t.Text = string.Format(CultureInfo.InvariantCulture, "Unable to go to bookmark #{0} : {1}", keyNumber, ex); errorProvider.Tasks.Add(t); } } } } } else { SetStatusText(string.Format("the bookmark '{0}' has no been pinned in document or document has been closed, press ctrl-shift-{0} to assign location", keyNumber)); } }
void generalPage_OnCommit(object sender, EventArgs e) { NumberedBookmarksOptions options = sender as NumberedBookmarksOptions; if (options.Options.UseBoomarkAcrossDocument != this.IsAcrossDocuments) { var oldValue = this.IsAcrossDocuments; this.IsAcrossDocuments = options.Options.UseBoomarkAcrossDocument; if (oldValue) { NumberedBookmarksGlobalManager.Clear(null); } else { //todo on every documents foreach (var buffer in DocumentUtilities.OpenedBuffers(this.DTE)) { NumberedBookmarksManager.GetBookmarkManager(buffer).Clear(); } } } }