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

Parents
No Data
Reply
  • First, I said "please", and I meant it. I didn't intend to be rude, and I don't think I was. You've spent multiple replies correcting my terminology and not answering my question.

    As you say, the project that Trados judges to be "active" is the CurrentProject in the ProjectsController, and those projects which are selected in the Projects view are the SelectedProjects.

    When I'm in the Browse() method of a ITranslationProviderWinFormsUI, I can get access to the ProjectsController, and there are frequently both a CurrentProject and a single item in the SelectedProjects list. However, depending on how the user got to the Browse() method, the user may be editing the settings for either the CurrentProject or the single item in the SelectedProjects list (or, as I said originally, the settings for a new project which, as you say, is not yet an actual project object). Does the Trados API permit me to distinguish between these cases?

    At the moment, I can find only one method: use reflection to digest the title of the project settings window and match its name to the known projects. But I have a hard time believing that's the right way to do it.
Children