How can I tell which project is active?

Hi all -

I have a need to find out something about the active project, which I define as either:

- the project I'm currently creating, if I'm in the "New Project" dialog

- the project that I edit if I press the "Project Settings" button on the top ribbon, if I'm anywhere else

How do I find this out reliably in the API? My first idea was to retrieve the ProjectsController as follows:

ProjectsController c = SdlTradosStudio.Application.GetController<ProjectsController>();

and then grab the CurrentProject; but this is not necessarily the project that I'm lookin at in the project settings window. My next idea was to grab the first element from the SelectedProjects list; but this may be empty if no project is selected in the projects list. And if it IS selected, it's not the project in the New Project dialog, for obvious reasons.

If it's not possible to find the active project as I define it above, is it possible to figure out what view or dialog is active? That is, can I tell whether I'm in the New Project dialog, or in the Projects or Files views?

Thanks in advance -

Sam Bayer