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 easiest 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, set it as the Content of a WPF window in a WPF application project or to the ContentView of a Xamarin.Mac window.

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

Another way to create a command bar based commanding UI and associate it with a schedule view is:

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

To remove all widgets associated with specific commands from the commanding UI, use the RemoveCommands method of the schedule view with command bars:

Remove commands
Copy Code
// Create an array of commands to remove
NCommand[] commandsToRemove = new NCommand[] {
    NScheduleView.OpenCommand,
    NScheduleView.SaveAsCommand,
    NScheduleView.SaveCommand
};

NScheduleViewWithCommandBars scheduleViewWithCommandBars = new NScheduleViewWithCommandBars();
scheduleViewWithCommandBars.RemoveCommands(commandsToRemove);
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));
    }
}

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