/// <summary> /// Create the glyph element. /// </summary> /// <param name="line">Editor line to create the glyph for.</param> /// <param name="tag">The corresponding tag.</param> /// <returns></returns> public UIElement GenerateGlyph(IWpfTextViewLine line, IGlyphTag tag) { // get the coverage info for the current line LineCoverageState state = GetLineCoverageState(line); // no coverage info found -> exit here if (state == LineCoverageState.Unknown) { return(null); } var brush = GetBrushForState(state); if (brush == null) { return(null); } System.Windows.Shapes.Ellipse ellipse = new Ellipse(); ellipse.Fill = brush; ellipse.Height = _glyphSize; ellipse.Width = _glyphSize; ellipse.ToolTip = GetToolTipText(state); if (state == LineCoverageState.Partly) { ellipse.MouseEnter += OnGlyphMouseEnter; ellipse.MouseLeave += OnGlyphMouseLeave; ellipse.Tag = line; } return(ellipse); }
/// <summary> /// Determines the correct brush for the coverage state. /// </summary> /// <param name="state">The line coverage state.</param> /// <returns></returns> private Brush GetBrushForState(LineCoverageState state) { switch (state) { case LineCoverageState.Covered: return _greenBrush; case LineCoverageState.Uncovered: return _redBrush; case LineCoverageState.Partly: return _orangeBrush; } return null; }
/// <summary> /// Determines the correct brush for the coverage state. /// </summary> /// <param name="state">The line coverage state.</param> /// <returns></returns> private Brush GetBrushForState(LineCoverageState state) { switch (state) { case LineCoverageState.Covered: return(_greenBrush); case LineCoverageState.Uncovered: return(_redBrush); case LineCoverageState.Partly: return(_orangeBrush); } return(null); }
/// <summary> /// Determines the tooltip text the coverage state. /// </summary> /// <param name="state">The line coverage state.</param> /// <returns></returns> private string GetToolTipText(LineCoverageState state) { switch (state) { case LineCoverageState.Covered: return("This line is fully covered."); case LineCoverageState.Uncovered: return("This line is not covered by any test."); case LineCoverageState.Partly: return("This line is partly covered by tests. The detailed coverage information is shown within the editor."); } return(null); }
/// <summary> /// Determines the tooltip text the coverage state. /// </summary> /// <param name="state">The line coverage state.</param> /// <returns></returns> private string GetToolTipText(LineCoverageState state) { switch (state) { case LineCoverageState.Covered: return "This line is fully covered."; case LineCoverageState.Uncovered: return "This line is not covered by any test."; case LineCoverageState.Partly: return "This line is partly covered by tests. The detailed coverage information is shown within the editor."; } return null; }