예제 #1
0
        private void UpdateLines(IEnumerable <ITextViewLine> newOrReformattedLines)
        {
            ITextDocument textDocument = _view.TextBuffer.GetTextDocument();

            if (textDocument == null)
            {
                return;
            }
            TestFile sourceFile = _tests.GetTestFileByPath(textDocument.FilePath);

            double viewportWidth = _view.ViewportWidth;

            foreach (ITextViewLine line in newOrReformattedLines)
            {
                int  lineNumber;
                bool found = line.Extent.FindTest(_view, _classifier, out lineNumber);
                if (found)
                {
                    TestOutcome outcome = TestOutcome.None;
                    if (sourceFile != null)
                    {
                        outcome = sourceFile.GetOutcome(lineNumber);
                    }
                    Brush brush;
                    switch (outcome)
                    {
                    case TestOutcome.Failed:
                        brush = MissedBackground;
                        break;

                    case TestOutcome.Passed:
                        brush = HitBackground;
                        break;

                    case TestOutcome.None:
                    case TestOutcome.Skipped:
                    case TestOutcome.NotFound:
                    default:
                        brush = NotRunBackground;
                        break;
                    }

                    Rectangle rect = new Rectangle
                    {
                        Height  = line.Height,
                        Width   = viewportWidth,
                        Fill    = brush,
                        Opacity = 0.35
                    };

                    Canvas.SetLeft(rect, _view.ViewportLeft);
                    Canvas.SetTop(rect, line.Top);
                    _layer.AddAdornment(line.Extent, null, rect);
                }
            }
        }