
On Editor_Changed when there is no selection I collect the textrange of the current block of xml and change the background to a pale colour.
To accomplish this I use HighlightingStyleSpanIndicator but my problem is the nicely colored font of xml attributres are also changed.
//Control Init
editor.Document.SpanIndicatorLayers.Add(_spanIndicatorBlockHighlight);
_spanIndicatorBlockHighlightingStyle = new HighlightingStyle(_spanIndicatorBlockHighlightName, "res:Block Highlight Style", Color.Empty, SystemColors.Control);
// How can I only change the textrange background color without affecting forecolor?
void editor_SelectionChanged(object sender, SelectionEventArgs e)
{
editor.Document.SpanIndicatorLayers[_spanIndicatorBlockHighlightName].Clear();
if (e.Selection.IsZeroLength)
{
//highlight the block
editor.Document.SpanIndicatorLayers[_spanIndicatorBlockHighlightName].Add(
new HighlightingStyleSpanIndicator("HSS", _spanIndicatorBlockHighlightingStyle), MyTextRange);
}
}
[Modified 11 years ago]