SCSF - How to add items to "File" ToolStripMenuItem

Topics: CAB & Smart Client Software Factory
Jan 28, 2007 at 11:10 PM
Reference implementations AppraiserWorkbench and BankBranchWorkbench have a "File" ToolStripMenuItem that is defined under:
-> Infrastructure
- -> Shell
- - -> ShellForm.cs
as _fileToolStripMenuItem that is private.

Creating my own Smart Client solution using SCSF Guidance reproduces the same result. After creating a module, I'm suppose to add menu items under ExtendMenu() on ModuleController.cs.

ToolStripMenuItem _printToolStripMenu = new ToolStripMenuItem();
_printToolStripMenu.Text = "&Print";
_printToolStripMenu.ShortcutKeys = ((Keys.Alt | Keys.E));
MyApplication.Infrastructure._fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { _printToolStripMenu });

Of course the compiler reports:
MyApplication.Infrastructure.Layout.ShellLayoutView' does not contain a definition for '_fileToolStripMenuItem

How shall I do it?
Jan 30, 2007 at 10:57 AM
Change the _fileToolStripMenuItem modifier to public, it will works.

Also, wich you can do is to register the Items collection of your file menu like this.

//Registramos la colección de Items del menú de herramientas.
WorkItem.UIExtensionSites.RegisterSite(UIExtensionSiteNames.FileMenuItems, View._fileStripMenuItem.DropDownItems);

And then you can register your _printMenuItem like this.

WorkItem.UIExtensionSitesUIExtensionSiteNames.FileMenuItems.Add(_printMenuItem);

I hope having helped you.

Best Regards
Jan 31, 2007 at 12:16 AM
Edited Feb 5, 2007 at 12:46 AM
Gracias por tu ayuda RoTTeN! You did point me the right direction.

The full story goes like this:

1-Create constant
Project: Infrastructure.Interface (under Infrastructure)
File: UIExtensionSiteNames.cs (under Constants)
Add:
/// <summary>
/// The extension site for File menu items.
/// </summary>
public const string FileMenuItems = "FileMenuItems";

2-Define internal property
Project: Infrastructure.Layout (under Infrastructure)
File: ShellLayoutView.cs
Add:
internal ToolStripMenuItem FileToolStripMenuItem
{
get { return _fileToolStripMenuItem; }
}

3-Register UI Extension Site
Project: same
File: ShellLayoutViewPresenter.cs
Method: OnViewSet()
Add:
WorkItem.UIExtensionSites.RegisterSite(UIExtensionSiteNames.FileMenuItems, View.FileToolStripMenuItem.DropDownItems);

4-Create the Print item on File menu
Project: MyModule
File: ModuleController.cs
Method: ExtendMenu()
Add:
ToolStripMenuItem _printToolStripMenu = new ToolStripMenuItem();
_printToolStripMenu.Text = "&Print";
_printToolStripMenu.ShortcutKeys = ((Keys.Control | Keys.P));
WorkItem.UIExtensionSites"FileMenuItems".Add(_printToolStripMenu);
Jan 31, 2007 at 6:40 AM
De nada, me alegro de haberte ayudado. :)
Feb 5, 2007 at 12:46 AM
The January 31 post assumes you have checked "Create a separate module to define the layout for the shell" when creating the Smart Client Solution.

If you didn't check it, there are some differences

2-Define internal property
Project: Shell (under Infrastructure)
File: ShellForm.cs
Add:
internal ToolStripMenuItem FileToolStripMenuItem
{
get { return fileToolStripMenuItem; }
}

3-Register UI Extension Site
Project: same
File: ShellApplication.cs
Method: AfterShellCreated()
Add:
RootWorkItem.UIExtensionSites.RegisterSite(UIExtensionSiteNames.FileMenuItems, this.Shell.FileToolStripMenuItem.DropDownItems);