Beispiel #1
0
        private void AddMenu_Load(object sender, EventArgs e)
        {
            PopulateTreeView();
            Cdc.MetaManager.DataAccess.Domain.Menu menu = menuService.GetMenuByApplicationId(FrontendApplication.Id);
            this.IsEditable = menu.IsLocked && menu.LockedBy == Environment.UserName;

            Cursor.Current = Cursors.Default;
        }
Beispiel #2
0
        private void PopulateTreeView()
        {
            // Check if the application has a topmenuitem
            Cdc.MetaManager.DataAccess.Domain.Menu menu = menuService.GetMenuByApplicationId(FrontendApplication.Id);

            // If a menu didn't exist then create it with one node.
            if (menu == null)
            {
                menu = new Cdc.MetaManager.DataAccess.Domain.Menu();

                menu.Application = FrontendApplication;

                Cdc.MetaManager.DataAccess.Domain.MenuItem topMenuItem = new Cdc.MetaManager.DataAccess.Domain.MenuItem();

                topMenuItem.Name    = string.Empty;
                topMenuItem.Caption = "Menu Caption (change me!)";
                topMenuItem.Menu    = null;
                topMenuItem.Parent  = null;

                topMenuItem = menuService.SaveMenuItem(topMenuItem);

                menu.TopMenuItem = topMenuItem;

                menuService.SaveMenu(menu);

                topMenuItem.Menu = menu;

                topMenuItem = menuService.SaveMenuItem(topMenuItem);
            }

            if (menu != null)
            {
                // Fetch the tree of menuitems
                Cdc.MetaManager.DataAccess.Domain.MenuItem topMenuItem = menuService.GetMenuItemById(menu.TopMenuItem.Id);

                // Check if we found any items
                if (topMenuItem != null)
                {
                    TreeNode dialogTreeNode = new TreeNode();

                    BuildViewTree(topMenuItem, dialogTreeNode);

                    tvMenu.Nodes.Add(dialogTreeNode);

                    // Expand the whole menu
                    tvMenu.ExpandAll();
                }
            }
        }