CommandInMenuAttribute
Namespace: Digi21.DigiNG.Plugin.Menu
Assembly: Digi21.DigiNG.Plugin
Adds a drawing window menu item that executes the command implemented by the class.
[AttributeUsage(AttributeTargets.Class)]
public class CommandInMenuAttribute : Attribute
The attribute only affects classes registered as commands, that is, with CommandAttribute or LocalizableCommandAttribute.
Whenever the user opens the submenu containing position Group, Digi3D.AI reads this attribute from all registered .NET commands and adds, at that position, an item with text Title for each command whose Group matches. Selecting the item executes the command by name, without parameters. The MenuItemGroup table shows each group's position and the groups that do not appear in the menu.
Restrictions:
- Digi3D.AI does not add items if the
MostrarMenusNativosconfiguration option is enabled. - Digi3D.AI assigns each distinct combination of group, title and command an identifier from 22301 to 22399, keeping the assignment for the session. Two commands with the same
Titlein the same group receive different identifiers and each item executes its own command. From the session's 100th combination onward, no identifiers remain and Digi3D.AI does not add the item to the menu. - If the attribute's constructor throws an exception when the submenu opens, Digi3D.AI does not add that command's item and writes the exception message through
System.Diagnostics.Trace.
Constructors
public CommandInMenuAttribute(string title, MenuItemGroup group)
| Parameter | Description |
|---|---|
title |
Menu item text. Assigned to Title. |
group |
Menu position. Assigned to Group. |
Properties
| Property | Description |
|---|---|
string Title { get; set; } |
Menu item text. |
MenuItemGroup Group { get; set; } |
Menu position where the item appears. |
Example
The example command in Command has [Command(Name = "MIDE_DISTANCIA")] and [CommandInMenu("Medir la distancia entre dos puntos", MenuItemGroup.InmediateGroup4)]. The Medir la distancia entre dos puntos item appears in Immediate, after Measures segment, and executes MIDE_DISTANCIA.