Unregister Adornment Service

SyntaxEditor for WPF Forum

Posted 12 years ago by Nick Beer - National Instruments
Version: 11.1.0545
Avatar
Hello -

I have registered an IAdornmentManagerProvider for my language, and under some circumstances, I'd like to be able to remove that service. However, I've noticed that when I remove the service my IAdornmentManager is not closed. This causes my adornments to remain.

How do you recommend removing an adornment service, ensuring the adornments are no longer drawn?

Thanks -

Nick

Comments (5)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Nick,

In your AdornmentManager, you can probably do this to remove them:
protected override void OnClosed() {
    // Remove any remaining adornments
    this.AdornmentLayer.RemoveAllAdornments();
}


Actipro Software Support

Posted 12 years ago by Nick Beer - National Instruments
Avatar
Hmm... I guess that's the problem. When I call UnregisterService, the OnClosed handler in my AdornmentManager is not called. Do you expect that it should be?

Nick
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Nick,

You'd probably need to get the IAdornmentManager for the ITextViews you have open and call Close() on each one before unregistering the service.

The language service doesn't hold any ties to SyntaxEditors or views so it doesn't know how to have a CloseAll() sort of concept, because it wouldn't know which views are still active.


Actipro Software Support

Posted 12 years ago by Nick Beer - National Instruments
Avatar
OK, thanks. I've done that and have been able to unregister and remove my adornments. However, now I'm unable to turn them on again at a later time. It seems that the AdornmentManagerProvider must be registered in the constructor of the SyntaxLanguage?

Anyhow, I've worked around it by just setting a flag in the AdornmentManager. It seems that it would be preferable to simply register and unregister these services, but it doesn't appear you support that for now.

Nick
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Nick,

Correct, the manager provider doesn't know if it's been registered on a language and what views may be using those languages. You could just call the provider.GetAdornmentManager(view) method on any view that should receive an adornment manager again. I believe that will register it.

But if you will be toggling things, then it may be preferable to just flag whether adornments should be displayed or not and leave the adornment managers in place.


Actipro Software Support

The latest build of this product (v24.1.2) was released 3 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.