private void EditCurrentSelectedMenuItem() { if (CurrentMenuItem != null) { // Edit the MenuItem using (AddMenuItem editMenuItem = new AddMenuItem()) { editMenuItem.FrontendApplication = FrontendApplication; editMenuItem.BackendApplication = BackendApplication; editMenuItem.CurrentMenuItem = CurrentMenuItem; editMenuItem.IsRootMenuItem = tvMenu.SelectedNode.Parent == null; if (editMenuItem.ShowDialog() == DialogResult.OK) { // Save the menuitem created menuService.SaveMenuItem(editMenuItem.CurrentMenuItem); // Set the new menuitem to the tag. tvMenu.SelectedNode.Tag = editMenuItem.CurrentMenuItem; // Update selected node UpdateTreeNode(tvMenu.SelectedNode); } } } }
private bool AddMenuItem(TreeNode parentNode) { // Get parents MenuItem Cdc.MetaManager.DataAccess.Domain.MenuItem parentMenuItem = (Cdc.MetaManager.DataAccess.Domain.MenuItem)parentNode.Tag; // Create the new menuitem Cdc.MetaManager.DataAccess.Domain.MenuItem newItem = new Cdc.MetaManager.DataAccess.Domain.MenuItem(); // Edit the MenuItem using (AddMenuItem editMenuItem = new AddMenuItem()) { editMenuItem.FrontendApplication = FrontendApplication; editMenuItem.BackendApplication = BackendApplication; editMenuItem.CurrentMenuItem = newItem; if (editMenuItem.ShowDialog() == DialogResult.OK) { // Add the item to the parentitem newItem.Menu = parentMenuItem.Menu; newItem.Parent = parentMenuItem; // Set sequence newItem.Sequence = SetSequence(parentNode); // Save the menuitem created newItem = menuService.SaveMenuItem(newItem); // Add the child to the parent menuitem parentMenuItem.Children.Add(newItem); // Add a node to the treeview TreeNode createdNode = CreateNewNode(parentNode, newItem); // Set the new node to be the selected one. tvMenu.SelectedNode = createdNode; return(true); } } return(false); }