예제 #1
0
        static public CTabPage BuildCTabPage(Control parent)
        {
            while (model.allControls.Exists(l => l.cd.Name == "CTabPage" + CTabPage.count))
            {
                CTabPage.count++;
            }
            CTabPage c = new CTabPage();

            parent.Controls.Add(c);
            (parent as CTabControl).SelectedTab = c;

            SetCommonHandlers(c);
            SetDragDropHandlers(c);

            Model.getInstance().allControls.Add(c);
            c.SetControlDescription();
            c.Parent = parent;

            c.cd.RealText = c.cd.Text;

            model.logCreator.Append("+ Added: " + c.cd.Name);
            return(c);
        }
예제 #2
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();
        }