Outlook Bar for CAB - activate default button

Topics: CAB & Smart Client Software Factory
Dec 26, 2006 at 8:36 AM
originally posted by: ChrisBednarski

Is there a way to activate the first button of the Outlook Workspace after Shell has loaded all dependent modules?

Assume this scenario.
1. Shell loads 3 modules.
2. Each module adds one (or more) SmartPart(s) to Outlook Workspace.

Since each module is independent and could be loaded in any sequence, where should the first button be activated from?
shell? module itself? I'm confused.

TIA,
Chris
Dec 27, 2006 at 8:25 AM
originally posted by: JuanArg

Hi,
I think this code should be placed in the Shell.
As modules are independent and pluggable you don’t know which of your modules will be actually loaded.
I think ModuleLoaded event of the ModuleLoaderService is a good approach for this task.
I hope this example helps you. It just activates the first view added to the SmartParts collection.
If you need a more complex approach I recommend you firing an EventTopic to which Modules can subscribe.

protected override void AfterShellCreated()
{
base.AfterShellCreated();

IModuleLoaderService loader = RootWorkItem.Services.Get<IModuleLoaderService>();
loader.ModuleLoaded += new EventHandler<DataEventArgs<LoadedModuleInfo>>(loader_ModuleLoaded);
}

void loader_ModuleLoaded(object sender, DataEventArgs<LoadedModuleInfo> e)
{
OutlookBarWorkspace leftWorkspace = RootWorkItem.WorkspacesWorkspaceNames.LeftWorkspace as OutlookBarWorkspace;
if (leftWorkspace != null && leftWorkspace.SmartParts.Count > 0 && leftWorkspace.ActiveSmartPart != leftWorkspace.SmartParts0)
{
leftWorkspace.Activate(leftWorkspace.SmartParts0);
}
}

Juan Arguello
http://staff.southworks.net/jarguello