1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| internal class MultiLangTag : SpaceNegotiatingAdornmentTag { public MultiLangTag(double width, double topSpace, double baseline, double textHeight, double bottomSpace, Microsoft.VisualStudio.Text.PositionAffinity affinity, object identityTag, object providerTag) : base( width, topSpace, baseline, textHeight, bottomSpace, affinity, identityTag, providerTag ) { } } internal sealed class MultiLangTagger : ITagger<MultiLangTag> { public MultiLangTagger() { } public event EventHandler<SnapshotSpanEventArgs> TagsChanged;
public IEnumerable<ITagSpan<MultiLangTag>> GetTags(NormalizedSnapshotSpanCollection spans) { if (MyConfig.IsEnable == true) { foreach (var span in spans) { var currentLineText = span.GetText( ); int find = -1; bool isFind = false; string strTranslate = ""; foreach (var item in MyConfig.Dict.Keys) { isFind = currentLineText.IndexOf( item ) > 0; if (isFind) { find = currentLineText.IndexOf( item ); strTranslate = MyConfig.Dict[item]; break; }; }
if (find > -1) { yield return (ITagSpan<MultiLangTag>)new TagSpan<MultiLangTag>( new SnapshotSpan( span.Snapshot.TextBuffer.CurrentSnapshot, (Span)span ), new MultiLangTag( 0.0, (double)MyConfig.FontSize * 1.2, 0.0, 0.0, 0.0, PositionAffinity.Predecessor, (object)null, (object)null ) ); } }
} } }
|