/// <summary>write the code for the designer file where the properties of the control are written</summary>
        public override ProcessTemplate SetControlProperties(TFormWriter writer, TControlDef ctrl)
        {
            // first create the hosted control
            string      hostedControlName = TYml2Xml.GetAttribute(ctrl.xmlNode, "HostedControl");
            TControlDef hostedCtrl        = FCodeStorage.FindOrCreateControl(hostedControlName, ctrl.controlName);

            IControlGenerator ctrlGenerator = writer.FindControlGenerator(hostedCtrl);

            // add control itself
            if ((hostedCtrl != null) && (ctrlGenerator != null))
            {
                ctrlGenerator.SetControlProperties(writer, hostedCtrl);
            }

            return(base.SetControlProperties(writer, ctrl));
        }
示例#2
0
        /// <summary>
        /// insert the buttons for the form, eg. submit button, cancel button, etc
        /// </summary>
        /// <param name="ACtrl"></param>
        /// <param name="ATemplate"></param>
        /// <param name="AItemsPlaceholder"></param>
        /// <param name="AWriter"></param>
        public static void InsertButtons(TControlDef ACtrl, ProcessTemplate ATemplate, string AItemsPlaceholder, TFormWriter AWriter)
        {
            StringCollection children = TYml2Xml.GetElements(ACtrl.xmlNode, "Buttons");

            foreach (string child in children)
            {
                TControlDef       childCtrl = AWriter.FCodeStorage.FindOrCreateControl(child, ACtrl.controlName);
                IControlGenerator ctrlGen   = AWriter.FindControlGenerator(childCtrl);

                ProcessTemplate ctrlSnippet           = ctrlGen.SetControlProperties(AWriter, childCtrl);
                ProcessTemplate snippetCellDefinition = AWriter.FTemplate.GetSnippet("CELLDEFINITION");

                LayoutCellInForm(childCtrl, -1, ctrlSnippet, snippetCellDefinition);

                ATemplate.InsertSnippet(AItemsPlaceholder, ctrlSnippet, ",");
            }
        }
示例#3
0
        /// <summary>write the code for the designer file where the properties of the control are written</summary>
        public override ProcessTemplate SetControlProperties(TFormWriter writer, TControlDef ctrl)
        {
            ProcessTemplate snippetRowDefinition = writer.FTemplate.GetSnippet(FControlDefinitionSnippetName);

            ((TExtJsFormsWriter)writer).AddResourceString(snippetRowDefinition, "LABEL", ctrl, ctrl.Label);

            StringCollection Controls = FindContainedControls(writer, ctrl.xmlNode);

            snippetRowDefinition.AddToCodelet("ITEMS", "");

            if (Controls.Count > 0)
            {
                // used for radiogroupbox
                foreach (string ChildControlName in Controls)
                {
                    TControlDef       childCtrl   = FCodeStorage.FindOrCreateControl(ChildControlName, ctrl.controlName);
                    IControlGenerator ctrlGen     = writer.FindControlGenerator(childCtrl);
                    ProcessTemplate   ctrlSnippet = ctrlGen.SetControlProperties(writer, childCtrl);

                    ctrlSnippet.SetCodelet("COLUMNWIDTH", "");

                    ctrlSnippet.SetCodelet("ITEMNAME", ctrl.controlName);
                    ctrlSnippet.SetCodelet("ITEMID", childCtrl.controlName);

                    if (ctrl.GetAttribute("hideLabel") == "true")
                    {
                        ctrlSnippet.SetCodelet("HIDELABEL", "true");
                    }
                    else if (ChildControlName == Controls[0])
                    {
                        ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "LABEL", ctrl, ctrl.Label);
                    }

                    snippetRowDefinition.InsertSnippet("ITEMS", ctrlSnippet, ",");
                }
            }
            else
            {
                // used for GroupBox, and Composite
                TExtJsFormsWriter.InsertControl(ctrl, snippetRowDefinition, "ITEMS", "HiddenValues", writer);
                TExtJsFormsWriter.InsertControl(ctrl, snippetRowDefinition, "ITEMS", "Controls", writer);
            }

            return(snippetRowDefinition);
        }
