Disable my custom DisplayPipeline when my components has preview off

Hello everyone,

I’m new to this forum, and I’m a beginner in both C# and Grasshopper devellopment.
I have created a custom component that displays information in the Rhinoviewport by overriding the method DrawForeground. It works well but I would like to disable my custom DisplayPipeline when my componenent has preview off, is disabled or isn’t in the current active Grasshopper Document.
For now I’ve managed to clear my drawing when the component is deleted by overriding the method RemovedFromDocument.

public override void RemovedFromDocument(GH_Document document) 
{
    myDisplay.Enabled = false;
}

But for the rest, I think I found a way to check if my conditions are met with :

if (this.Hidden | this.Locked | this.OnPingDocument() != Grasshopper.Instances.ActiveCanvas.Document)
{
    myDisplay.Enabled = false;
}

but I don’t know where to put this check. For now, I put it in the SovInstance method and it seems to be working but it’s not really practical as I need to update the inputs to do the checking.
Is there a method that I can override that gets called when my component is changed or when the grasshoper canvas is changed ?
Also is there a way to force a component to have an option thave preview off and on ? The option isn’t not showing if I don’t have an output that can be displayed in the RhinoViewport.