Group: Forum Members
Last Active: 13 Years Ago
Posts: 14,
Visits: 1
|
Hi *,
I try to add a custom toolbar command
public class NCustomDiagramButtonCommand : NDiagramButtonCommand { // [...]
public NCustomDiagramButtonCommand() : base((int)DiagramCommandRange.Misc, (int)DiagramCommand.LastCommandId + 1, "Custom command", "Custom button command in a custom toolbar.") { }
public override void Execute() { MessageBox.Show("NCustomDiagramButtonCommand was executed."); } // [...] }
with
// create the custom buttom command if not already craated if (customDiagramButtonCommand == null) { customDiagramButtonCommand = new NCustomDiagramButtonCommand(); Form.CommandBarsManager.Commander.Commands.Add(customDiagramButtonCommand); }
to one of the menu entrys (the "Edit" menu) in the main menu bar with:
NMenuBar mainMenu = (NMenuBar)Form.CommandBarsManager.Toolbars["Main Menu"]; mainMenu.Commands[2].Commands.Add(NCommand.FromContext((NCommandContext)customDiagramButtonCommand.CreateUICommand()));
If I call this after Form.CommandBarsManager.Recreate(); the new menu entry is shown, but if I clicked the new menu entry, the "Execute" procedure of the NCustomDiagramButtonCommand object isn't fired.
Why?
Regards
Wilhelm
|