Beispiel #1
0
 public void parseMenuItem(EIBMenu menu, TreeNode parentTreeNode)
 {
     foreach (object menuItem in menu.DropDownItems)
     {
         if (menuItem.GetType() == typeof(EIBMenu))
         {
             EIBMenu eibmenu = (EIBMenu)menuItem;
             if (!string.IsNullOrEmpty(eibmenu.Text))
             {
                 TreeNode tn = new TreeNode(eibmenu.Text);
                 tn.Name = eibmenu.Name;
                 parentTreeNode.Nodes.Add(tn);
                 parseMenuItem(eibmenu, tn);
                 nodeMenus.Add(tn.Name, eibmenu);
             }
         }
         else
         {
             EIBMenuItem eibMenuItem = (EIBMenuItem)menuItem;
             if (!string.IsNullOrEmpty(eibMenuItem.Text))
             {
                 TreeNode tn = new TreeNode(eibMenuItem.Text);
                 tn.Name = eibMenuItem.Name;
                 parentTreeNode.Nodes.Add(tn);
                 nodeMenus.Add(tn.Name, eibMenuItem);
             }
         }
     }
 }
Beispiel #2
0
 internal void retreiveAllChildControl(object parent)
 {
     foreach (CBFormCtrl ctl in this.CBControls)
     {
         if (ctl.CtrlName == "ToolStrip" && ctl.PartialName == "System.Windows.Forms")
         {
             ToolStrip toolStrip = new ToolStrip();
             ctl.retreiveAllChildControl(toolStrip);
             ((EIBMenuBar)parent).Join(toolStrip);
         }
         else if (ctl.ctrlName == "EIBMenu")
         {
             EIBMenu ctrl = (EIBMenu)ToolBox.CreateControl(ctl.CtrlName, ctl.PartialName);
             ToolBox.SetControlProperties(ctrl, ctl.PropertyList);
             ctl.retreiveAllChildControl(ctrl);
             if (parent is ToolStrip)
             {
                 ((ToolStrip)parent).Items.Add(ctrl);
             }
             else
             {
                 ((EIBMenu)parent).DropDownItems.Add(ctrl);
             }
         }
         else if (ctl.ctrlName == "EIBMenuItem")
         {
             EIBMenuItem ctrl = (EIBMenuItem)ToolBox.CreateControl(ctl.CtrlName, ctl.PartialName);
             ToolBox.SetControlProperties(ctrl, ctl.PropertyList);
             //ctl.retreiveAllChildControl(ctrl);
             if (parent is ToolStrip)
             {
                 ((ToolStrip)parent).Items.Add(ctrl);
             }
             else
             {
                 ((EIBMenu)parent).DropDownItems.Add(ctrl);
             }
         }
         else
         {
             Control ctrl = (Control)ToolBox.CreateControl(ctl.CtrlName, ctl.PartialName);
             ToolBox.SetControlProperties(ctrl, ctl.PropertyList);
             ctl.retreiveAllChildControl(ctrl);
             ((Control)parent).Controls.Add(ctrl);
         }
     }
 }
Beispiel #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            TreeNode selectedNode = treeView1.SelectedNode;
            object   menu         = nodeMenus[selectedNode.Name];

            if (menu != null)
            {
                if (menu.GetType() == typeof(EIBMenu))
                {
                    EIBMenu     eibMenu = (EIBMenu)menu;
                    EIBMenuItem ctrl    = (EIBMenuItem)UIEventManager.getToolBox.getControlType(FormDesignerConstants.MenuItemControl);
                    ctrl.Text = "EIBMenuItem";
                    eibMenu.DropDownItems.Add(ctrl);
                    TreeNode tn = new TreeNode(ctrl.Text);
                    tn.Name = ctrl.Name;
                    selectedNode.Nodes.Add(tn);
                    nodeMenus.Add(tn.Name, ctrl);
                }
                else if (menu.GetType() == typeof(EIBMenuItem))
                {
                    MessageBox.Show("Select parent menu");
                }
            }
        }
