How to change a color of each entered word in Avalon Edit WPF

252 Views Asked by At

What am i trying to do is "check color of every single entered word" and then change it into color one by one. For example default color is a black (then check color of words if its not a red change it into red but a word by word each of them).

I've tried this but it is changes specific line color, not exactly what am i finding one.

 class LineColorizer : DocumentColorizingTransformer
    {
        int LineNumber;
        public LineColorizer(int lineNumber)
        {
            LineNumber = lineNumber;
        }
        protected override void ColorizeLine(ICSharpCode.AvalonEdit.Document.DocumentLine line)
        {
            
            if (!line.IsDeleted && line.LineNumber == LineNumber)
            {
                ChangeLinePart(line.Offset, line.EndOffset, ApplyChanges);
            }
        }
        void ApplyChanges(VisualLineElement element)
        {
            element.TextRunProperties.SetForegroundBrush(Brushes.Red);
        }
    }
            var line = rtb.Document.GetLineByNumber(3);
            rtb.TextArea.TextView.LineTransformers.Add(new LineColorizer(3));

How to accomplish something like this?

0

There are 0 best solutions below