///////////////////////////////////////////////////////////////////////////////////////////////////// // PUBLIC PROCEDURES ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Sets the current statement indicator, by finding the next breakpoint after the specified snapshot offset. /// </summary> /// <param name="document">The editor document.</param> /// <param name="startSnapshotOffset">The starting snapshot offset to examine.</param> /// <returns>The current statement snapshot offset.</returns> public static TextSnapshotOffset SetCurrentStatement(IEditorDocument document, TextSnapshotOffset startSnapshotOffset) { if (!startSnapshotOffset.IsDeleted) { // Create search options (only allow enabled breakpoints) var options = new TagSearchOptions <BreakpointIndicatorTag>(); options.Filter = (tr => tr.Tag.IsEnabled); // Find the next breakpoint var tagRange = document.IndicatorManager.Breakpoints.FindNext(startSnapshotOffset, options); if (tagRange != null) { // Get the snapshot range of the breakpoint var snapshotRange = tagRange.VersionRange.Translate(startSnapshotOffset.Snapshot); var currentStatementSnapshotOffset = new TextSnapshotOffset(snapshotRange.Snapshot, snapshotRange.EndOffset); // Set the current statement indicator range document.IndicatorManager.CurrentStatement.SetInstance(snapshotRange); return(currentStatementSnapshotOffset); } } // Remove any current statement indicator document.IndicatorManager.CurrentStatement.Clear(); return(TextSnapshotOffset.Deleted); }
/// <summary> /// Occurs when the button is clicked. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">A <see cref="RoutedEventArgs"/> that contains the event data.</param> private void OnGoToNextIndicatorButtonClick(object sender, RoutedEventArgs e) { // Create search options var options = new TagSearchOptions <CustomIndicatorTag>(); options.CanWrap = true; options.SearchUp = false; // Find the next indicator (use a generic method provided on the indicator manager for custom indicators) var tagRange = editor.Document.IndicatorManager.FindNext <CustomIndicatorTagger, CustomIndicatorTag>(editor.ActiveView.Selection.EndSnapshotOffset, options); if (tagRange != null) { // Move the caret editor.ActiveView.Selection.CaretOffset = tagRange.VersionRange.Translate(editor.ActiveView.CurrentSnapshot).StartOffset; } // Focus the editor editor.Focus(); }
/// <summary> /// Occurs when the button is clicked. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">A <see cref="RoutedEventArgs"/> that contains the event data.</param> private void OnGoToPreviousIndicatorButtonClick(object sender, RoutedEventArgs e) { // Create search options (only find enabled bookmarks) var options = new TagSearchOptions <BookmarkIndicatorTag>(); options.CanWrap = true; options.SearchUp = true; options.Filter = (tr => tr.Tag.IsEnabled); // Find the previous indicator var tagRange = editor.Document.IndicatorManager.Bookmarks.FindNext(editor.ActiveView.Selection.EndSnapshotOffset.Line, options); if (tagRange != null) { // Move the caret editor.ActiveView.Selection.CaretOffset = tagRange.VersionRange.Translate(editor.ActiveView.CurrentSnapshot).StartOffset; } // Focus the editor editor.Focus(); }