public IEnumerable <ITagSpan <SpaceNegotiatingAdornmentTag> > GetTags(NormalizedSnapshotSpanCollection spans) { if (wpfTextView.IsClosed) { yield break; } foreach (var span in spans) { foreach (var tagSpan in tagAggregator.GetTags(span)) { var spanColl = tagSpan.Span.GetSpans(wpfTextView.TextSnapshot); Debug.Assert(spanColl.Count != 0); if (spanColl.Count == 0) { continue; } var fullSpan = new SnapshotSpan(spanColl[0].Snapshot, Span.FromBounds(spanColl[0].Span.Start, spanColl[spanColl.Count - 1].Span.End)); var uiElem = tagSpan.Tag.Adornment; double topSpace = tagSpan.Tag.TopSpace ?? 0; double bottomSpace = tagSpan.Tag.BottomSpace ?? 0; double textHeight = tagSpan.Tag.TextHeight ?? (Filter(uiElem.DesiredSize.Height) - (topSpace + bottomSpace)); var adornmentInfo = new AdornmentTagInfo(fullSpan, uiElem, tagSpan); var tag = new SpaceNegotiatingAdornmentTag(Filter(uiElem.DesiredSize.Width), topSpace, tagSpan.Tag.Baseline ?? textHeight * 0.75, textHeight, bottomSpace, tagSpan.Tag.Affinity ?? PositionAffinity.Predecessor, adornmentInfo, providerTag); adornmentInfo.Tag = tag; yield return(new TagSpan <SpaceNegotiatingAdornmentTag>(fullSpan, tag)); } } }
string DisplayStringForTag(ITag tag, out object toolTipContent) { toolTipContent = null; List <string> content = new List <string>(); ClassificationTag classification = tag as ClassificationTag; if (classification != null) { content.Add(classification.ClassificationType.ToString()); } ErrorTag error = tag as ErrorTag; if (error != null) { toolTipContent = error.ToolTipContent; content.Add(error.ErrorType); } IOutliningRegionTag region = tag as IOutliningRegionTag; if (region != null) { toolTipContent = region.CollapsedHintForm; content.Add(string.Format("IsImplementation: {0}, IsDefaultCollapsed: {1}", region.IsImplementation, region.IsDefaultCollapsed)); } TextMarkerTag marker = tag as TextMarkerTag; if (marker != null) { content.Add(marker.Type); } SpaceNegotiatingAdornmentTag snat = tag as SpaceNegotiatingAdornmentTag; if (snat != null) { content.Add(string.Format("TextHeight: {0}, Width: {1}, Affinity: {2}", snat.TextHeight, snat.Width, snat.Affinity)); } IntraTextAdornmentTag itat = tag as IntraTextAdornmentTag; if (itat != null) { content.Add("Content: " + itat.Adornment.ToString()); } IUrlTag url = tag as IUrlTag; if (url != null) { content.Add(url.Url.ToString()); } if (content.Count > 0) { return(string.Join(Environment.NewLine, content)); } else { return(tag?.ToString()); } }