0
votes

Background

Let's say I have a custom task pane like the one in the image below.

For my app, I only display this pane if the user is logged in (determined by the presence of a valid session token that was granted from an API endpoint), otherwise I display a log-in pane.

If the user leaves an inspector open when the session times out, I need to show a different task pane with a log in button. The user have many inspectors (and, therefore, many custom task panes) open at once.

I am planning to run a recursive method on a background thread about once per hour to check if the session is valid and, if not, swap any custom task panes that are displayed with a log-in pane.

Question

How do I accomplish a "swap" in each inspector the user has opened? Should I iterate all inspectors? If so, how do I access a collection of custom task panes within that inspector. Conversely, if I should iterate Globals.ThisAddIn.CustomTaskPanes, how do I identify the inspector it belongs to so that I can swap any visible custom task pane with my log-in pane?

Thanks in advance. enter image description here

1

1 Answers

1
votes

You need to keep a dictionary where the key will be an inspector object. So, that you can get access to the custom task pane easily.

       InspectorWrapper inspectorWrapper = Globals.ThisAddIn.InspectorWrappers[inspector];
        CustomTaskPane taskPane = inspectorWrapper.CustomTaskPane;
        if (taskPane != null)
        {
            taskPane.Visible = false;
        }

Take a look at the following articles for more information: