0

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?

闇Yami
  • 43
  • 8
  • I don't get the `if it is not red, then make it red`. At the end all words will be red. If you want to colorize word, maybe [this answer](https://stackoverflow.com/a/62947791/361177) can help you. – Orace Dec 27 '21 at 14:57
  • @Orace, what am i trying to do is i wanna make them a red one by one after clicking one button. But it wont be red if someone doesn't hit the button. I've tried that it changes every same text into a same color if selected text is a existed more than one. Is there any way to identify word one by one and then making it red one by one? – 闇Yami Dec 27 '21 at 15:22
  • "wanna make them a red one by one" - what does that mean, exactly? – Jim Foye Jan 05 '22 at 16:08

0 Answers0