MDI Bar Merging
- 5 minutes to read
You can implement MDI mode in your applications using the DocumentGroup and DocumentPanel objects. The DocumentGroup will be a container for individual windows/panels (DocumentPanel objects).
The Toolbar-Menu library allows you to add menus and bars to your application. You can create bars at the root level and for individual DocumentPanel objects at the same time. For instance, the menu at the root level can provide general commands for working with files, windows, etc, while a child window (panel) can have bars and menus providing specific functionality.
When your application contains menus and bars at the root level and within individual DocumentPanel objects, the bar merging feature is supported.
With the bar merging feature, child menus and bars are merged into the parent menus and bars, as specified by the bar's settings.
Menus and bars are implemented using a BarManager control, which is a container for all bar objects. To define bars at the root level, you need to define a BarManager object at the root level (In the text below we'll refer to it as the parent BarManager). To define bars within a DocumentPanel, you need to define a separate BarManager within this panel. We'll refer to it as the child BarManager.
The merging mechanism merges menus and bars of a child BarManager into the menus and bars of a parent BarManager. The unmerge mechanism restores the previous layout.
#The Merging Mechanism
The merging mechanism is invoked:
- in regular MDI mode, when a DocumentPanel is maximized.
- in tabbed MDI mode, when a tab (DocumentPanel) is activated.
The unmerge mechanism is invoked:
- in regular MDI mode, when a DocumentPanel is restored from the maximized to the normal state or before another DocumentPanel is maximized.
- in tabbed MDI mode, when a tab (DocumentPanel) is deactivated (for instance, before another tab is selected).
This default behavior can be changed via the DockLayoutManager.MDIMergeStyle property that affects all child panels within a DockLayoutManager. Depending on this property value, you can either completely restrict bar merging, allow merging for activated tabs and maximized MDI panels only, or specify that all currently activated tabs and maximized MDI panels should be merged at the same time. To specify the merging behavior for individual panels, use the DocumentPanel.MDIMergeStyle attached property instead. This property has a higher priority than the DockLayoutManager.MDIMergeStyle property.
#Automatic and Manual Bar Merging
Automatic merging/unmerging is supported for main menus. Other bars need to be merged and unmerged manually. For this purpose, you can handle the DockLayoutManager.Merge and DockLayoutManager.UnMerge events. The latter allows you to undo the results of the manual merge operation you performed via the DockLayoutManager.Merge event handler.
To merge two bars that belong to different BarManagers, call the parent bar's Bar.Merge method. Call Bar.UnMerge to restore the original links layout for the bar, after the merge operation.
Similarly, use ILinksHolder.Merge and ILinksHolder.UnMerge methods to perform merging operations on link containers (e.g. submenu).
#Links Merging Types
During merging, you can specify whether the bar item links of a child BarManager's bar/link container should be added to the parent BarManager's bar/link container (this is the default behavior), should replace item links on the parent bar with identical captions or should simply be removed from a bar.
To specify these settings, use the BarItemLinkBase.MergeType properties of the child BarManager's links that need to be merged. Note that the settings for the parent BarManager's links may also need to be changed in specific cases, to get the desired behavior (see the table below which illustrates the available merging techniques):
Bar |
Description |
---|---|
Add | Specifies that the child Bar |
Merge |
This setting is applied to link containers (e. |
Remove | For a child Bar |
Replace | Indicates that the child Bar |
When adding items during a merge operation, the original links of a parent BarManager and the new links of the child BarManager are arranged according to their BarItemLinkBase.MergeOrder property values. Links with the lowest MergeOrder come first. The last links will be those that have the greatest MergeOrder value. If a parent BarManager's bar has links with MergeOrder equal to the MergeOrder of a child BarManager's link, then the child BarManager's link will be placed after all the parent BarManager's matching links.