add a NDiagramButtonCommand to NDiagramCommandBarsManager menu


Author
Message
Wilhelm Vortisch
Wilhelm Vortisch
Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)Junior Member (14 reputation)
Group: Forum Members
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
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search