Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt Lacey mrlacey

View GitHub Profile
View FestiveImageTag.cs
internal class FestiveImageTag : ITag
{
public FestiveImageTag(string term)
{
this.Term = term;
}
public string Term { get; }
}
View FestiveImageTagger.cs
internal sealed class FestiveImageTagger : RegexTagger<FestiveImageTag>
{
internal FestiveImageTagger(ITextBuffer buffer)
: base(
buffer,
new[] { new Regex(@"\W(\w{3,7})\W", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase) })
{
}
protected override FestiveImageTag TryCreateTagForMatch(Match match)
View FestiveImageTaggerProvider.cs
[Export(typeof(ITaggerProvider))]
[ContentType("text")]
[TagType(typeof(FestiveImageTag))]
internal sealed class FestiveImageTaggerProvider : ITaggerProvider
{
public ITagger<T> CreateTagger<T>(ITextBuffer buffer)
where T : ITag
{
if (buffer == null)
{
View FestiveImageAdornment.cs
internal sealed class FestiveImageAdornment : System.Windows.Controls.Image
{
internal FestiveImageAdornment(FestiveImageTag tag)
{
this.FestiveImageTag = tag;
this.SetSource(this.FestiveImageTag.Term);
this.Height = 20;
this.Width = 20;
}
View FestiveImageAdornmentTagger.cs
internal sealed class FestiveImageAdornmentTagger
: IntraTextAdornmentTagger<FestiveImageTag, FestiveImageAdornment>
{
private readonly ITagAggregator<FestiveImageTag> tagger;
private FestiveImageAdornmentTagger(IWpfTextView view, ITagAggregator<FestiveImageTag> tagger)
: base(view)
{
this.tagger = tagger;
}
View FestiveImageAdornmentTaggerProvider.cs
[Export(typeof(IViewTaggerProvider))]
[ContentType("text")]
[ContentType("projection")]
[TextViewRole(PredefinedTextViewRoles.Document)]
[TagType(typeof(IntraTextAdornmentTag))]
internal sealed class FestiveImageAdornmentTaggerProvider : IViewTaggerProvider
{
[Import]
internal IBufferTagAggregatorFactoryService BufferTagAggregatorFactoryService;
View FestiveEditorTextViewCreationListener.cs
public void TextViewCreated(IWpfTextView textView)
{
// The adorments will get wired to the text view events
new MistletoeAdornment(textView);
new TopLeftHollyAdornment(textView);
new TopRightHollyAdornment(textView);
new BottomLeftHollyAdornment(textView);
new BottomRightHollyAdornment(textView);
}
View hollyadornments.cs
// TopLeftHollyAdornment
// Place the image in the top left of the Viewport
Canvas.SetLeft(this.image, this.view.ViewportLeft);
Canvas.SetTop(this.image, this.view.ViewportTop);
// TopRightHollyAdornment
// Place the image in the top right of the Viewport
@mrlacey
mrlacey / MistletoeAdornment.cs
Last active Nov 17, 2020
FestiveEditor - 4
View MistletoeAdornment.cs
using System;
using System.IO;
using System.Reflection;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using Microsoft.VisualStudio.Text.Editor;
namespace FestiveEditor
{
internal sealed class MistletoeAdornment
View FestiveEditorTextViewCreationListener_3.cs
public void TextViewCreated(IWpfTextView textView)
{
new MistletoeAdornment(textView);
}
You can’t perform that action at this time.