You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Unable to render {include} The included page could not be found.

Introduction
To extend menu and toolbar of DelftShell some interfaces are added to DelftTools (ICommand, IMenuItem, IToolBar, part of IMainWindow). Implementations of these interfaces can be found in
DelftShell.Gui.Forms.MenuItem,
DelftShell.Gui.Forms.ToolBar,
DelftShell.Gui.Forms.ToolBarManager and
DelftShell.Gui.Forms.MainWindow.MainWindow (DelftShell).

A typical use of these classes is (see DelftShell.Tests.Gui.MenuManagerTest.BasicInterfaceTest):

IToolBar toolbar = MainWindow.CreateToolBar();
toolbar.Name = "toolbar";
toolbar.Text = "toolbar";
MainWindow.Toolbars.Add(toolbar);

ZoominCommand zoominCommand = new ZoominCommand("zoomin");

IMenuItem menuItem = MainWindow.CreateMenuItem();
menuItem.Name = "buttonToolBarZoomin";
menuItem.Text = "&Zoomin";
menuItem.Command = zoominCommand;
toolbar.Add(menuItem);

Please refer to apps\DelftShell\test\DelftShell.Tests\Gui\MenuManagerTest.cs for more examples.

configuring via xml
To simplify the use of these interfaces a xsd is developed that defines an extentention to the User Interface. xml based on this xsd can be processed by the PluginConfigurationSectionHandler class.

The plugin config file
During startup DelftShell will scan the plugins' configuration file for a section "plugin". The xml code in this section will be processed by the DelftTools.Gui.PluginConfigurationSectionHandler class. The PluginConfigurationSectionHandler will build an internal data structure that is translated by the PluginConfigurator into the actual toolbars and menus.

To implement this scenario

  • Add a config file to the plugin if not already available (Add New Item - Application configuration file)
  • To <configuration> add a section <configSections> and add in this a section with name "plugin"
    and type="DelftTools.Gui.PluginConfigurationSectionHandler, DelftTools.Gui"
    example:
    <configSections>
    <section name="plugin" type="DelftTools.Gui.PluginConfigurationSectionHandler, DelftTools.Gui" />
    </configSections>
  • Add a plugin section with contains the xml to extend the UI.
  • Modify the afterbuild event to copy the app.config file to plugin.dll.config
    copy "$(TargetDir)*.dll.config" "$(SolutionDir)apps\DelftShell\modules\DelftShell.Loader\bin\plugins\$(ProjectName)\"

Images
PluginConfigurator supports three sources for images.

Globalresource
PluginConfigurator will will load images that start with globalresource: from the DelftShell resources (right click apps\delftshell\modules\DelftShell properties\Resources\Images).

Localresource
PluginConfigurator will will load images that start with localresource: from the plugin resources (e.g. right click apps\delftshell\test\TestPlugin1 properties\Resources\Images).

File
PluginConfigurator will load all non resource images from file, no special prefix is used. The path used is the location of the plugin binary.

Example (see App.config for TestPlugin1)
<commands>
<!-- command id="TestCommand" text="&LocalResourceImage" image="localresource:chart_bar" category="Test Plugin"/ -->
<command id="TestCommand" text="&LocalResourceImage" category="Test Plugin"/>
<command id="NewTestViewCommand" text="&GlobalResourceImage" image="globalresource:bug" category="Test Plugin"/>
<command id="AnotherTestCommand" text="&FileImage" image="Resources\test.png" category="Test Plugin"/>
</commands>

Point of interest
Name
Name is the unique identifier for menu, toolbar and menuitem. Duplicate names will generate an error.

Debugging
If DelftShell is compiled in debug mode an extra menu option is available at Debug - Write UI &Dump File
This will dump info of the menu and toolbars in use to 'DelftShellUIDump'. Please note that also info on all docked windows and attached views is dumped.

  • No labels