Пример #1
0
        void centerMark_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            MarkControl markControl = (MarkControl)sender;
            EIBNodeConnectorBase selnodeConnector = (EIBNodeConnectorBase)markControl.parentConnector;
            Graphics g = null;
            g = Graphics.FromImage(baseFrame.BackgroundImage);
            g.Clear(baseFrame.BackColor);

            foreach (Line l in ((BaseWindow)this.baseFrame.Parent).Lines)
            {
                EIBNodeConnectorBase nodeConnector = (EIBNodeConnectorBase)l.centerMark.parentConnector;
                int centerMarkX = (nodeConnector.mark1.Center.X + nodeConnector.mark2.Center.X) / 2;
                int centerMarkY = (nodeConnector.mark1.Center.Y + nodeConnector.mark2.Center.Y) / 2;
                if (!l.isDeleted)
                {
                    if (l.centerMark.parentConnector != selnodeConnector)
                    {
                        l.centerMark.parentConnector.isSelected = false;
                    }
                    else
                    {
                        l.centerMark.parentConnector.isSelected = true;
                    }
                    if (l.centerMark.parentConnector.isSelected)
                    {
                        Pen redPen = new Pen(Color.Red, (float)2);
                        g.DrawLine(redPen, nodeConnector.mark1.Center.X, nodeConnector.mark1.Center.Y, centerMarkX, centerMarkY);
                        g.DrawLine(redPen, centerMarkX, centerMarkY, nodeConnector.mark2.Center.X, nodeConnector.mark2.Center.Y);
                        NodeRelationManager nodeRelation = new NodeRelationManager();
                        nodeRelation.eibRelation1.firstTableName.Items.Add(nodeConnector.mark1.WorkFlowNode.WorkFlowNodeId);
                        nodeRelation.eibRelation1.secondTableName.Items.Add(nodeConnector.mark2.WorkFlowNode.WorkFlowNodeId);
                        nodeRelation.eibRelation1.firstTableName.SelectedIndex = 0;
                        nodeRelation.eibRelation1.secondTableName.SelectedIndex = 0;
                        nodeRelation.eibRelation1.relationName.Text = nodeConnector.ControlName;
                        nodeRelation.ShowDialog();
                    }
                    else
                    {
                        Pen royalBluePen = new Pen(Color.RoyalBlue, (float)2);
                        g.DrawLine(royalBluePen, nodeConnector.mark1.Center.X, nodeConnector.mark1.Center.Y, centerMarkX, centerMarkY);
                        g.DrawLine(royalBluePen, centerMarkX, centerMarkY, nodeConnector.mark2.Center.X, nodeConnector.mark2.Center.Y);
                    }
                }
            }
            baseFrame.Invalidate();
            baseFrame.Update();
            g.Dispose();

            /*EIBNodeConnectorBase nodeConnector = (EIBNodeConnectorBase)markControl.parentConnector;
            Graphics g = null;
            g = Graphics.FromImage(baseFrame.BackgroundImage);
            int centerMarkX = (nodeConnector.mark1.Center.X + nodeConnector.mark2.Center.X) / 2;
            int centerMarkY = (nodeConnector.mark1.Center.Y + nodeConnector.mark2.Center.Y) / 2;
            //
            foreach (Line l in ((BaseWindow)this.baseFrame.Parent).Lines)
            {
                if (!l.isDeleted)
                {
                    if (!isSelected)
                    {
                        isSelected = true;
                        g.DrawLine(new Pen(Color.Red, (float)2), nodeConnector.mark1.Center.X, nodeConnector.mark1.Center.Y, centerMarkX, centerMarkY);
                        g.DrawLine(new Pen(Color.Red, (float)2), centerMarkX, centerMarkY, nodeConnector.mark2.Center.X, nodeConnector.mark2.Center.Y);

                    }
                    else
                    {
                        isSelected = false;
                        g.DrawLine(new Pen(Color.RoyalBlue, (float)2), nodeConnector.mark1.Center.X, nodeConnector.mark1.Center.Y, centerMarkX, centerMarkY);
                        g.DrawLine(new Pen(Color.RoyalBlue, (float)2), centerMarkX, centerMarkY, nodeConnector.mark2.Center.X, nodeConnector.mark2.Center.Y);
                    }
                }
                baseFrame.Invalidate();
                baseFrame.Update();
            }
            g.Dispose();*/
        }