示例#4
0
        /// <summary>
        /// main function for creating a control
        /// </summary>
        /// <param name="ACtrl"></param>
        /// <param name="ATemplate"></param>
        /// <param name="AItemsPlaceholder"></param>
        /// <param name="ANodeName"></param>
        /// <param name="AWriter"></param>
        public static void InsertControl(TControlDef ACtrl,
                                         ProcessTemplate ATemplate,
                                         string AItemsPlaceholder,
                                         string ANodeName,
                                         TFormWriter AWriter)
        {
            XmlNode controlsNode = TXMLParser.GetChild(ACtrl.xmlNode, ANodeName);

            List <XmlNode> childNodes = TYml2Xml.GetChildren(controlsNode, true);

            if ((childNodes.Count > 0) && childNodes[0].Name.StartsWith("Row"))
            {
                foreach (XmlNode row in TYml2Xml.GetChildren(controlsNode, true))
                {
                    ProcessTemplate snippetRowDefinition = AWriter.FTemplate.GetSnippet("ROWDEFINITION");

                    StringCollection children = TYml2Xml.GetElements(controlsNode, row.Name);

                    foreach (string child in children)
                    {
                        TControlDef       childCtrl             = AWriter.FCodeStorage.FindOrCreateControl(child, ACtrl.controlName);
                        IControlGenerator ctrlGen               = AWriter.FindControlGenerator(childCtrl);
                        ProcessTemplate   ctrlSnippet           = ctrlGen.SetControlProperties(AWriter, childCtrl);
                        ProcessTemplate   snippetCellDefinition = AWriter.FTemplate.GetSnippet("CELLDEFINITION");

                        LayoutCellInForm(childCtrl, children.Count, ctrlSnippet, snippetCellDefinition);

                        if ((children.Count == 1) && ctrlGen is RadioGroupSimpleGenerator)
                        {
                            // do not use the ROWDEFINITION, but insert control directly
                            // this helps with aligning the label for the group radio buttons
                            snippetRowDefinition.InsertSnippet("ITEMS", ctrlSnippet, ",");
                        }
                        else
                        {
                            snippetCellDefinition.InsertSnippet("ITEM", ctrlSnippet);
                            snippetRowDefinition.InsertSnippet("ITEMS", snippetCellDefinition, ",");
                        }
                    }

                    ATemplate.InsertSnippet(AItemsPlaceholder, snippetRowDefinition, ",");
                }
            }
            else
            {
                foreach (XmlNode childNode in childNodes)
                {
                    string      child     = TYml2Xml.GetElementName(childNode);
                    TControlDef childCtrl = AWriter.FCodeStorage.FindOrCreateControl(child, ACtrl.controlName);

                    if ((ANodeName != "HiddenValues") && (childCtrl.controlTypePrefix == "hid"))
                    {
                        // somehow, hidden values get into the controls list as well. we don't want them there
                        continue;
                    }

                    IControlGenerator ctrlGen = AWriter.FindControlGenerator(childCtrl);

                    if (ctrlGen is FieldSetGenerator)
                    {
                        InsertControl(AWriter.FCodeStorage.FindOrCreateControl(child,
                                                                               ACtrl.controlName), ATemplate, AItemsPlaceholder, ANodeName, AWriter);
                    }
                    else
                    {
                        ProcessTemplate ctrlSnippet           = ctrlGen.SetControlProperties(AWriter, childCtrl);
                        ProcessTemplate snippetCellDefinition = AWriter.FTemplate.GetSnippet("CELLDEFINITION");

                        LayoutCellInForm(childCtrl, -1, ctrlSnippet, snippetCellDefinition);

                        ATemplate.InsertSnippet(AItemsPlaceholder, ctrlSnippet, ",");
                    }
                }
            }
        }