Hi,
I have develop a custom tagger in order to format some specific words.
My problem is that the format is applying to this words even if they are used as strings (inside quotes).
I would like that the format only applies when the word is not in quotes.
In. Ex:
WORD -> Apply Format
"WORD" -> Do not apply format
This is my code:
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using AutoMapper.Internal;
using Telerik.WinControls.UI;
using Telerik.WinForms.Controls.SyntaxEditor.Taggers;
using Telerik.WinForms.Controls.SyntaxEditor.UI;
using Telerik.WinForms.SyntaxEditor.Core.Tagging;
namespace Simulation.UX.Forms.Controls.Neptune
{
public class CustomTagger : CSharpTagger
{
public static readonly ClassificationType CustomClassificationType = new("Custom");
public static readonly Dictionary<string, ClassificationType> WordsToClassificationType = new();
public static readonly TextFormatDefinition Format = new(new SolidBrush(Color.DarkGoldenrod));
private readonly List<string> _words;
public NeptuneTagger(RadSyntaxEditorElement editor, List<string> words) : base(editor)
{
_words = words;
}
protected override Dictionary<string, ClassificationType> GetWordsToClassificationTypes()
{
Dictionary<string, ClassificationType> baseTypes = base.GetWordsToClassificationTypes();
_words?.ForAll(w =>
{
if (!baseTypes.ContainsKey(w))
{
baseTypes.Add(w, CustomClassificationType);
}
});
return baseTypes;
}
}
}