Exemple #1
0
        static public CTabControl BuildCTabControl(Control parent)
        {
            while (model.allControls.Exists(l => l.cd.Name == "CTabControl" + CTabControl.count))
            {
                CTabControl.count++;
            }
            CTabControl c = new CTabControl();

            parent.Controls.Add(c);

            SetCommonHandlers(c);
            c.AllowDrop = true;

            c.SetControlDescription();
            c.cd.RealText = c.cd.Text;
            //c.SelectedIndexChanged += IndexChanged;

            Model.getInstance().allControls.Add(c);
            model.logCreator.Append("+ Added: " + c.cd.Name);

            return(c);
        }
Exemple #2
0
        private void CreatePreviewControls(Section s, XElement i)
        {
            if (s == null)
            {
                return;
            }
            if (i == null)
            {
                return;
            }

            switch (i.Attribute("type").Value)
            {
            case "CLabel":
                CLabel lbl = ControlFactory.BuildCLabel(s.Tab);
                lbl.cd.Name = i.Element("Name").Value;
                break;

            case "CComboBox":
                CComboBox cb = ControlFactory.BuildCComboBox(s.Tab);
                cb.cd.Name = i.Element("Name").Value;
                break;

            case "CButton":
                CButton b = ControlFactory.BuildCButton(s.Tab);
                b.cd.Name = i.Element("Name").Value;
                break;

            case "CGroupBox":
                CGroupBox gb = ControlFactory.BuildCGroupBox(s.Tab);
                gb.cd.Name = i.Element("Name").Value;
                break;

            case "CPanel":
                CPanel pl = ControlFactory.BuildCPanel(s.Tab);
                pl.cd.Name = i.Element("Name").Value;
                break;

            case "CBitmap":
                CBitmap bm = ControlFactory.BuildCBitmap(s.Tab);
                bm.cd.Name = i.Element("Name").Value;
                break;

            case "CTextBox":
                CTextBox tb = ControlFactory.BuildCTextBox(s.Tab);
                tb.cd.Name = i.Element("Name").Value;
                break;

            case "CCheckBox":
                CCheckBox ccb = ControlFactory.BuildCCheckBox(s.Tab);
                ccb.cd.Name = i.Element("Name").Value;
                break;

            case "CTabControl":
                CTabControl ctc = ControlFactory.BuildCTabControl(s.Tab);
                ctc.cd.Name = i.Element("Name").Value;
                break;

            case "CTabPage":
                //Tab pages require its parent TabControl to be created first.
                break;
            }
        }
Exemple #3
0
        private void CreateDefinedControls(XDocument xdoc)
        {
            List <XContainer> CTabs        = new List <XContainer>();
            List <XContainer> CTabControls = new List <XContainer>();

            this.xdoc = xdoc;
            var items = from item in this.xdoc.Descendants("Controls")
                        .Descendants("Control")
                        select item;

            // Create a "preview" of the controls.
            // Everyone is assigned a section as its parent.
            foreach (var i in items)
            {
                if (i.Attribute("type").Value == "CTabPage")
                {
                    CTabs.Add(i);
                }
                else
                {
                    Section s = model.sections.Find(se => se.Name == i.Element("Section").Value);
                    CreatePreviewControls(s, i);
                }
            }

            // CTabControls are created and in place.
            // Now it's time to set the Custom Tabs.
            if (CTabs.Count > 0)
            {
                foreach (XElement e in CTabs)
                {
                    CTabControl parentControl = model.allControls.Find(p => p.cd.Name == e.Element("Parent").Value) as CTabControl;
                    CTabPage    ctp           = ControlFactory.BuildCTabPage(parentControl);
                    ctp.cd.Name     = e.Element("Name").Value;
                    ctp.cd.RealText = e.Element("Text").Value;
                }
            }

            int incPerItem = 90 / items.Count();

            progress = 10;
            //Fill out the controls with the info from ObjectDefinition.xml
            foreach (var i in items)
            {
                foreach (ICustomControl c in model.allControls)
                {
                    if (c.cd.Name == i.Element("Name").Value)
                    {
                        try
                        {
                            SetRealParent(c, i as XContainer);
                            SetRealProperties(c, i);
                            SetPaths(c, i);
                            SetControlSpecificProperties(c, i);

                            SetRelatedReadList(c, i);
                            SetRelatedVisibility(c, i);
                            SetCoupledControls(c, i);
                        }
                        catch (Exception e)
                        {
                            String caption = Model.GetTranslationFromID(37);
                            String msg     = Model.GetTranslationFromID(47) + " " + Model.GetTranslationFromID(52);
                            MessageBox.Show(msg, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);

                            model.logCreator.Append("Creating: " + c.cd.Name);
                            model.logCreator.Append(msg);
                            model.logCreator.Append(e.ToString());

                            System.Environment.Exit(1);
                        }

                        ReadRelationManager.ReadConfiguration(c);
                        ApplyRights(c);
                        model.ApplyRelations(c);

                        if (c.cd.Format != "")
                        {
                            ApplyFormats(c);
                        }
                        if (c is CTabControl)
                        {
                            try
                            {
                                SetSelectedTab(c, i);
                            }
                            catch (Exception e)
                            {
                                String caption = Model.GetTranslationFromID(37);
                                String msg     = Model.GetTranslationFromID(47) + " " + Model.GetTranslationFromID(52);
                                MessageBox.Show(msg, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);

                                model.logCreator.Append("Setting tab: " + c.cd.Name);
                                model.logCreator.Append(msg);
                                model.logCreator.Append(e.ToString());

                                System.Environment.Exit(1);
                            }
                        }
                        c.cd.Changed = false;
                        System.Diagnostics.Debug.WriteLine("+ Added : " + c.cd.Name + " with parent: " + c.cd.Parent.Name + " in Section: " + c.cd.ParentSection.Name);
                    }
                    // Update the Splash Screen
                    progress += incPerItem;
                }
            }

            model.ApplyRightsToControls();
            model.ApplyRightsToSections();
        }