Beispiel #4
0
        private void button4_Click(object sender, EventArgs e)
        {
            TreeNode selectedNode = treeView1.SelectedNode;
            int      index        = selectedNode.Index;
            TreeNode parentNode   = selectedNode.Parent;

            if (parentNode == null)
            {
                if (index >= treeView1.Nodes.Count - 1)
                {
                    return;
                }
                selectedNode.Remove();
                treeView1.Nodes.Insert(index + 1, selectedNode);
                object menuObj = nodeMenus[selectedNode.Name];
                if (menuObj != null)
                {
                    if (menuObj.GetType() == typeof(EIBMenu))
                    {
                        EIBMenu eibMenu   = (EIBMenu)menuObj;
                        int     menuIndex = ((ToolStrip)(currentMenuBar.Controls[0])).Items.IndexOf(eibMenu);
                        ((ToolStrip)(currentMenuBar.Controls[0])).Items.Remove(eibMenu);
                        ((ToolStrip)(currentMenuBar.Controls[0])).Items.Insert(menuIndex + 1, eibMenu);
                    }
                    else if (menuObj.GetType() == typeof(EIBMenuItem))
                    {
                        /*EIBMenuItem eibMenu = (EIBMenuItem)menuObj;
                         * EIBMenu parentEibMenu = (EIBMenu)nodeMenus[selectedNode.Parent.Name];
                         * int menuIndex = parentEibMenu.DropDownItems.IndexOf(eibMenu);
                         * parentEibMenu.DropDownItems.Remove(eibMenu);
                         * parentEibMenu.DropDownItems.Insert(menuIndex - 1, eibMenu);*/
                        //MessageBox.Show("Select parent menu");
                    }
                }
            }
            else if (selectedNode.Index < parentNode.Nodes.Count - 1)
            {
                selectedNode.Remove();
                parentNode.Nodes.Insert(index + 1, selectedNode);
                object menuObj = nodeMenus[selectedNode.Name];
                if (menuObj != null)
                {
                    if (menuObj.GetType() == typeof(EIBMenu))
                    {
                        EIBMenu eibMenu       = (EIBMenu)menuObj;
                        EIBMenu parentEibMenu = (EIBMenu)nodeMenus[selectedNode.Parent.Name];
                        int     menuIndex     = parentEibMenu.DropDownItems.IndexOf(eibMenu);
                        parentEibMenu.DropDownItems.Remove(eibMenu);
                        parentEibMenu.DropDownItems.Insert(menuIndex + 1, eibMenu);
                    }
                    else if (menuObj.GetType() == typeof(EIBMenuItem))
                    {
                        EIBMenuItem eibMenu       = (EIBMenuItem)menuObj;
                        EIBMenu     parentEibMenu = (EIBMenu)nodeMenus[selectedNode.Parent.Name];
                        int         menuIndex     = parentEibMenu.DropDownItems.IndexOf(eibMenu);
                        parentEibMenu.DropDownItems.Remove(eibMenu);
                        parentEibMenu.DropDownItems.Insert(menuIndex + 1, eibMenu);
                        //MessageBox.Show("Select parent menu");
                    }
                }
            }
        }
        private static void UpdateSubMenuValues(IEIBControl menuBar, XmlNode menuNode)
        {
            //DragDropHandler.RegisterControl(menuBar, true, true);
            if (menuNode.ChildNodes.Count > 0)
            {
                foreach (XmlNode Node in menuNode.ChildNodes)
                {
                    if (Node.Name == FormDesignerConstants.MenuControl)
                    {
                        EIBMenu submenu = new EIBMenu();
                        SetMenuValue(submenu, Node);
                        submenu.InitiateSettings(null);
                        submenu.Click += new EventHandler(FormDesigner.eventManager.handleMenuClick);
                        //menuItem.ControlName = menuItem.Name;
                        if (menuBar is EIBMenuBar)
                        {
                            ((EIBMenuBar)menuBar).CurrentMenu.DropDownItems.Add(submenu);
                        }
                        else
                        {
                            ((EIBVMenuBar)menuBar).CurrentMenu.DropDownItems.Add(submenu);
                        }

                        //to deserialise the evnts related to menu items
                        SetEIBEventsValue(submenu, Node);
                        if (Node.HasChildNodes)
                        {
                            if (menuBar is EIBMenuBar)
                            {
                                ((EIBMenuBar)menuBar).CurrentMenu = submenu; ;
                            }
                            else
                            {
                                ((EIBVMenuBar)menuBar).CurrentMenu = submenu;
                            }

                            UpdateSubMenuValues(menuBar, Node);
                        }
                        //else
                        //{
                        //    menuBar.CurrentMenu = (EIBMenu)menuBar.CurrentMenu.OwnerItem;
                        //}

                        EIBMenu.counter++;
                    }
                    else if (Node.Name == FormDesignerConstants.MenuItemControl)
                    {
                        EIBMenuItem menuItem = new EIBMenuItem();
                        SetMenuValue(menuItem, Node);
                        menuItem.InitiateSettings(null);
                        menuItem.Click += new EventHandler(FormDesigner.eventManager.handleMenuItemClick);
                        //menuItem.ControlName = menuItem.Name;
                        if (menuBar is EIBMenuBar)
                        {
                            ((EIBMenuBar)menuBar).CurrentMenu.DropDownItems.Add(menuItem);
                            ((EIBMenuBar)menuBar).CurrentMenu.CurrentMenuItem = menuItem;
                        }
                        else
                        {
                            ((EIBVMenuBar)menuBar).CurrentMenu.DropDownItems.Add(menuItem);
                            ((EIBVMenuBar)menuBar).CurrentMenu.CurrentMenuItem = menuItem;
                        }
                        //to deserialise the evnts related to menu items
                        SetEIBEventsValue(menuItem, Node);
                        EIBMenuItem.counter++;
                    }
                }
                if (menuBar is EIBMenuBar)
                {
                    ((EIBMenuBar)menuBar).CurrentMenu = (EIBMenu)((EIBMenuBar)menuBar).CurrentMenu.OwnerItem;
                }
                else
                {
                    ((EIBVMenuBar)menuBar).CurrentMenu = (EIBMenu)((EIBVMenuBar)menuBar).CurrentMenu.OwnerItem;
                }

            }
            else
            {
                //menuBar.CurrentMenu = (EIBMenu)menuBar.CurrentMenu.OwnerItem;
            }

            //if (menubarNode.ChildNodes.Count > 0)
            //{
            //    foreach (XmlNode menuNode in menubarNode.ChildNodes)
            //    {
            //        EIBMenu menu = new EIBMenu();
            //        // menu.InitiateSettings(null);
            //        SetMenuValue(menu, menuNode);
            //        //menu.ControlName = menu.Name;
            //        menu.Click += new EventHandler(FormDesigner.eventManager.handleMenuClick);
            //        menuBar.CurrentToolStrip.Items.Add(menu);
            //        menuBar.CurrentMenu = menu;
            //        //control.Items.Add(childXMLNode.Attributes[XMLServicesConstants.XmlNodeTextAtt].Value.ToString());
            //        foreach (XmlNode menuItemNode in menuNode.ChildNodes)
            //        {
            //            EIBMenuItem menuItem = new EIBMenuItem();
            //            menuItem.InitiateSettings(null);
            //            SetMenuValue(menuItem, menuItemNode);
            //            menuItem.Click += new EventHandler(FormDesigner.eventManager.handleMenuItemClick);
            //            //menuItem.ControlName = menuItem.Name;
            //            menuBar.CurrentMenu.DropDownItems.Add(menuItem);
            //            menuBar.CurrentMenu.CurrentMenuItem = menuItem;
            //            //to deserialise the evnts related to menu items
            //            SetEIBEventsValue(menuItem, menuItemNode);
            //        }

            //    }

            //}
        }
Beispiel #6
0
 public EIBVMenuBar getOwnerForMenuItem(EIBMenuItem menuItem)
 {
     if (menuItem != null)
     {
         if(menuItem.OwnerItem is EIBMenu)
         {
             return getOwner((EIBMenu)menuItem.OwnerItem);
         }
     }
     return null;
 }