private void SetCodeCoverageChanged() { ITextDocument textDocument = _textView.TextBuffer.GetTextDocument(); if (textDocument == null) { return; } SourcefileViewModel sourceFile = _codeCoverage.GetSourceFileByPath(textDocument.FilePath); _margin.DataContext = sourceFile; if (sourceFile == null || !_codeCoverage.ShowLinesHit) { Visibility = Visibility.Collapsed; } else { Visibility = Visibility.Visible; } }
private void UpdateLines(IEnumerable <ITextViewLine> newOrReformattedLines) { ITextDocument textDocument = _view.TextBuffer.GetTextDocument(); if (textDocument == null) { return; } SourcefileViewModel sourceFile = PowershellService.Current.CodeCoverage.GetSourceFileByPath(textDocument.FilePath); if (sourceFile == null) { return; } double viewportWidth = _view.ViewportWidth; foreach (ITextViewLine line in newOrReformattedLines) { int lineNumber = _view.TextSnapshot.GetLineNumberFromPosition(line.Extent.Start) + 1; if (sourceFile.LinesHit.ContainsKey(lineNumber)) { bool hit = sourceFile.LinesHit[lineNumber]; Rectangle rect = new Rectangle { Height = line.Height, Width = viewportWidth, Fill = hit ? HitBackground : MissedBackground, Opacity = 0.35 }; Canvas.SetLeft(rect, _view.ViewportLeft); Canvas.SetTop(rect, line.Top); _layer.AddAdornment(line.Extent, null, rect); } } }