//Deserialize individual base windows and there child control
        public static void DeserializeWindowXML(string fileName, Control baseFrame, XmlNode parentXMLNode)
        {
            XmlDocument doc = new XmlDocument();
            XmlNode currentXmlNode = null;
            EIBGrid grid = null;
            EIBLattice lattice = null;
            try
            {

                // disabling re-drawing of treeview till all nodes are added
                fileName = fileName + ".xml";
                if (parentXMLNode == null)
                {
                    doc.Load(fileName);
                    currentXmlNode = doc.FirstChild;
                    baseFrame.Controls.Clear();
                }
                else
                {
                    currentXmlNode = parentXMLNode;
                }
                // baseFrame.Controls.Clear();
                if (currentXmlNode.Name == FormDesignerConstants.BaseWindow)
                {
                    // loading node attributes
                    UpdateControlProperties(baseFrame, currentXmlNode);
                    ((EIBPanel)baseFrame).AutoScroll = true;
                }
                foreach (XmlNode xmlNode in currentXmlNode.ChildNodes)
                {
                    #region Desearilization for each control
                    if (xmlNode.NodeType == XmlNodeType.Element)
                    {

                        if (xmlNode.Name == FormDesignerConstants.TextBoxControl)
                        {
                            EIBTextBox newNode = new EIBTextBox();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBTextBox.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.SchedularControl)
                        {
                            EIBSchedular newNode = new EIBSchedular();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBSchedular.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.AppletControl)
                        {
                            EIBApplet newNode = new EIBApplet();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBApplet.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.ButtonControl)
                        {
                            EIBButton newNode = new EIBButton();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBButton.counter++;
                            //UIEventManager.form.Controlpool.Add(newNode,);
                        }
                        if (xmlNode.Name == FormDesignerConstants.JasperControl)
                        {
                            EIBJasper newNode = new EIBJasper();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBJasper.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.DatePickerControl)
                        {
                            EIBDatePicker newNode = new EIBDatePicker();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBDatePicker.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.TimeControl)
                        {
                            EIBTime newNode = new EIBTime();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            newNode.ShowTimeSplit();
                            EIBTime.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.CalenderControl)
                        {
                            EIBCalender newNode = new EIBCalender();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBCalender.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.LabelControl)
                        {
                            EIBLabel newNode = new EIBLabel();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBLabel.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.RadioControl)
                        {
                            EIBRadioButton newNode = new EIBRadioButton();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBRadioButton.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.CheckboxControl)
                        {
                            EIBCheckbox newNode = new EIBCheckbox();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBCheckbox.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.ComboControl)
                        {
                            EIBCombobox newNode = new EIBCombobox();
                            UpdateControlProperties(newNode, xmlNode);
                            UpdateComboBoxValues(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBCombobox.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.PagingControl)
                        {
                            EIBPaging newNode = new EIBPaging();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBPaging.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.ImageBrowseControl)
                        {
                            EIBImageBrowse newNode = new EIBImageBrowse();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBImageBrowse.counter++;
                        }
                        /*if (xmlNode.Name == FormDesignerConstants.MenuBarControl)
                        {
                            EIBMenuBar.counter++;
                            EIBMenuBar newNode = new EIBMenuBar();
                            UpdateControlProperties(newNode, xmlNode);
                            UpdateMenuValues(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            newNode.Height = 25;
                            newNode.Width = newNode.Parent.Width;
                            newNode.CurrentToolStrip.Dock = DockStyle.Fill;
                            DragDropHandler.RegisterControl(newNode, true, true);
                            newNode.Click += new EventHandler(FormDesigner.eventManager.handleMenuClick);
                            currentControl = newNode;
                        }*/
                        if (xmlNode.Name == FormDesignerConstants.MenuBarControl)
                        {
                            EIBVMenuBar newNode = new EIBVMenuBar();
                            UpdateControlProperties(newNode, xmlNode);
                            UpdateMenuValues(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            newNode.Dock = DockStyle.None;
                            baseFrame.Controls.Add(newNode);
                            DragDropHandler.RegisterControl(newNode, true, true);
                            newNode.PerformLayout();
                            //newNode.Size = new Size(30, 30);
                            //newNode.Click += new EventHandler(FormDesigner.eventManager.handleMenuClick);
                            currentControl = newNode;
                            EIBVMenuBar.counter++;

                        }
                        if (xmlNode.Name == FormDesignerConstants.FrameControl)
                        {
                            EIBPanel newNode = new EIBPanel();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBDeserializeServices.DeserializeWindowXML(null, newNode, xmlNode);
                            DragDropHandler.RegisterControl(newNode, true, true);
                            Console.Write("Done with Frame");
                            EIBPanel.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.PlaceHolderControl)
                        {
                            EIBPlaceHolder newNode = new EIBPlaceHolder();

                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBDeserializeServices.DeserializeWindowXML(null, newNode, xmlNode);
                            DragDropHandler.RegisterControl(newNode, true, true);
                            Console.Write("Done with PlaceHolder");
                            EIBPlaceHolder.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.UserControl)
                        {
                            EIBItem newNode = new EIBItem();

                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            //EIBDeserializeServices.DeserializeWindowXML(null, newNode, xmlNode);
                            //DragDropHandler.RegisterControl(newNode, true, true);
                            Console.Write("Done with Item");
                            EIBItem.counter++;
                        }

                        if (xmlNode.Name == FormDesignerConstants.RadioGroupControl)
                        {
                            EIBRadioGroup newNode = new EIBRadioGroup();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBDeserializeServices.DeserializeWindowXML(null, newNode, xmlNode);
                            DragDropHandler.RegisterControl(newNode, true, true);
                            //Console.Write("Done with EIBradioGroup");
                            EIBRadioGroup.counter++;
                        }

                        if (xmlNode.Name == FormDesignerConstants.PictureControl)
                        {
                            EIBPicture newNode = new EIBPicture();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBPicture.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.GridControl)
                        {
                            EIBGrid newNode = new EIBGrid();
                            UpdateControlProperties(newNode, xmlNode);
                            currentControl = newNode;
                            baseFrame.Controls.Add(newNode);
                            DragDropHandler.RegisterControl(newNode, true, true);
                            EIBDeserializeServices.DeserializeWindowXML(null, newNode, xmlNode);
                            EIBGrid.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.LatticeControl)
                        {
                            EIBLattice newNode = new EIBLattice();
                            UpdateControlProperties(newNode, xmlNode);
                            currentControl = newNode;
                            baseFrame.Controls.Add(newNode);
                            DragDropHandler.RegisterControl(newNode, true, true);
                            EIBDeserializeServices.DeserializeWindowXML(null, newNode, xmlNode);
                            EIBLattice.counter++;
                        }
                        if (xmlNode.Name.Trim().Equals(FormDesignerConstants.RowControl, StringComparison.CurrentCultureIgnoreCase))
                        {
                            EIBRow newNode = new EIBRow();
                            if (currentControl is EIBGrid)
                            {
                                if (currentControl is EIBGrid)
                                {
                                    grid = (EIBGrid)currentControl;
                                    UpdateControlProperties(newNode, xmlNode);
                                    DragDropHandler.RegisterControl(newNode, true, true);
                                    grid.Rows.Add(newNode);
                                    currentControl = newNode;
                                    EIBDeserializeServices.DeserializeWindowXML(null, newNode, xmlNode);
                                    EIBRow.counter++;
                                }
                            }

                        }
                        //added for LROW
                        if (xmlNode.Name.Trim().Equals(FormDesignerConstants.LRowControl, StringComparison.CurrentCultureIgnoreCase))
                        {
                            EIBRow newNode = new EIBRow();
                            if (currentControl is EIBLattice)
                            {
                                if (currentControl is EIBLattice)
                                {
                                    lattice = (EIBLattice)currentControl;
                                    UpdateControlProperties(newNode, xmlNode);
                                    DragDropHandler.RegisterControl(newNode, true, true);
                                    lattice.Rows.Add(newNode);
                                    IEIBControl parent = currentControl;
                                    currentControl = newNode;
                                    EIBDeserializeServices.DeserializeWindowXML(null, newNode, xmlNode);
                                    currentControl = parent;
                                    EIBRow.counter++;
                                }
                            }

                        }
                        if (xmlNode.Name.Trim().Equals(FormDesignerConstants.ColumnControl, StringComparison.CurrentCultureIgnoreCase))
                        {
                            EIBColumn newNode = new EIBColumn();
                            if (currentControl is EIBRow)
                            {
                                EIBRow row = (EIBRow)currentControl;
                                row.Columns.Add(newNode);
                                DragDropHandler.RegisterControl(newNode, true, true);
                                UpdateControlProperties(newNode, xmlNode);
                            }
                            EIBDeserializeServices.DeserializeWindowXML(null, newNode, xmlNode);
                            EIBColumn.counter++;
                        }
                        //added for LCOLUMN
                        if (xmlNode.Name.Trim().Equals(FormDesignerConstants.LColumnControl, StringComparison.CurrentCultureIgnoreCase))
                        {
                            EIBColumn newNode = new EIBColumn();
                            if (currentControl is EIBRow)
                            {
                                EIBRow row = (EIBRow)currentControl;
                                row.Columns.Add(newNode);
                                DragDropHandler.RegisterControl(newNode, true, true);
                                UpdateControlProperties(newNode, xmlNode);
                            }
                            EIBDeserializeServices.DeserializeWindowXML(null, newNode, xmlNode);
                            EIBColumn.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.ListControl)
                        {
                            EIBListbox newNode = new EIBListbox();
                            UpdateControlProperties(newNode, xmlNode);
                            UpdateListBoxValues(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBListbox.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.MultiTabControl)
                        {
                            EIBTabControl newNode = new EIBTabControl();
                            UpdateControlProperties(newNode, xmlNode);
                            //newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBDeserializeServices.DeserializeWindowXML(null, newNode, xmlNode);
                            DragDropHandler.RegisterControl(newNode, true, true);
                            EIBTabControl.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.TreeNodeControl)
                        {
                            EIBTreeNode newNode = new EIBTreeNode();
                            currentTreeControl = null;
                            UpdateTreeNodeProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            if ((currentControl != null) && (currentControl is EIBTreeView))
                            {
                                if (!(((EIBTreeView)currentControl).Nodes.Contains(newNode)))
                                {
                                    ((EIBTreeView)currentControl).Nodes.Add(newNode);
                                }
                            }
                            //baseFrame.Controls.Add(newNode);
                            EIBTreeNode.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.TabPage)
                        {
                            EIBTabPage newNode = new EIBTabPage();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            EIBDeserializeServices.DeserializeWindowXML(null, newNode, xmlNode);
                            EIBTabPage.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.TreeControl)
                        {
                            EIBTreeView newNode = new EIBTreeView();
                            UpdateControlProperties(newNode, xmlNode);
                            newNode.InitiateSettings(null);
                            baseFrame.Controls.Add(newNode);
                            currentControl = newNode;
                            EIBDeserializeServices.DeserializeWindowXML(null, newNode, xmlNode);
                            DragDropHandler.RegisterControl(newNode, true, true);
                            EIBTreeView.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.SearchControl)
                        {
                            EIBSearch eibSearch = new EIBSearch();
                            UpdateControlProperties(eibSearch, xmlNode);
                            eibSearch.SearchDesign = new EIBFormDesigner.Search.SearchDesigner(baseFrame);
                            eibSearch.SearchDesign.initSearchFrame(baseFrame);
                            UpdateSearchProperties(eibSearch.SearchDesign, xmlNode);
                            baseFrame.Controls.Add(eibSearch);
                            EIBSearch.counter++;
                        }
                        if (xmlNode.Name == FormDesignerConstants.BrowseControl)
                        {
                            EIBBrowse eibBrowse = new EIBBrowse();
                            UpdateControlProperties(eibBrowse, xmlNode);
                            eibBrowse.InitiateSettings(null);
                            baseFrame.Controls.Add(eibBrowse);
                            EIBBrowse.counter++;
                        }
                    }
                    #endregion
                    // moving up to in TreeView if end tag is encountered
                }
            }
            catch (FileNotFoundException ex)
            {
                MessageBox.Show("The File " + ex.FileName + " not found.");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Occured.\n Xml File Was Modified."+ex.Message);
            }
            finally
            {

            }
        }
Example #2
0
        public static object CreateControl(string ctrlName, string partialName)
        {
            try
            {
                Control ctrl = null;
                //ToolStripMenuItem menu;
                //ToolStripButton menuItem;
                switch (ctrlName)
                {
                    case "EIBButton":
                        ctrl = new EIBButton();
                        break;
                    case "EIBApplet":
                        ctrl = new EIBApplet();
                        break;
                    case "EIBLattice":
                        ctrl = new EIBLattice();
                        break;
                    case "EIBSchedular":
                        ctrl = new EIBSchedular();
                        break;
                    case "EIBDatePicker":
                        ctrl = new EIBDatePicker();
                        break;
                    case "EIBTime":
                        ctrl = new EIBTime();
                        break;
                    case "EIBCheckbox":
                        ctrl = new EIBCheckbox();
                        break;
                    case "EIBCombobox":
                        ctrl = new EIBCombobox();
                        break;
                    case "EIBLabel":
                        ctrl = new EIBLabel();
                        break;
                    case "EIBLine":
                        ctrl = new EIBLine();
                        break;
                    case "EIBPanel":
                        ctrl = new EIBPanel();
                        DragDropHandler.RegisterControl(ctrl, true, true);
                        break;
                    case "EIBJasper":
                        ctrl = new EIBJasper();
                        break;
                    case "EIBRadioGroup":
                        ctrl = new EIBRadioGroup();
                        DragDropHandler.RegisterControl(ctrl, true, true);
                        break;
                    case "EIBPicture":
                        ctrl = new EIBPicture();
                        break;
                    case "EIBRadioButton":
                        ctrl = new EIBRadioButton();
                        break;
                    case "EIBTabControl":
                        ctrl = new EIBTabControl();
                        DragDropHandler.RegisterControl(ctrl, true, true);
                        break;
                    case "EIBTabPage":
                        ctrl = new EIBTabPage();
                        DragDropHandler.RegisterControl(ctrl, true, true);
                        break;
                    case "EIBSearch":
                        ctrl = new EIBSearch();
                        break;
                    case "EIBListbox":
                        ctrl = new EIBListbox();
                        break;
                    case "EIBGrid":
                        ctrl = new EIBGrid();
                        DragDropHandler.RegisterControl(ctrl, true, true);
                        break;
                    case "EIBTable":
                        ctrl = new EIBTable();
                        break;
                    case "EIBRelation":
                        ctrl = new EIBRelation();
                        break;
                    case "EIBTextBox":
                        ctrl = new EIBTextBox();
                        break;
                    case "EIBTreeView":
                        ctrl = new EIBTreeView();
                        break;
                    case "EIBMenuBar":
                        ctrl = new EIBMenuBar(false);
                        DragDropHandler.RegisterControl(ctrl, true, true);
                        break;
                    case "EIBNode":
                        ctrl = new EIBNode();
                        break;
                    case "EIBNodeRelation":
                        ctrl = new EIBNodeRelation();
                        break;
                    case "EIBColumn":
                        ctrl = new EIBColumn();
                        DragDropHandler.RegisterControl(ctrl, true, true);
                        break;
                    case "EIBScrollableRow":
                        ctrl = new EIBScrollableRow();
                        DragDropHandler.RegisterControl(ctrl, true, true);
                        break;
                    case "EIBBrowse":
                        ctrl = new EIBBrowse();
                        break;
                    case "EIBVMenuBar":
                        ctrl = new EIBVMenuBar(false);
                        DragDropHandler.RegisterControl(ctrl, true, true);
                        break;
                    case "EIBMenu":
                        return new EIBMenu();
                    case "EIBMenuItem":
                        return new EIBMenuItem();
                    /*
                                        case "EIBTreeNode":
                                            ctrl = new EIBTreeNode();
                                            break;
                    */
                    default:
                        Assembly controlAsm = Assembly.LoadWithPartialName(partialName);
                        Type controlType = controlAsm.GetType(partialName + "." + ctrlName);
                        ctrl = (Control)Activator.CreateInstance(controlType);
                        break;

                }

                return ctrl;

            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("create control failed:" + ex.Message);
                return new Control();
            }
        }
Example #3
0
 public static void saveXMLofLattice(EIBLattice latticeControl)
 {
     int rowCount = latticeControl.Rows.Count;
     XmlNode xmlNode = null;
     for (int rowCounter = 0; rowCounter < rowCount; rowCounter++)
     {
         EIBRow row = latticeControl.Rows[rowCounter];
         int columnCount = row.Columns.Count;
         Hashtable controlProperties = XMLServices.updateSettings(row, row.ControlName, row.Name.ToLower());
         controlProperties.Add(XMLServicesConstants.XmlNodeSizeTypeAtt, row.HeightTyp.ToString());
         xmlNode = XMLServices.writeElement(((IEIBControl)latticeControl).ParentXmlNode, row.ControlType, controlProperties, null, null);
         row.ParentXmlNode = xmlNode;
         for (int colCounter = 0; colCounter < columnCount; colCounter++)
         {
             //XmlNode columnNode = null;
             Control control = row.Columns[colCounter];
             saveXMLofControl(control, null);
             //Hashtable columnProperties = XMLServices.updateSettings(column, ((IEIBControl)column).ControlName, column.Name.ToLower());
             //columnProperties[XMLServicesConstants.XmlNodeVisibleAtt] = true.ToString().ToLower();
             //columnNode = XMLServices.writeElement(((IEIBControl)row).ParentXmlNode, ((IEIBControl)column).ControlType, columnProperties, null, null);
             //((IEIBControl)column).ParentXmlNode = columnNode;
             //foreach (Control control in column.Controls)
             //{
             //    if (control != null)
             //    {
             //        saveXMLofControl(control, ((IEIBControl)column).ParentXmlNode);
             //    }
             //}
         }
     }
 }