Adding spacer

Spacer can be added between the commands by decorating the command using the CommandSpacerAttribute. Spacer will be added before this command.

public enum Commands_e
{
    Command1,

    [CommandSpacer]
    Command2
}

If command tab tab boxes are created for this command group (i.e. showInCmdTabBox parameter is set to true in the CommandItemInfoAttribute), spacer is not reflected in the corresponding command tab box.

Adding sub-menus

Sub-menus for the command groups can be defined by calling the corresponding overload of the CommandGroupInfoAttribute attribute and specifying the type of the parent menu group

public enum Commands_e
{
    Command1,
    Command2
}

[CommandGroupInfo(typeof(Commands_e))] //SubCommands_e is a sub-menu of Commands_e
public enum SubCommands_e
{
    SubCommand1,
    SubCommand2
}

Sub menus are rendered in separate tab boxes in the command tab.

Example

[Title("AddInEx Commands")]
public enum Commands_e
{
    [CommandItemInfo(true, true, swWorkspaceTypes_e.AllDocuments, true)]
    Command1,

    [CommandSpacer]
    [CommandItemInfo(true, true, swWorkspaceTypes_e.AllDocuments, true)]
    Command2
}

[CommandGroupInfo(typeof(Commands_e))]
[Title("Sub Menu Commands")]
public enum SubCommands_e
{
    [CommandItemInfo(true, true, swWorkspaceTypes_e.AllDocuments, true)]
    SubCommand1,

    [CommandItemInfo(true, true, swWorkspaceTypes_e.AllDocuments, true)]
    SubCommand2
}

The above commands configuration would result in the following menu and command tab boxes created:

Sub-menus and spacer
Sub-menus and spacer
  • Command1 and Command2 are commands of the top level menu defined in Commands_e enumeration
  • Spacer is added between Command1 and Command2
  • SubCommand1 and SubCommand2 are commands of SubCommands_e enumeration which is a sub menu of Commands_e enumeration
Command tab boxes
Command tab boxes
  • All commands (including sub menu commands) are added on the same command tab
  • Command1 and Command2 are placed in a separate command tab boxes of SubCommand1 and SubCommand2
  • Spacer between Command1 and Command2 is ignored in the commands tab