Пример #2
0
        public void handleDrag(object sender, EventArgs e, object panel, Point NewLocation)
        {
            EIBFormDesigner.Controls.EIBPanel panelNew = null;
            Button buttonObject = (Button)sender;
            string text = buttonObject.Text;
            Control ctrl = null;
            EIBMenu menu = null;
            EIBMenuItem menuItem = null;
            EIBTreeNode treeNode = null;
            bool isusercontrol = true;
            if (form.currentBaseWindow.TypeOfWindow == FormDesignerConstants.FormPattern)
            {
                #region Handling New Control Adding
                if (text.Trim().Equals(FormDesignerConstants.PlaceHolderControl))
                {
                    ctrl = (EIBPlaceHolder)toolBox.getControlType(text.Trim());
                    DragDropHandler.RegisterControl(ctrl, true, true);
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.LabelControl))
                {
                    ctrl = (EIBLabel)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.FrameControl))
                {
                    ctrl = (EIBPanel)toolBox.getControlType(text.Trim());
                    DragDropHandler.RegisterControl(ctrl, true, true);
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.JasperControl))
                {
                    ctrl = (EIBJasper)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.RadioGroupControl))
                {
                    ctrl = (EIBRadioGroup)toolBox.getControlType(text.Trim());
                    DragDropHandler.RegisterControl(ctrl, true, true);
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.TextBoxControl))
                {
                    ctrl = (EIBTextBox)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.ButtonControl))
                {
                    ctrl = (EIBButton)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.DatePickerControl))
                {
                    ctrl = (EIBDatePicker)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.TimeControl))
                {
                    ctrl = (EIBTime)toolBox.getControlType(text.Trim());
                    ((EIBTime)ctrl).setTime("0:0:0");
                    ((EIBTime)ctrl).ShowTimeSplit();
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.BrowseControl))
                {
                    ctrl = (EIBBrowse)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.ImageBrowseControl))
                {
                    ctrl = (EIBImageBrowse)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.TreeControl))
                {
                    ctrl = (EIBTreeView)toolBox.getControlType(text.Trim());
                    DragDropHandler.RegisterControl(ctrl, true, true);
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.GridControl))
                {
                    ctrl = (EIBGrid)toolBox.getControlType(text.Trim());
                    DragDropHandler.RegisterControl(ctrl, true, true);
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.MultiTabControl))
                {
                    ctrl = (EIBTabControl)toolBox.getControlType(text.Trim());
                    DragDropHandler.RegisterControl(ctrl, true, true);
                    foreach (EIBTabPage page in ((EIBTabControl)ctrl).TabPages)
                    {
                        addPropertiesControl(page);
                    }
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.TabPage))
                {
                    ctrl = (EIBTabPage)toolBox.getControlType(text.Trim());
                    if (ctrl is EIBTabPage)
                    {
                        ctrl.Text = ctrl.Name;
                    }
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.PictureControl))
                {
                    ctrl = (EIBPicture)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.CheckboxControl))
                {
                    ctrl = (EIBCheckbox)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.RadioControl))
                {
                    ctrl = (EIBRadioButton)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.ComboControl))
                {
                    ctrl = (EIBCombobox)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.PagingControl))
                {
                    ctrl = (EIBPaging)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                /*if (text.Trim().Equals(FormDesignerConstants.MenuBarControl))
                {
                    ctrl = (EIBMenuBar)toolBox.getControlType(text.Trim());
                    DragDropHandler.RegisterControl(ctrl, true, true);
                    isusercontrol = false;
                }*/
                if (text.Trim().Equals(FormDesignerConstants.MenuBarControl))
                {
                    ctrl = (EIBVMenuBar)toolBox.getControlType(text.Trim());
                    DragDropHandler.RegisterControl(ctrl, true, true);
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.CalenderControl))
                {
                    ctrl = (EIBCalender)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.SchedularControl))
                {
                    ctrl = (EIBSchedular)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.AppletControl))
                {
                    ctrl = (EIBApplet)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.LatticeControl))
                {
                    ctrl = (EIBLattice)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.SearchControl))
                {
                    //Handle Search
                    ctrl = (EIBSearch)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.ListControl))
                {
                    //Handle Menu
                    ctrl = (EIBListbox)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }

                if (text.Trim().Equals(FormDesignerConstants.MenuControl))
                {
                    //Handle Menu
                    menu = (EIBMenu)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.MenuItemControl))
                {
                    //Handle Menu
                    menuItem = (EIBMenuItem)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.TreeNodeControl))
                {
                    treeNode = (EIBTreeNode)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.RowControl))
                {
                    ctrl = (EIBRow)toolBox.getControlType(text.Trim());
                    if (currentControl[0] is EIBGrid)
                    {
                        EIBGrid tablePanel = (EIBGrid)currentControl[0];
                        //tablePanel.SuspendLayout();
                        EIBRow rowTable = (EIBRow)ctrl;
                        rowTable.BackColor = Color.Coral;
                        //rowTable.HeightPercent = 0;
                        rowTable.HeightPixel = 30;
                        rowTable.HeightTyp = EIBRow.HeightMeasurement.Pixel;
                        tablePanel.Rows.Add(rowTable);
                        DragDropHandler.RegisterControl(ctrl, true, true);
                    }
                    if (currentControl[0] is EIBLattice)
                    {
                        EIBLattice tablePanel = (EIBLattice)currentControl[0];
                        //tablePanel.SuspendLayout();
                        EIBRow rowTable = (EIBRow)ctrl;
                        rowTable.BackColor = Color.Coral;
                        //rowTable.HeightPercent = 0;
                        rowTable.HeightPixel = 30;
                        rowTable.HeightTyp = EIBRow.HeightMeasurement.Pixel;
                        tablePanel.Rows.Add(rowTable);
                        DragDropHandler.RegisterControl(ctrl, true, true);
                    }
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.ColumnControl))
                {
                    ctrl = (EIBColumn)toolBox.getControlType(text.Trim());
                    if (currentControl[0] is EIBRow && ((EIBRow)currentControl[0]).Parent is EIBGrid)
                    {
                        EIBColumn columnTable = (EIBColumn)ctrl;
                        columnTable.BackColor = Color.Aqua;
                        columnTable.WidthPixel = 50;
                        columnTable.WidthType = WidthMeasurement.Pixel;
                        EIBRow rowTable = (EIBRow)currentControl[0];
                        rowTable.Columns.Add(columnTable);
                        DragDropHandler.RegisterControl(ctrl, true, true);
                    }
                    isusercontrol = false;
                    /*
                    if (currentControl is EIBGrid)
                    {
                        TableLayoutPanel tableLayoutPanel = (TableLayoutPanel)currentControl;
                        tableLayoutPanel.ColumnCount = tableLayoutPanel.ColumnCount + 1;
                        ColumnStyle colStyle =  new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100);
                        tableLayoutPanel.ColumnStyles.Add(colStyle);

                    }
                     */
                }
                if (text.Trim().Equals(FormDesignerConstants.LineControl))
                {
                    ctrl = (EIBLine)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.ConnectorControl))
                {
                    ctrl = (EIBLine)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (isusercontrol &&
                        !text.Trim().Equals(FormDesignerConstants.NodeControl) &&
                        !text.Trim().Equals(FormDesignerConstants.NodeConnectorControl) &&
                        !text.Trim().Equals(FormDesignerConstants.TableControl) &&
                        !text.Trim().Equals(FormDesignerConstants.RelationControl))
                {
                    if (text != form.currentBaseWindow.UniqueID)
                    {
                        if (panel is EIBPlaceHolder)
                        {

                            if (!((EIBPlaceHolder)panel).CheckifAlreadyHave(text))
                            {
                                ctrl = (EIBItem)toolBox.getControlType("Item");
                                ((EIBItem)ctrl).Reference = text;
                                ((EIBItem)ctrl).Text = text;
                            }
                            else
                            {
                                MessageBox.Show("Already contains a usercontrol " + text);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Draw a placeholder to have usercontrol");
                        }
                    }
                    else
                    {
                        MessageBox.Show("You can not drag same usercontrol on same form pattern.");
                    }
                }
                if (form.CurrentBaseWindow != null)
                {
                    form.CurrentBaseWindow.baseFrame.Focus();
                }
                #endregion
            }
            else if (form.currentBaseWindow.TypeOfWindow == FormDesignerConstants.WorkflowPattern)
            {

                isusercontrol = false;
                if (text.Trim().Equals(FormDesignerConstants.NodeControl))
                {
                    ctrl = (EIBNode)toolBox.getControlType(text.Trim());
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.NodeConnectorControl))
                {
                    //ctrl = (EIBRelation)toolBox.getControlType(text.Trim());
                    NodeRelationManager relationManager = new NodeRelationManager();
                    relationManager.currentBaseWindow = form.currentBaseWindow;
                    relationManager.loadWorkflowNodes(form.currentBaseWindow.baseFrame);
                    relationManager.ShowDialog(form);
                    isusercontrol = false;
                    return;
                }
            }
            else if (form.currentBaseWindow.TypeOfWindow == FormDesignerConstants.DataPattern)
            {
                if (text.Trim().Equals(FormDesignerConstants.TableControl))
                {
                    ctrl = (EIBTable)toolBox.getControlType(text.Trim());
                    ((EIBTable)ctrl).DatabaseDataSet = form.currentBaseWindow.DatabaseDataSet;
                    ((TableUserControl)ctrl).afterDragDrop();
                    isusercontrol = false;
                }
                if (text.Trim().Equals(FormDesignerConstants.RelationControl))
                {
                    //ctrl = (EIBRelation)toolBox.getControlType(text.Trim());
                    RelationshipManager relationManager = new RelationshipManager();
                    relationManager.DatabaseDataSet = form.currentBaseWindow.DatabaseDataSet;
                    relationManager.loadDatabaseTable(form.currentBaseWindow.baseFrame);
                    relationManager.ShowDialog(form);
                    isusercontrol = false;
                    return;
                }
            }

                    //userpattern code.
            //isusercontrol = false;
            #region Associate Other Operation.
            if (!form.CurrentBaseWindow.baseFrame.isMouseClick)
            {
                form.currentBaseWindow.baseFrame.MouseClick += new MouseEventHandler(handleControlClick);
                form.CurrentBaseWindow.baseFrame.isMouseClick = true;
            }

            if (ctrl != null)
            {
                pickBox.Add((IEIBControl)ctrl, new PickBox());
                foreach (IEIBControl ctl in currentControl)
                {
                    if (ctl is TreeNode)
                    {
                        if (((TreeNode)ctl).TreeView != null)
                        {
                            if (pickBox.ContainsKey((IEIBControl)((TreeNode)ctl).TreeView))
                                pickBox[(IEIBControl)((TreeNode)ctl).TreeView].HideHandles();
                        }
                    }
                    else
                    {
                        if (pickBox.ContainsKey((IEIBControl)ctl))
                            pickBox[ctl].HideHandles();
                    }
                }

                //if (panel is EIBPlaceHolder)
                //{
                //    parentPanel = (EIBPlaceHolder)panel;
                //    if (ctrl is EIBMenuBar)
                //    {
                //        ((EIBMenuBar)ctrl).Location = new Point(0, 0);
                //        ((EIBMenuBar)ctrl).Height = 25;
                //        ((EIBMenuBar)ctrl).Width = parentPanel.Width;
                //        ((EIBMenuBar)ctrl).Dock = DockStyle.Top;
                //        ((EIBMenuBar)ctrl).Locked = true;
                //    }
                //    parentPanel.Controls.Add(ctrl);
                //}
                if (panel is EIBPanel)
                {
                    if (!(panel is EIBTabControl))
                    {
                        if (ctrl is TabPage)
                        {
                            if (EIBControlCollection.TabPagelist.ContainsKey(ctrl.Text.Trim()))
                            {
                                EIBControlCollection.TabPagelist.Remove(ctrl.Text.Trim());
                                return;
                            }
                        }
                    }
                    parentPanel = (EIBPanel)panel;
                    if (ctrl is EIBMenuBar)
                    {
                        ((EIBMenuBar)ctrl).Location = new Point(0, 0);
                        ((EIBMenuBar)ctrl).Height = 25;
                        ((EIBMenuBar)ctrl).Width = parentPanel.Width;
                        ((EIBMenuBar)ctrl).Dock = DockStyle.Top;
                        ((EIBMenuBar)ctrl).Locked = true;
                    }
                    parentPanel.Controls.Add(ctrl);
                }
                else if (panel is EIBTabControl)
                {
                    parentPanel = (EIBTabControl)panel;
                    EIBTabControl parentTabPanel = (EIBTabControl)panel;
                    if (ctrl is TabPage)
                    {
                        parentTabPanel.TabPages.Add((EIBTabPage)ctrl);
                    }
                    else
                    {
                        if (parentTabPanel.SelectedTab != null)
                        {
                            parentTabPanel.SelectedTab.Controls.Add(ctrl);
                        }
                    }

                }
                else if (panel is EIBColumn)
                {
                    EIBColumn column = (EIBColumn)panel;
                    try
                    {
                        column.Controls.Add(ctrl);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message[0].ToString());
                    }
                }
                else if (panel is EIBRow)
                {
                    EIBRow row = (EIBRow)panel;
                    if (row.Parent is EIBLattice)
                    {
                        try
                        {
                            row.Controls.Add(ctrl);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message[0].ToString());
                        }
                    }
                }
                else if (panel is EIBRadioGroup)
                {
                    parentPanel = (EIBRadioGroup)panel;
                    if (ctrl is EIBRadioButton)
                    {
                        parentPanel.Controls.Add(ctrl);
                    }
                }
                else if (panel is EIBPlaceHolder)
                {
                    parentPanel = (EIBPlaceHolder)panel;
                    if (ctrl is EIBItem)
                    {
                        parentPanel.Controls.Add(ctrl);
                    }
                    else
                    {
                        MessageBox.Show("You can not drag controls in placeholders");
                        return;
                    }
                 }
                ctrl.Cursor = Cursors.HSplit;
                if (!(ctrl is EIBMenuBar || ctrl is EIBRow || ctrl is EIBColumn))
                {
                    ctrl.Left = NewLocation.X + 2;
                    ctrl.Top = NewLocation.Y + 2;
                }

                addPropertiesControl(ctrl);
                //Redo Undo Action
                form.History.Do(new AddControlMemento());
                form.Controlpool.Add((IEIBControl)ctrl,form.CurrentBaseWindow);
                /*******/
                List<IEIBControl> collectionControl = new List<IEIBControl>();
                collectionControl.Add((IEIBControl)ctrl);
                propertiesManager.displayProperties(form.propertyWindow,collectionControl);
                if (!(ctrl is EIBRow || ctrl is EIBColumn))
                {
                    pickBox[(IEIBControl)ctrl].SelectControl(ctrl, new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0));
                }
            }
            #endregion
            #region Other Operation
            if (menu != null)
            {
                if (currentControl.Count == 1)
                {
                    if (currentControl[0] is EIBMenuBar)
                    {
                        currentControl.Clear();
                        currentControl.Add((IEIBControl)menu);
                        menu.Text = "Menu";
                        parentMenuBar = (EIBMenuBar)panel;
                        //parentMenuBar.CurrentToolStrip.Items.Add(menu);
                        if (parentMenuBar.CurrentToolStrip == null)
                        {
                            if(parentMenuBar.Controls.Count >0)
                            {
                                parentMenuBar.CurrentToolStrip = (ToolStrip)parentMenuBar.Controls[0];
                            }
                        }
                        parentMenuBar.CurrentToolStrip.Items.Add(menu);
                        parentMenuBar.CurrentMenu = menu;
                        menu.Click += new EventHandler(handleMenuClick);
                        propertiesManager.displayProperties(form.propertyWindow, currentControl);
                        formulaManager.displayFormulaProperties(form.formulaEditor, currentControl[0]);

                    }
                    else if (currentControl[0] is EIBVMenuBar)
                    {
                        currentControl.Clear();
                        currentControl.Add((IEIBControl)menu);
                        menu.Text = "Menu";
                        if (panel is EIBVMenuBar)
                        {
                            ((EIBVMenuBar)panel).Items.Add(menu);
                            ((EIBVMenuBar)panel).CurrentMenu = menu;
                            menu.Click += new EventHandler(handleMenuClick);
                            propertiesManager.displayProperties(form.propertyWindow, currentControl);
                            formulaManager.displayFormulaProperties(form.formulaEditor, currentControl[0]);
                        }
                    }
                    else if (currentControl[0] is EIBMenu)
                    {
                        EIBMenu myselectedmenu = (EIBMenu)currentControl[0];
                        currentControl.Clear();
                        currentControl.Add((IEIBControl)menu);
                        menu.Text = myselectedmenu.Text + "submenu";
                        if (panel is EIBMenuBar)
                        {
                            parentMenuBar = (EIBMenuBar)panel;
                            //parentMenuBar.CurrentToolStrip.Items.Add(menu);
                            parentMenuBar.CurrentMenu.DropDownItems.Add(menu);
                        }
                        else if (panel is EIBVMenuBar)
                        {
                            ((EIBVMenuBar)panel).CurrentMenu.DropDownItems.Add(menu);
                        }
                        menu.Click += new EventHandler(handleMenuClick);
                        propertiesManager.displayProperties(form.propertyWindow, currentControl);
                        formulaManager.displayFormulaProperties(form.formulaEditor, currentControl[0]);

                    }
                }

            }
            if (menuItem != null)
            {
                if (currentControl[0] is EIBMenuBar)
                {
                    /*currentControl.Clear();
                    currentControl.Add((IEIBControl)menu);
                    menu.Text = "Menu";
                    parentMenuBar = (EIBMenuBar)panel;
                    //parentMenuBar.CurrentToolStrip.Items.Add(menu);
                    if (parentMenuBar.CurrentToolStrip == null)
                    {
                        if (parentMenuBar.Controls.Count > 0)
                        {
                            parentMenuBar.CurrentToolStrip = (ToolStrip)parentMenuBar.Controls[0];
                        }
                    }
                    parentMenuBar.CurrentToolStrip.Items.Add(menu);
                    parentMenuBar.CurrentMenu = menu;
                    menu.Click += new EventHandler(handleMenuClick);
                    propertiesManager.displayProperties(form.propertyWindow, currentControl);
                    formulaManager.displayFormulaProperties(form.formulaEditor, currentControl[0]);
                     */

                }
                else if (currentControl[0] is EIBVMenuBar)
                {
                    currentControl.Clear();
                    currentControl.Add((IEIBControl)menuItem);
                    menuItem.Text = "MenuItem";
                    if (panel is EIBVMenuBar)
                    {
                        if (((EIBVMenuBar)panel).CurrentMenu != null)
                        {
                            ((EIBVMenuBar)panel).CurrentMenu.DropDownItems.Add(menuItem);
                            ((EIBVMenuBar)panel).CurrentMenu.CurrentMenuItem = menuItem;
                            menuItem.Click += new EventHandler(handleMenuItemClick);
                            propertiesManager.displayProperties(form.propertyWindow, currentControl);
                            formulaManager.displayFormulaProperties(form.formulaEditor, currentControl[0]);
                        }
                        else
                        {
                            MessageBox.Show("Please select a menu.");
                        }
                    }
                }
                else if (currentControl[0] is EIBMenu)
                {
                    EIBMenu myselectedmenu = (EIBMenu)currentControl[0];
                    currentControl.Clear();
                    currentControl.Add((IEIBControl)menuItem);
                    menuItem.Text = myselectedmenu.Text + "submenuitem";
                    if (panel is EIBVMenuBar)
                    {
                        ((EIBVMenuBar)panel).CurrentMenu.DropDownItems.Add(menuItem);
                    }
                    menuItem.Click += new EventHandler(handleMenuItemClick);
                    propertiesManager.displayProperties(form.propertyWindow, currentControl);
                    formulaManager.displayFormulaProperties(form.formulaEditor, currentControl[0]);

                }

            }
            if (treeNode != null && (currentControl[0] is EIBTreeView))
            {
                EIBTreeView treeView = (EIBTreeView)currentControl[0];
                treeView.Nodes.Add(treeNode);
                IEIBControl currentEIBControl = (IEIBControl)treeNode;
                form.currentBaseWindow.CurrentControl.Clear();
                form.currentBaseWindow.CurrentControl.Add(currentEIBControl);
                currentControl.Clear();
                currentControl.Add(treeNode) ;
                propertiesManager.displayProperties(form.propertyWindow, treeNode);
                formulaManager.displayFormulaProperties(form.formulaEditor, currentEIBControl);
            }
            if (treeNode != null && (currentControl[0] is EIBTreeNode))
            {
                EIBTreeNode treeNodeParent = (EIBTreeNode)currentControl[0];
                if (!treeNodeParent.Equals(treeNode))
                {
                    treeNodeParent.Nodes.Add(treeNode);
                }
                IEIBControl currentEIBControl = (IEIBControl)treeNode;
                form.currentBaseWindow.CurrentControl.Clear();
                form.currentBaseWindow.CurrentControl.Add(currentEIBControl) ;
                currentControl.Clear();
                currentControl.Add(treeNode);
                propertiesManager.displayProperties(form.propertyWindow, treeNode);
                formulaManager.displayFormulaProperties(form.formulaEditor, currentEIBControl);
            }
            LoadControls(form.currentBaseWindow.baseFrame);
            form.Invalidate();
            form.ResumeLayout(false);
            #endregion
        }