Help with TabWorkspace

Topics: CAB & Smart Client Software Factory
May 11, 2007 at 1:52 PM
i am using a tabworkspace in my main window. as a workitem is invoked its smartparts are shown on a new tabpage. my application also creates menuitems particular to each workitem. my problem is when a user invokes several workitems (which creates several tabpages and uielements) how do i determine the active tabpage (containing a particular view) and be able to unregister or deactivate uielements that do not apply to the active tabpage, and put a caption on each tabpage that pertains to the workitem.

thanks in advance
May 11, 2007 at 6:30 PM
I had similar req in my project unfortunately i didnot see any way to disable the ui items.In our archieture we have ShellService to build all the menus for all the modules and workitem.So it was easy for Shell Service to store the reference of the UIElement(ToolMenuItem) in a hastable with modulename ,workitemid and ToolMenuItem reference as a key.Depends on the active module or workitem ShellService will pull all the menus for the workitem and make it enable.I donno if this helps you.

Thnx
Mani
May 14, 2007 at 8:11 AM
i f possible may i have sample code so that i may follow.

Thanks
Joel
May 14, 2007 at 8:42 PM

//This method adds the toolbar to the shell

public void AddToolbarItem(string name, string toolbarText, string imageString, string siteName, string commandName, bool addSeperator)
{
ToolStripSeparator separator = null;
ToolStripItem toolButton = null;// (ToolStripItem)(uiElement.IsDropDown ? (new ToolStripDropDownButton(toolbarText)) : new ToolStripButton(toolbarText));
if (!uiElement.IsDropDown)
{
toolButton = new ToolStripMenuItem(toolbarText);
}
else
{
toolButton = new ToolStripDropDownButton(toolbarText);
}
toolButton.Name = name;
toolButton.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
toolButton.Image = (Image)Properties.Resources.ResourceManager.GetObject(imageString);
this.iLevelWorkItem.UIExtensionSitessiteName.Add(toolButton);
this.iLevelWorkItem.UIExtensionSites.RegisterSite(name, toolButton);
//toolbars is the hastable that stores the reference of the toolbutton with button name as key
toolbars.Add(toolButton.Name,toolButton);
AddCommandHandler(toolButton, commandName, ControlEvents.Click, iLevelWorkItem);
this.uiElement = null;
}


//This method Enable or Disable the toolbar

private void EnableDisableToolbar(bool enable, params string[] toolbarItems)
{
foreach (string toolbarItem in toolbarItems)
{
if (toolbars.ContainsKey(toolbarItem))
{
((ToolStripItem)toolbarstoolbarItem).Enabled = enable;
}
}

}


Both this methods are avaliable in the ShellService which is the rootlevel service avaliable for all the modules.


Thnx
Mani