/// <summary> /// Initializes a new instance of the <see cref="TextViewCoverageProviderBase"/> class. /// </summary> /// <param name="view">The view.</param> public TextViewCoverageProviderBase(ITextView view) { if (OpenCoverUIPackage.Instance == null) { return; } _textView = view; _spanCoverage = new Dictionary<SnapshotSpan, bool>(); _codeCoverageResultsControl = OpenCoverUIPackage.Instance .GetToolWindow<CodeCoverageResultsToolWindow>() .CodeCoverageResultsControl; _currentSpans = GetWordSpans(_textView.TextSnapshot); _textView.GotAggregateFocus += SetupSelectionChangedListener; _codeCoverageResultsControl.NewCoverageDataAvailable += OnNewCoverageDataAvailable; }
/// <summary> /// Standard constructor for the tool window. /// </summary> public CodeCoverageResultsToolWindow() : base(null) { // Set the window title reading it from the resources. this.Caption = Resources.ToolWindowTitle; // Set the image that will appear on the tab of the window frame // when docked with an other window // The resource ID correspond to the one defined in the resx file // while the Index is the offset in the bitmap strip. Each image in // the strip being 16x16. this.BitmapResourceID = 301; this.BitmapIndex = 1; // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable, // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on // the object returned by the Content property. _codeCoverageResultsControl = new CodeCoverageResultsControl(); base.Content = _codeCoverageResultsControl; }
/// <summary> /// Disposes the base class /// <param name="disposing">True for clean up managed ressources.</param> /// </summary> protected virtual void Dispose(bool disposing) { if (_textView != null) { _textView.GotAggregateFocus -= SetupSelectionChangedListener; _textView.LayoutChanged -= ViewLayoutChanged; } if (_codeCoverageResultsControl != null) { _codeCoverageResultsControl.NewCoverageDataAvailable -= OnNewCoverageDataAvailable; } _textView = null; _spanCoverage.Clear(); _currentSpans.Clear(); _codeCoverageResultsControl = null; }
private void SetCodeCoverageResultsToolWindow() { // Get the instance number 0 of this tool window. This window is single instance so this instance // is actually the only one. // The last flag is set to true so that if the tool window does not exists it will be created. CodeCoverageResultsToolWindow = this.FindToolWindow(typeof(CodeCoverageResultsToolWindow), 0, true) as CodeCoverageResultsToolWindow; if ((null == CodeCoverageResultsToolWindow) || (null == CodeCoverageResultsToolWindow.Frame)) { throw new NotSupportedException(Resources.CanNotCreateWindow); } else { CodeCoverageResultsControl = CodeCoverageResultsToolWindow.Content as CodeCoverageResultsControl; var frame = CodeCoverageResultsToolWindow.Frame as IVsWindowFrame; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(frame.Show()); frame.Hide(); } }