namespace Microsoft.VisualStudio.Text.Editor { using Microsoft.VisualStudio.Text.Formatting; using Microsoft.VisualStudio.Text.Tagging; using Microsoft.VisualStudio.Utilities; using System; using System.Collections.Generic; using System.ComponentModel.Composition; using System.Linq; using System.Windows; using System.Windows.Media; using System.Windows.Shapes; [Export(typeof(IGlyphFactoryProvider))] [Name("AGlyph")] [Order(After = "VsTextMarker")] [ContentType("code")] [TagType(typeof(ATag))] internal sealed class AGlyphFactory : IGlyphFactoryProvider, IGlyphFactory { public IGlyphFactory GetGlyphFactory(IWpfTextView view, IWpfTextViewMargin margin) { return this; } public UIElement GenerateGlyph(IWpfTextViewLine line, IGlyphTag tag) { if (tag == null || !(tag is ATag)) return null; return new Ellipse { Fill = Brushes.Blue, Height = 16, Width = 16 }; } } internal class ATag : IGlyphTag { } [Export(typeof(ITaggerProvider))] [ContentType("code")] [TagType(typeof(ATag))] class ATagger : ITaggerProvider, ITagger<ATag> { public ITagger<T> CreateTagger<T>(ITextBuffer buffer) where T : ITag { return this as ITagger<T>; } IEnumerable<ITagSpan<ATag>> ITagger<ATag>.GetTags(NormalizedSnapshotSpanCollection spans) { return from span in spans where span.GetText().Contains("a") select new TagSpan<ATag>(span, new ATag()); } public event EventHandler<SnapshotSpanEventArgs> TagsChanged; } }
July 10, 2014
Simplest Margin Glyph
Leave a Comment »
No comments yet.
Leave a comment