Enumerate and activate IDE views
- Last UpdatedJul 23, 2024
- 1 minute read
Because of extensible architecture of the IDE, its extensions do not really know about each other and ideally they should be able to work without being tightly coupled with each other. This might necessitate extensions to know what other IDE views are available and to activate a specific one of its interest programmatically. The IDE provides functionality in the form of a service to enumerate all IDE views and activate a specific one. Wonderware extensions use this functionality internally for various operations like create instance, create derived template, rename AutomationObject and so on. Following is an example of how an extension can leverage this service and find out a view that support in-place renaming and activate it.
private bool ActivateRightView()
{
bool bCanInPlaceRename = false;
IaaPluginWindows windows =
m_site.Services[typeof(IaaPluginWindows)] as
IaaPluginWindows;
if(windows != null)
{
IaaPluginWindow activeWindow = windows.ActiveWindow;
if(activeWindow != null)
{
IaaIDEView ideView = activeWindow.Window as IaaIDEView;
if(ideView != null)
{
bCanInPlaceRename = ideView.CanInPlaceRename();
if(bCanInPlaceRename)
{
activeWindow.Activate();
}
else
{
foreach(IaaPluginWindow wnd in windows)
{
IaaIDEView view = wnd.Window as IaaIDEView;
if(view != null)
{
bCanInPlaceRename = view.CanInPlaceRename();
if(bCanInPlaceRename)
{
wnd.Activate();
break;
}
}
}
}
}
}
}
return bCanInPlaceRename;
}