public VisibleBlock(ISemanticBlockTag tag, double x, double yTop, double yBottom) { this.tag = tag; this.x = x; this.yTop = yTop; this.yBottom = yBottom; }
public bool UpdateTip(IVerticalScrollBar margin, MouseEventArgs e, ToolTip tip) { if ((!_textView.IsClosed) && (_tagger != null) && _previewEnabled) { Point pt = e.GetPosition(this); if ((pt.X >= 0.0) && (pt.X <= this.Width)) { SnapshotPoint position = _scrollBar.GetBufferPositionOfYCoordinate(pt.Y); ISemanticBlockTag deepestTag = null; var tags = _tagger.GetTags(new SnapshotSpan(position, 0)); foreach (var tagSpan in tags) { if (tagSpan.Tag.Type != BlockType.Unknown) { if ((deepestTag == null) || (tagSpan.Tag.Level > deepestTag.Level)) { deepestTag = tagSpan.Tag; } } } if (deepestTag != null) { if (tip.IsOpen) { var existingContext = tip.Content as FrameworkElement; if ((existingContext != null) && (existingContext.Tag == deepestTag)) { // No changes from the last time we opened the tip. return(true); } } FrameworkElement context = deepestTag.Context(_coloring, _textView.FormattedLineSource.DefaultTextProperties); context.Tag = deepestTag; //The width of the view is in zoomed coordinates so factor the zoom factor into the tip window width computation. double zoom = _textView.ZoomLevel / 100.0; tip.MinWidth = tip.MaxWidth = Math.Floor(Math.Max(50.0, _textView.ViewportWidth * zoom * 0.5)); tip.MinHeight = tip.MaxHeight = context.Height + 12.0; tip.Content = context; tip.IsOpen = true; StructureMarginElement.LogTipOpened("VS/PPT-Structure/MarginTipOpened", context); return(true); } } } return(false); }
private void CreateBlockAdornment(ISemanticBlockTag 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); }
public Brush GetToolTipBrush(ISemanticBlockTag tag) { return(this.GetColoring(tag.Type).ToolTipBrush); }
public Brush GetLineBrush(ISemanticBlockTag tag) { return(this.GetColoring(tag.Type).LineBrush); }
public Pen GetLinePen(ISemanticBlockTag tag) { return(this.GetColoring(tag.Type).LinePen); }
public Pen GetToolTipPen(ISemanticBlockTag tag) { return(this.GetColoring(tag.Type).ToolTipPen); }