/// <summary> /// Row double-clicked /// </summary> private void Grid_HighlightRequired(object sender, CodeResultItemEventArgs e) { if (HighlightRequired != null) { HighlightRequired(sender, e); } }
/// <summary> /// Highlights given block of text in the code window /// </summary> protected void Panel_HighlightRequired(object sender, CodeResultItemEventArgs e) { try { // obtains IVsTextView instance, opening the file if necessary IVsTextView view = DocumentViewsManager.GetTextViewForFile(e.Item.SourceItem.GetFullPath(), true, true); if (view == null) { throw new Exception("Cannot open document."); } TextSpan span = e.Item.ReplaceSpan; // get text span of the result item int hr = view.SetSelection(span.iStartLine, span.iStartIndex, span.iEndLine, span.iEndIndex); Marshal.ThrowExceptionForHR(hr); hr = view.EnsureSpanVisible(span); // scroll down to ensure selection visible Marshal.ThrowExceptionForHR(hr); } catch (Exception ex) { VLOutputWindow.VisualLocalizerPane.WriteException(ex); VisualLocalizer.Library.Components.MessageBox.ShowException(ex); } }