Current Line Highlighting - DisplayItemClassificationTypeProvider

SyntaxEditor for WPF Forum

Posted 7 years ago by Mick George - Software Engineer, CNC Software, Inc.
Version: 12.1.0560
Avatar

I have a language that implements current line highlighting style as shown in the code below taken from my language constructor and this works as expected.

// Create a custom registry
IHighlightingStyleRegistry registry = new HighlightingStyleRegistry();
registry.Description = this.Key;

// hook up current line highlighting to this registry
DisplayItemClassificationTypeProvider providertypes = new DisplayItemClassificationTypeProvider(registry);
providertypes.RegisterAll();

registry.Register(providertypes.CurrentLine, new HighlightingStyle(), false);

 

When a file of this language type is opened or created the language's HighlightingStyleRegistry is retrieved and assigned to the documents language as shown below. This works as expected.

// Set the language after everything's loaded
ISyntaxLanguage language = this.LanguageManager.LoadLanguage(this.CodeDocumentModel.LanguageKey);
editor.Document.Language = language;
 
// Get the IHighlightingStyleRegistry for this language.
SyntaxLanguageBase languageBase = language as SyntaxLanguageBase;
editor.HighlightingStyleRegistry = languageBase.GetHighlightingStyleRegistry();

// Set colors from user options
this.UpdateHighlightingStyleRegistryCurrentline(editor);

 

The user can specify what colors to use for line highlighting and the code for setting those values is shown below.

        /// <summary>
        /// Update syntax editor <c>IHighlightingStyle</c> property current line highlighting.
        /// </summary>
        /// <param name="editor">The syntax editor</param>
        /// <remarks>Applies to all documents regardless of language type</remarks>
        public void UpdateHighlightingStyleRegistryCurrentline(SyntaxEditor editor)
        {
                IClassificationType type = editor.HighlightingStyleRegistry["CurrentLine"];
                IHighlightingStyle highlightingStyle = editor.HighlightingStyleRegistry[type];
                highlightingStyle.Background = this.optionsFontsAndColors.CurrentLineHighlightBackground;
                highlightingStyle.BorderBrush = this.optionsFontsAndColors.BorderBrush;
        }

The code above appears to work as expected, each value assigned is updated accordingly. However, when a document is displayed the current line highlighting appears to be using the default Actipro values, i.e. light grey border and no background color but as soon as I right click in the view to invoke a context menu then left click back into the view the users current line highlighting colors are used. I am not sure what I am missing?

Comments (5)

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Mick,

So does it just seem like the editor isn't refreshing properly immediately following the programmatic change but if you move the caret to a new line it does update appropriately?


Actipro Software Support

Posted 7 years ago by Mick George - Software Engineer, CNC Software, Inc.
Avatar

That was my first thought, however, clicking around the view and typing, adding line, deleting etc do not cause an update the only things that do are switching tabs to another document and then switching back or invoking a context menu, it does seem a little odd. I am trying to see of there is something else I am doing that might be causing this but so far I can't see anything. I think my next approach is to try and replicate it in a small test project.

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Ok that would be most helpful.  Please email it over and we'll check it out.  Hopefully we can find a workaround or resolution for you before the upcoming maintenance release.


Actipro Software Support

Posted 7 years ago by Mick George - Software Engineer, CNC Software, Inc.
Avatar

Bill, I believe I was able to reproduce the issue in an example project, I have since mailed it to you. 

Thanks for taking a look,

Mick

Answer - Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Mick,

Thanks for the sample, we've fixed it for the next build. You may be able to work around it until the next build by toggling the current line highlighting feature on/off after your change.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.