Nevron Open Vision Documentation
Context Menu

NOV Diagram lets you fully customize the context menu shown when the user right clicks somewhere in the drawing view. To do so, you should create a class that inherits NDrawingContextMenu and override the methods you are interested in. Most commonly you will need to override one or both of the following methods:

The code example below demonstrates how to create a drawing context menu factory that adds a custom command at the bottom of the context menu:

Create custom diagram context menu
Copy Code
public class CustomContextMenu : NDrawingContextMenu
{
    public CustomContextMenu()
    {
    }
    static CustomContextMenu()
    {
        CustomContextMenuSchema = NSchema.Create(typeof(CustomContextMenu), NDrawingContextMenu.NDrawingContextMenuSchema);
    }

    protected override void CreateCustomCommands(NMenu menu)
    {
        base.CreateCustomCommands(menu);

        // Create a context menu builder
        NContextMenuBuilder builder = new NContextMenuBuilder();

        // Add a custom command
        builder.AddMenuItem(menu, NResources.Image_Ribbon_16x16_smiley_png, CustomCommand);
    }

    public static readonly NSchema CustomContextMenuSchema;
}

When you've created your custom diagram context menu factory, you should create an instance of it and assign it to the ContextMenu property of the drawing view:

Assign a diagram context menu factory to a drawing view
Copy Code
drawingView.ContextMenu = new CustomContextMenu();
See Also
Send Feedback