Ejemplo n.º 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);
             }
         }
     }
 }
Ejemplo n.º 2
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);
             }
         }
     }
 }
Ejemplo n.º 3
0
 public void removeAllChild(object menu)
 {
     if (menu.GetType() == typeof(EIBMenuItem))
     {
         nodeMenus.Remove(((EIBMenuItem)menu).Name);
     }
     else
     {
         foreach (object ctrl in ((EIBMenu)menu).DropDownItems)
         {
             if (ctrl.GetType() == typeof(EIBMenu))
             {
                 EIBMenu eibMenu = (EIBMenu)ctrl;
                 if (eibMenu.HasDropDownItems)
                 {
                     removeAllChild(eibMenu);
                 }
                 nodeMenus.Remove(eibMenu.Name);
             }
             else if (ctrl.GetType() == typeof(EIBMenuItem))
             {
                 nodeMenus.Remove(((EIBMenuItem)ctrl).Name);
             }
         }
     }
 }
Ejemplo n.º 4
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);
         }
     }
 }
Ejemplo n.º 5
0
        //Delete button code for menu editor.
        private void button5_Click(object sender, EventArgs e)
        {
            TreeNode selectedNode = treeView1.SelectedNode;
            TreeNode parentNode   = selectedNode.Parent;

            if (parentNode == null)
            {
                ((ToolStrip)(currentMenuBar.Controls[0])).Items.Remove((ToolStripItem)nodeMenus[selectedNode.Name]);
                removeAllChild(nodeMenus[selectedNode.Name]);
                treeView1.Nodes.Remove(selectedNode);
            }
            else
            {
                EIBMenu parentMenu = (EIBMenu)nodeMenus[parentNode.Name];
                parentMenu.DropDownItems.Remove((ToolStripItem)nodeMenus[selectedNode.Name]);
                removeAllChild(nodeMenus[selectedNode.Name]);
                parentNode.Nodes.Remove(selectedNode);
            }
            isSelected             = false;
            treeView1.SelectedNode = null;
            showButton(false);
        }
Ejemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            TreeNode selectedNode = treeView1.SelectedNode;

            if (selectedNode == null)
            {
                EIBMenu ctrl = (EIBMenu)UIEventManager.getToolBox.getControlType(FormDesignerConstants.MenuControl);
                ctrl.Text = "Menu";
                TreeNode tn = new TreeNode(ctrl.Text);
                tn.Name = ctrl.Name;
                treeView1.Nodes.Add(tn);
                nodeMenus.Add(tn.Name, ctrl);
                ((ToolStrip)(currentMenuBar.Controls[0])).Items.Add(ctrl);
            }
            else
            {
                object menu = nodeMenus[selectedNode.Name];
                if (menu != null)
                {
                    if (menu.GetType() == typeof(EIBMenu))
                    {
                        EIBMenu eibMenu = (EIBMenu)menu;
                        EIBMenu ctrl    = (EIBMenu)UIEventManager.getToolBox.getControlType(FormDesignerConstants.MenuControl);
                        ctrl.Text = "SubMenu";
                        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");
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private void CreateCBFormCtrl(object ctrl)
        {
            CtrlName    = ctrl.GetType().Name;
            PartialName = ctrl.GetType().Namespace;
            if (ctrl is EIBMenuBar)
            {
                PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(ctrl);//, new Attribute[] { new SerializableAttribute(),new BrowsableAttribute(true)});

                foreach (PropertyDescriptor myProperty in properties)
                {
                    try
                    {
                        if (myProperty.PropertyType.IsSerializable && myProperty.IsBrowsable)
                        {
                            propertyList.Add(myProperty.Name, myProperty.GetValue(ctrl));
                        }
                        else if (myProperty.Name == "Controls")
                        {
                            //propertyList.Add(myProperty.Name,myProperty.GetValue(ctrl));
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Trace.WriteLine(ex.Message);
                        //do nothing, just continue
                    }
                }
            }
            else
            {
                PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(ctrl);

                foreach (PropertyDescriptor myProperty in properties)
                {
                    try
                    {
                        if (myProperty.PropertyType.IsSerializable)
                        {
                            propertyList.Add(myProperty.Name, myProperty.GetValue(ctrl));
                        }
                        else if (myProperty.Name == "Controls")
                        {
                            //propertyList.Add(myProperty.Name,myProperty.GetValue(ctrl));
                        }
                        else if (myProperty.Name == "Nodes")
                        {
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Trace.WriteLine(ex.Message);
                        //do nothing, just continue
                    }
                }
            }
            if (ctrl is ToolStrip)
            {
                ToolStrip toolStrip = (ToolStrip)ctrl;
                foreach (ToolStripItem ctl in toolStrip.Items)
                {
                    if (ctl is EIBMenu)
                    {
                        CBFormCtrl cbCtrl = new CBFormCtrl(ctl);
                        this.CBControls.Add(cbCtrl);
                    }
                    else if (ctl is EIBMenuItem)
                    {
                        CBFormCtrl cbCtrl = new CBFormCtrl(ctl);
                        this.CBControls.Add(cbCtrl);
                    }
                }
            }
            else if (ctrl is EIBMenu)
            {
                EIBMenu menu = (EIBMenu)ctrl;
                foreach (ToolStripItem ctl in menu.DropDownItems)
                {
                    if (ctl is EIBMenu)
                    {
                        CBFormCtrl cbCtrl = new CBFormCtrl(ctl);
                        this.CBControls.Add(cbCtrl);
                    }
                    else if (ctl is EIBMenuItem)
                    {
                        CBFormCtrl cbCtrl = new CBFormCtrl(ctl);
                        this.CBControls.Add(cbCtrl);
                    }
                }
            }
            else if (!(ctrl is EIBMenuItem))
            {
                if (ctrl is EIBTreeView)
                {
                    foreach (EIBTreeNode ctl in ((EIBTreeView)ctrl).Nodes)
                    {
                        CBFormCtrl cbCtrl = new CBFormCtrl(ctl);
                        this.CBControls.Add(cbCtrl);
                    }
                }
                else if (ctrl is EIBTreeNode)
                {
                    foreach (EIBTreeNode ctl in ((EIBTreeNode)ctrl).Nodes)
                    {
                        CBFormCtrl cbCtrl = new CBFormCtrl(ctl);
                        this.CBControls.Add(cbCtrl);
                    }
                }
                else
                {
                    foreach (Control ctl in ((Control)ctrl).Controls)
                    {
                        if (ctl is IEIBControl)
                        {
                            CBFormCtrl cbCtrl = new CBFormCtrl(ctl);
                            this.CBControls.Add(cbCtrl);
                        }
                        else if (ctl is ToolStrip)
                        {
                            CBFormCtrl cbCtrl = new CBFormCtrl(ctl);
                            this.CBControls.Add(cbCtrl);
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
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");
                    }
                }
            }
        }
Ejemplo n.º 9
0
        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);
            //        }

            //    }

            //}
        }
Ejemplo n.º 10
0
        public static void saveXMLofSubMenus(EIBMenu menu,XmlNode xmlNode)
        {
            foreach (IEIBControl ctrlmenu in menu.DropDownItems)
            {
                if (ctrlmenu is EIBMenu)
                {
                    EIBMenu tmenu = (EIBMenu)ctrlmenu;
                    Hashtable menuItemProperties = XMLServices.updateMenuSettings(tmenu, tmenu.Name, tmenu.Name);
                    Hashtable menuEventProperties = XMLServices.updateMenuEvents(tmenu, tmenu.Name.ToLower(), tmenu.Name.ToLower());

                    XmlNode pxmlNode= XMLServices.writeElement(xmlNode, EIBControlList.GetRenderingElement(tmenu.GetType().Name), menuItemProperties, menuEventProperties, null);
                    if (((ToolStripMenuItem)ctrlmenu).DropDownItems.Count > 0)
                    {
                        saveXMLofSubMenus((EIBMenu)ctrlmenu, pxmlNode);
                    }
                }
                else if (ctrlmenu is EIBMenuItem)
                {
                    EIBMenuItem tmenu = (EIBMenuItem)ctrlmenu;
                    Hashtable menuItemProperties = XMLServices.updateMenuSettings(tmenu, tmenu.Name, tmenu.Name);
                    Hashtable menuEventProperties = XMLServices.updateMenuEvents(tmenu, tmenu.Name.ToLower(), tmenu.Name.ToLower());

                    XMLServices.writeElement(xmlNode, EIBControlList.GetRenderingElement(tmenu.GetType().Name), menuItemProperties, menuEventProperties,null);
                    //saveXMLofSubMenus((EIBMenu)ctrlmenu);
                }

            }
        }
Ejemplo n.º 11
0
 public EIBVMenuBar getOwner(EIBMenu menu)
 {
     if (menu != null)
     {
         if (menu.Owner is EIBVMenuBar)
             return (EIBVMenuBar)menu.Owner;
         else if (menu.Owner.Parent is EIBMenuBar)
         {
             return null;
         }
         else
             return getOwner((EIBMenu)menu.OwnerItem);
     }
     else
     {
         return null;
     }
 }
Ejemplo n.º 12
0
        private static void UpdateMenuValues(IEIBControl menuBar, XmlNode menubarNode)
        {
            //DragDropHandler.RegisterControl(menuBar, true, true);

            if (menubarNode.ChildNodes.Count > 0)
            {
                foreach (XmlNode menuNode in menubarNode.ChildNodes)
                {
                    if (menuNode.Name != "Events" && menuNode.Name != "DataMappings")
                    {
                        EIBMenu menu = new EIBMenu();

                        SetMenuValue(menu, menuNode);
                        //menu.InitiateSettings(null);
                        menu.ControlName = menu.Name;
                        menu.UniqueId = menuNode.Attributes["id"].Value;
                        menu.Click += new EventHandler(FormDesigner.eventManager.handleMenuClick);
                        if (menuBar is EIBMenuBar)
                        {
                            ((EIBMenuBar)menuBar).CurrentToolStrip.Items.Add(menu);
                            ((EIBMenuBar)menuBar).CurrentMenu = menu;
                        }
                        else
                        {
                            ((EIBVMenuBar)menuBar).Items.Add(menu);
                            ((EIBVMenuBar)menuBar).CurrentMenu = menu;
                        }
                        SetEIBEventsValue(menu, menuNode);
                        if (menuNode.HasChildNodes)
                        {
                            UpdateSubMenuValues(menuBar, menuNode);
                        }
                        else
                        {

                        }
                        EIBMenu.counter++;
                      //  FormDesignerUtilities.formWindowNames.Add(menu.UniqueId.ToString(), menu.UniqueId.ToString().ToLower());
                        ControlValidation.addUniqueIdToList(menu.UniqueId.ToString());
                    }
                    //control.Items.Add(childXMLNode.Attributes[XMLServicesConstants.XmlNodeTextAtt].Value.ToString());
                    //foreach (XmlNode Node in menuNode.ChildNodes)
                    //{
                    //    if (Node.Name == FormDesignerConstants.MenuControl)
                    //    {
                    //        EIBMenu submenu = new EIBMenu();
                    //        //submenu.InitiateSettings(null);
                    //        SetMenuValue(submenu, Node);
                    //        submenu.Click += new EventHandler(FormDesigner.eventManager.handleMenuItemClick);
                    //        //menuItem.ControlName = menuItem.Name;
                    //        menuBar.CurrentMenu.DropDownItems.Add(submenu);
                    //        menuBar.CurrentMenu.CurrentMenuItem = menuItem;
                    //        //to deserialise the evnts related to menu items
                    //        SetEIBEventsValue(menuItem, menuItemNode);
                    //    }
                    //    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);
                    //}

                }

            }
            else
            {

            }
        }