/// <summary> /// Updates the adornment. /// </summary> bool UpdateAdornment(Adornment adornment, TagData dataTagData) { adornment.Update(dataTagData); return(true); }
/// <summary> /// Gets the or create adornment. /// </summary> UIElement GetOrCreateAdornment(AdornmentCache adornmentCache, SnapshotSpan snapshotSpan, TagData tagData, HashSet <SnapshotSpan> toRemove) { Adornment adornment; if (adornmentCache.TryGetValue(snapshotSpan, out adornment)) { if (UpdateAdornment(adornment, tagData)) { toRemove.Remove(snapshotSpan); } } else { var adornmentScope = new Scope { { Keys.TagModel, tagData }, { Keys.OnAdornmentClicked, OnAdornmentClicked }, { Keys.UpdateTextBoxStyleForVisualStudio, scope.TextBlockStyler } }; adornment = new Adornment(adornmentScope); // Get the adornment to measure itself. Its DesiredSize property is used to determine // how much space to leave between text for this adornment. // Note: If the size of the adornment changes, the line will be reformatted to accommodate it. // Note: Some adornments may change size when added to the view's visual tree due to inherited // dependency properties that affect layout. Such options can include SnapsToDevicePixels, // UseLayoutRounding, TextRenderingMode, TextHintingMode, and TextFormattingMode. Making sure // that these properties on the adornment match the view's values before calling Measure here // can help avoid the size change and the resulting unnecessary re-format. adornment.UIElement.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); adornmentCache.Add(snapshotSpan, adornment); } return(adornment.UIElement); }