![]() This tutorial is based on Microsoft’s sample on Glyphs. If you’re unfamiliar with Taggers, TaggerProviders or MEF (All the attributes), you can start with Part 5: Highlight code in Editor. Here I created in code a WPF Grid and a Rectangle, but usually you’ll want to create a WPF Control in a separate file.The width and height of the glyph bar are obtained with line.Height.The UI element created is centered in the middle of the line, both vertically and horizontally.This is pretty straightforward, but some things to note: HorizontalAlignment = HorizontalAlignment.Right Public UIElement GenerateGlyph(IWpfTextViewLine line, IGlyphTag tag) Internal class CommentGlyphFactory : IGlyphFactory The GlyphFactory will go over all the CommentTags that we created with the Tagger and tell VS to draw the Glyphs. The following part will actually draw the UI in the lines where CommentTags are created. We simply look for “//” in the given span and return a TagSpan marking the location of “//”. The ITagger creates CommentTag items wherever we need to draw the Glyph. Yield return new TagSpan(todoSpan, new CommentTag()) SnapshotSpan todoSpan = new SnapshotSpan(curSpan.Snapshot, new Span(curSpan.Start + loc, 2)) Int loc = curSpan.GetText().IndexOf( _searchText) IEnumerable> ITagger.GetTags(NormalizedSnapshotSpanCollection spans) The Tagger is the class that “tells” Visual Studio the text spans (ranges) where the effects (like our Glyph) should be drawn. ![]() ![]() Step 1: Create a Tagger that provides IGlyphTag
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |