I've added a LineTransformerClass that is derived from DocumentColorizingTransformer to the TextEditor:
TxtEditCodeViewer.TextArea.TextView.LineTransformers.Add(new ColorizeAvalonEdit());
Is there any programmatic way of invoking invalidation on the Linetransformer?
I've readily assumed that since it is added to the textview, the following should work:
TxtEditCodeViewer.TextArea.TextView.InvalidateVisual();
TxtEditCodeViewer.TextArea.TextView.InvalidateArrange();
TxtEditCodeViewer.TextArea.TextView.InvalidateMeasure();
But they don't. Just in case, I've tried the following as well:
//TxtEditCodeViewer.TextArea.TextView.InvalidateVisual();
//TxtEditCodeViewer.TextArea.TextView.InvalidateArrange();
//TxtEditCodeViewer.TextArea.TextView.InvalidateMeasure();
//TxtEditCodeViewer.InvalidateVisual();
//TxtEditCodeViewer.InvalidateArrange();
//TxtEditCodeViewer.InvalidateMeasure();
//TxtEditCodeViewer.TextArea.InvalidateArrange();
//TxtEditCodeViewer.TextArea.InvalidateMeasure();
//TxtEditCodeViewer.TextArea.InvalidateVisual();
The text view maintains a cache of the generated visual lines. Forcing WPF to repaint the control just makes it re-use the results in the cache and does not call your line transformer again.
You can use the TextView.Redraw method to invalidate the cached visual lines:
textEditor.TextArea.TextView.Redraw(segment); // invalidate portion of document
textEditor.TextArea.TextView.Redraw(); // invalidate whole document
This works for both ElementGenerators and LineTransformers.
For BackgroundRenderers, it is not necessary to invalidate visual lines. Instead, just tell the text view to invalidate the layer to which your background renderer belongs:
textEditor.TextArea.TextView.InvalidateLayer(this.Layer);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With