logo

Items of the application ribbon (tool bar and status bar)

Ribbon control service

To add items to the control panel of the work items inherited or subordinate to RibbonChapterWorkItem, the IRibbonExtensionService service is available:

namespace EleWise.ELMA.Design.CompositeUI.Services
{
 
/// <summary>
/// Extension service for the visual elements of the ribbon linked to the current section
/// </summary>
public interface IRibbonExtensionService
{
 
/// <summary>
/// Ribbon tool bar
/// </summary>
RibbonPanel RibbonPanel
{
get;
}
 
/// <summary>
/// Command binding which associates commands with controls
/// </summary>
CommandBinder CommandBinder
{
get;
}
 
/// <summary>
/// Add ribbon toolbars included in the specified control type  
/// </summary>
/// <typeparam name="TControl">Control type which includes ribbon tool bars </typeparam>
void AddRibbonBars<TControl>()
where TControl : Control;
 
/// <summary>
/// Add ribbon toolbars which are included in the specified control
/// </summary>
/// <param name="control"> Control type which includes ribbon tool bars </param>
void AddRibbonBars(Control control);
 
/// <summary>
/// Add ribbon toolbar
/// </summary>
void AddRibbonBar(RibbonBar bar);
 
/// <summary>
/// Add items to the status bar
/// </summary>
/// <param name="items">Items</param>
void AddStatusBarItems(BaseItem[] items);
 
/// <summary>
/// Make a layout of the visual items (for the correct display after changing the items)
/// </summary>
void PerformLayout();
 
}
 
}

The RibbonExtensionService property of the work items, inherited from RibbonChapterWorkItem, becomes available after initializing the work item.

To gain access to the service of the items that are subordinate to RibbonChapterWorkItem or its heir, you must import the service, declaring the property:

/// <summary>
/// Import the control service of the ribbon
/// </summary>
ServiceDependency
public IRibbonExtensionService RibbonExtensionService
{
get;
set;
}

Adding items to the toolbar

To add items to the toolbar you need to:

  1. Create UserControl (for example NewModuleRibbonPanel).
  2. Place bars (DevComponents.DotNetBar.RibbonBar) and buttons (DevComponents.DotNetBar.ButtonItem) in the UserControl.
  3. If necessary, define commands and settings for the toolbars (in the Tag property) and for the buttons (in the CommandParameter property). Separate parameters from the command names with a semicolon. For example, SetZoom; 100.

Register items through the method RibbonExtensionService.AddRibbonBars <NewModuleRibbonPanel>().

Adding items to the status bar

To add items to the status bar, create necessary items in the code and register them through the service:

zoomSpace = new LabelItem();
zoomSpace.Name = "lblOrgZoomSpace";
zoomSpace.Text = "";
zoomSpace.Stretch = true;
zoomSpace.CommandParameter = OrganizationCommands.Zoom.Group;
zoomSlider = new SliderItem();
zoomSlider.Name = "slOrgZoom";
zoomSlider.Width = 155;
zoomSlider.LabelWidth = 55;
zoomSlider.LabelVisible = true;
zoomSlider.Text = "100 %";
zoomSlider.Visible = true;
zoomSlider.CommandParameter = OrganizationCommands.Zoom.SetZoom;
zoomSlider.Minimum = 20;
zoomSlider.Maximum = 200;
zoomSlider.Value = 100;
RibbonExtensionService.AddStatusBarItems(new BaseItem[] { zoomSpace, zoomSlider });