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 Nevron Support,

thank you, the above tip has solved my problem.

Regards

Wilhelm
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hi Wilhelm,

You have to create the command that you add to the main menu Commands collection as follows:

int id = customDiagramButtonCommand.Id;
NCommandContext context = Form.CommandBarsManager.Contexts.ContextFromID(id);
NCommand cmd = NCommand.FromContext(context);

I hope this helps.

Best Regards,
Nevron Support Team


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