Nevron Forum
Back
Login
Register
Login
Register
Home
»
Nevron Vision for NET
»
Nevron Diagram for .NET
»
How to create command with Sub menu in custom...
How to create command with Sub menu in custom 'NDiagramContextMenuBuilder;
Post Reply
How to create command with Sub menu in custom...
View
Flat Ascending
Flat Descending
Threaded
Options
Subscribe to topic
Print This Topic
Goto Topics Forum
Author
Message
Niranjan Singh
Niranjan Singh
posted 8 Years Ago
ANSWER
Topic Details
Group: Forum Members
Posts: 49,
Visits: 179
I have further requirement from my last implementation using this -
How to remove auto generated context menu items for the selected shape conditionally?
Now I need to add some extra menu items to the context menu. I have added these command with sub menu but when i click these menu item then it does not fire the CommandContextExecuted event as like Delete and other commands. Below is the code snippet to create extra menu items in the context menu..
internal class CustomContextMenuBuilder : NDiagramContextMenuBuilder
{
public override NContextMenu BuildContextMenu(object obj)
{
NContextMenu contextMenu = null;
if (obj as NDrawingDocument == null)
{
contextMenu = new NContextMenu();
/* Added Delete option in the context menu */
contextMenu.Commands.Add(CreateCommand((int)DiagramCommand.Delete, false));
bool isConnectorMenu = obj as NRoutableConnector != null;
if (isConnectorMenu)
contextMenu.Commands.Add(CreateCommand((int)DiagramCommand.Reroute, true)); /* Added Reroute option in the context menu if connectors*/
/* Added SubmenuOrder in the context menu */
contextMenu.Commands.Add(CreateCommand((int)DiagramCommand.SubmenuOrder, !isConnectorMenu));
/* Added SubmenuRotateOrFlip in the context menu */
contextMenu.Commands.Add(CreateCommand((int)DiagramCommand.SubmenuRotateOrFlip, false));
if (offpageSystems.Count > 0) //Lets suppose it is list of String and I am creating a Sub menu
{
NCommand offpageCommand = new NCommand();
offpageCommand.Context = new NCommandContext(new NCommandProperties()
{
BeginGroup = true,
ShowArrowStyle = ShowArrowStyle.Default,
Name = "OffpageParent",
ID = ((int)DiagramCommand.LastCommandId + 20),
Text = "Offpage HVAC Systems"
});
contextMenu.Commands.Add(offpageCommand);
for (int cnt = 0; cnt < offpageSystems.Count; cnt++)
{
NCommand subCmd = new NCommand(new NCommandProperties()
{
Name = string.Format("OffpageChild{0}", cnt),
ID = ((int)DiagramCommand.LastCommandId + 20 + cnt),
Text = offpageSystems[cnt].SimModelName,
Tag = offpageSystems[cnt].RowReference
});
offpageCommand.Commands.Add(subCmd);
}
}
//DiagramCommandRange
}
return contextMenu;
}
Please suggest me the correct way to create context menu items which should work as like 'Action' DiagramCommandRange. How can i create another command range so that these submenu work like them??
Thanks in Advance
Tags
custom contextmenu
Diagram
Reply
Like
0
GO
Merge Selected
Merge into selected topic...
Merge into merge target...
Merge into a specific topic ID...
Open Merge
Threaded View
Threaded View
How to create command with Sub menu in custom...
Niranjan Singh
-
8 Years Ago
Hello Niranjan, When you create the context menu in BuildContextMenu...
Nevron Support
-
8 Years Ago
Post Reply
Similar Topics
Post Quoted Reply
Reading This Topic
Login
Login
Remember Me
Reset Password
Resend Validation Email
Login
Explore
Messages
Mentions
Search