Nevron Open Vision Documentation
Command Bars
Schedule Command Bar Builder

NOV Schedule provides a command bar builder that can be used to create some menus and toolbars to control and edit the schedule and its appointments. This builder is represented by the class NScheduleCommandBarBuilder. The following code fragment demonstrates how to create a command bar based commanding UI and associate it with a schedule view:

Create Command Bars UI
Copy Code
NScheduleCommandBarBuilder commandBarBuilder = new NScheduleCommandBarBuilder();
NWidget uiWidget = commandBarBuilder.CreateUI(scheduleView);

Another way to create a schedule view with command bars (menus and toolbars) is to use the NScheduleViewViewWithCommandBars class. The example below demonstrates how to create a schedule view with command bars hosted in a NOV widget host. You can then add this host to a form's Controls collection if you are creating a WinForms application or set it as the content of a WPF window in a WPF application project.

Create a Schedule View with Command Bars
Copy Code
NNovWidgetHost<NScheduleViewWithCommandBars> novContent = new NNovWidgetHost<NScheduleViewWithCommandBars>();
Modifying Builder Collections

If you want to remove a given toolbar or menu from the builders, you can easily do so by using the Remove method of the ToolBarBuilders and MenuDropDownBuilders collection of the schedule command bar builder respectively. You can get or remove builders by name.

The names of all schedule menu and toolbar builders are exposed as constants in the NScheduleCommandBarBuilder class. For example, to remove the "File" menu and the "Standard" toolbar of a command bars based schedule UI, you can use the following piece of code:

Remove Toolbar and Menu Builders
Copy Code
commandBarBuilder.MenuDropDownBuilders.Remove(NScheduleCommandBarBuilder.MenuFileName);
commandBarBuilder.ToolBarBuilders.Remove(NScheduleCommandBarBuilder.ToolbarStandardName);

In order to add or insert your own toolbar or menu drop down builder, you can use the Add or Insert methods of the corresponding builder collection respectively.

Add Custom Toolbar and Menu Builders
Copy Code
commandBarBuilder.MenuDropDownBuilders.Insert(1, new CustomMenuBuilder());
commandBarBuilder.ToolBarBuilders.Insert(0, new CustomToolBarBuilder());
Custom Menu Builders

To create a custom menu builder, you should create a class, which inherits NMenuDropDownBuilder:

Create custom menu drop down builder
Copy Code
public class CustomMenuBuilder : NMenuDropDownBuilder
{
    public CustomMenuBuilder()
        : base("Custom Menu")
    {
    }

    protected override void AddItems(NMenuItemCollection items)
    {
        // Add the "Add Appointment" menu item
        items.Add(CreateMenuItem(Nevron.Nov.Schedule.NResources.Image_Edit_AddAppointment_png,
            NScheduleView.AddAppointmentCommand));

        // Add the custom command menu item
        items.Add(CreateMenuItem(NResources.Image_Ribbon_16x16_smiley_png, CustomCommand));
    }
}
Custom Toolbar Builders

To create a custom toolbar builder, you should create a class, which inherits the NToolBarBuilder:

Create custom toolbar builder
Copy Code
public class CustomToolBarBuilder : NToolBarBuilder
{
    public CustomToolBarBuilder()
        : base("Custom Toolbar")
    {
    }

    protected override void AddItems(NCommandBarItemCollection items)
    {
        // Add the "Add Appointment" button
        items.Add(CreateButton(Nevron.Nov.Schedule.NResources.Image_Edit_AddAppointment_png, NScheduleView.AddAppointmentCommand));

        // Add the custom command button
        items.Add(CreateButton(NResources.Image_Ribbon_16x16_smiley_png, CustomCommand));
    }
}
Removing Individual Buttons

To remove individual buttons from a toolbar, you should:

  1. Create a custom toolbar builder that inherits the toolbar builder you want to remove buttons from
  2. Override the AddItems method and remove the items you want
  3. Replace the original toolbar builder in the command bar builder toolbar builders collection with your custom one

The code below shows how to create a custom toolbar builder that removes the Save As button from the schedule "Standard" toolbar:

Remove individual buttons
Copy Code
class CustomStandardToolbar : NStandardToolBarBuilder
{
    protected override void AddItems(NCommandBarItemCollection items)
    {
        // Call base to add the default items
        base.AddItems(items);

        // Remove the button at index 2 (i.e. the "Save As" button)
        items.RemoveAt(2);
    }
}

To replace the original "Standard" toolbar builder with the custom one, use the following code:

Replace the "Standard" toolbar builder
Copy Code
NScheduleCommandBarBuilder commandBarBuilder = new NScheduleCommandBarBuilder();
int toolbarIndex = commandBarBuilder.ToolBarBuilders.IndexOf(NScheduleCommandBarBuilder.ToolbarStandardName);
commandBarBuilder.ToolBarBuilders[toolbarIndex] = new CustomStandardToolbar();
See Also

UI

Send Feedback