Tried extending the a custom tooltip tagger to recognize multiple words/tooltips but no luck. Below is my custom tooltip tagger, any thoughts on where I am going wrong?
using System.Collections.Generic;
using Telerik.Windows.SyntaxEditor.Core.Editor;
using Telerik.Windows.SyntaxEditor.Core.Tagging;
using Telerik.Windows.SyntaxEditor.Core.Text;
namespace QuickMeasuresPro
{
class DAXTooltipTagger : TaggerBase<ToolTipTag>
{
private string searchWord;
private static readonly string[] Keywords = new string[]
{
"APPROXIMATEDISTINCTCOUNT","AVERAGE","AVERAGEA","AVERAGEX"
};
private static readonly string[] Tooltips = new string[]
{
"APPROXIMATEDISTINCTCOUNT(<columnName>)\r\nReturns the approximate number of rows that contain distinct values in a column.",
"AVERAGE(<column>)\r\nReturns the average (arithmetic mean) of all the numbers in a column.",
"AVERAGEA(<column>)\r\nReturns the average (arithmetic mean) of the values in a column.",
"AVERAGEX(<table>,<expression>)\r\nCalculates the average (arithmetic mean) of a set of expressions evaluated over a table.",
};
public DAXTooltipTagger(ITextDocumentEditor editor)
: base(editor)
{
}
public override IEnumerable<TagSpan<ToolTipTag>> GetTags(NormalizedSnapshotSpanCollection spans)
{
if (string.IsNullOrEmpty(this.searchWord))
{
yield break;
}
TextSnapshot snapshot = this.Document.CurrentSnapshot;
foreach (TextSnapshotSpan snapshotSpan in spans)
{
string lineString = snapshotSpan.GetText();
int i = 0;
foreach (string keyword in Keywords)
{
string tooltip = Tooltips[i];
i++;
int index = lineString.IndexOf(keyword);
while (index != -1)
{
TextSnapshotSpan tempSnapshotSpan = new TextSnapshotSpan(snapshot,
new Span(snapshotSpan.Start + index, keyword.Length));
yield return new TagSpan<ToolTipTag>(tempSnapshotSpan, new ToolTipTag(tooltip));
index = lineString.IndexOf(keyword, index + keyword.Length);
}
}
}
}
public void UpdateSearchWord(string newSearchWord)
{
this.searchWord = newSearchWord;
this.CallOnTagsChanged(this.Document.CurrentSnapshot.Span);
}
}
}