private void CreateBlockAdornment(Microsoft.PowerToolsEx.BlockTagger.IBlockTag tag, SnapshotSpan span, double x, double yTop, double yBottom) { LineGeometry line = new LineGeometry(new Point(x, yTop), new Point(x, yBottom)); GeometryDrawing drawing = new GeometryDrawing(null, _coloring.GetLinePen(tag), line); drawing.Freeze(); DrawingImage drawingImage = new DrawingImage(drawing); drawingImage.Freeze(); Image image = new Image(); image.Source = drawingImage; VisibleBlock block = new VisibleBlock(tag, x, yTop, yBottom); Canvas.SetLeft(image, x); Canvas.SetTop(image, yTop); _layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, block, image, OnAdornmentRemoved); _visibleBlocks.Add(block); }
private void DrawBlock(DrawingContext drawingContext, IMappingTagSpan <IBlockTag> tag, bool methodHighlights) { if (methodHighlights ? (tag.Tag.Type == BlockType.Method) : ((tag.Tag.Type != BlockType.Namespace) && (tag.Tag.Type != BlockType.Root))) { int level = 0; for (var p = tag.Tag.Parent; (p != null); p = p.Parent) { if ((p.Type != BlockType.Namespace) && (p.Type != BlockType.Root)) { ++level; } } NormalizedSnapshotSpanCollection spans = tag.Span.GetSpans(_textView.TextSnapshot); foreach (var span in spans) { double x = (double)(level) * (lineWidth + gapWidth) + 3.0; if (x < this.ActualWidth) { double yTop = _scrollBar.GetYCoordinateOfBufferPosition(span.Start); double yBottom = _scrollBar.GetYCoordinateOfBufferPosition(span.End); if (yBottom > yTop + 2.0) { if (methodHighlights) { drawingContext.PushClip(new RectangleGeometry(new Rect(x - 1.0, 0.0, (this.ActualWidth - x), this.ActualHeight))); drawingContext.DrawEllipse(_coloring.MethodSeparatorAndHighlightColoring.ToolTipBrush, null, new Point(x - 1.0, (yTop + yBottom) * 0.5), (this.ActualWidth + 1.0 - x), (yBottom - yTop) * 0.5); drawingContext.Pop(); } else { drawingContext.DrawLine(_coloring.GetLinePen(tag.Tag), new Point(x, yTop), new Point(x, yBottom)); } } } } } }