Пример #1
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;
        }
Пример #2
0
        /// <summary>
        /// generate the children, and write the size of this control
        /// </summary>
        public override void ProcessChildren(TFormWriter writer, TControlDef ctrl)
        {
            XmlNode Controls = TXMLParser.GetChild(ctrl.xmlNode, "Controls");

            if (Controls != null)
            {
                StringCollection childControls = TYml2Xml.GetElements(Controls);

                // this is a checkbox that enables another control or a group of controls
                ctrl.SetAttribute("GenerateWithOtherControls", "yes");

                if (childControls.Count == 1)
                {
                    TControlDef ChildCtrl = ctrl.FCodeStorage.GetControl(childControls[0]);
                    ChildCtrl.parentName = ctrl.controlName;
                    ctrl.Children.Add(ChildCtrl);

                    ChildCtrl.SetAttribute("DependsOnRadioButton", "true");

                    // use the label of the child control
                    if (ChildCtrl.HasAttribute("Label"))
                    {
                        ctrl.Label = ChildCtrl.Label;
                    }
                }
                else
                {
                    foreach (string child in childControls)
                    {
                        TControlDef ChildCtrl = ctrl.FCodeStorage.GetControl(child);

                        if (ChildCtrl == null)
                        {
                            throw new Exception("cannot find control " + child + " which should belong to " + ctrl.controlName);
                        }

                        ChildCtrl.parentName = ctrl.controlName;
                        ctrl.Children.Add(ChildCtrl);

                        ChildCtrl.SetAttribute("DependsOnRadioButton", "true");

                        IControlGenerator ctrlGenerator = writer.FindControlGenerator(ChildCtrl);
                        ctrlGenerator.GenerateControl(writer, ChildCtrl);
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// create the code
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="ctrl"></param>
        public void InsertControl(TFormWriter writer, TControlDef ctrl)
        {
            IControlGenerator ctrlGenerator = writer.FindControlGenerator(ctrl);

            string controlName = ctrl.controlName;

            if (FOrientation == eOrientation.TableLayout)
            {
                if (FCurrentRow != ctrl.rowNumber)
                {
                    FCurrentColumn = 0;
                    FCurrentRow = ctrl.rowNumber;
                }
            }

/* this does not work yet; creates endless loop/recursion
 *          if (ctrl.HasAttribute("LabelUnit"))
 *          {
 *              // we need another label after the control
 *              LabelGenerator lblGenerator = new LabelGenerator();
 *              string lblName = lblGenerator.CalculateName(controlName) + "Unit";
 *              TControlDef unitLabel = writer.CodeStorage.FindOrCreateControl(lblName, controlName);
 *              unitLabel.Label = ctrl.GetAttribute("LabelUnit");
 *
 *              TableLayoutPanelGenerator TlpGenerator = new TableLayoutPanelGenerator();
 *              ctrl.SetAttribute("ControlsOrientation", "horizontal");
 *              TlpGenerator.SetOrientation(ctrl);
 *              StringCollection childControls = new StringCollection();
 *              childControls.Add(controlName);
 *              childControls.Add(lblName);
 *              string subTlpControlName = TlpGenerator.CreateLayout(writer, FTlpName, childControls);
 *
 *              TlpGenerator.CreateCode(writer, ctrl);
 *              TlpGenerator.CreateCode(writer, unitLabel);
 *
 *              if (FOrientation == eOrientation.Vertical)
 *              {
 *                  AddControl(writer, FTlpName, subTlpControlName, 1, FCurrentRow);
 *              }
 *              else
 *              {
 *                  AddControl(writer, FTlpName, subTlpControlName, FCurrentColumn * 2 + 1, 0);
 *              }
 *          }
 *          else
 */
            if (ctrl.HasAttribute("GenerateWithOtherControls"))
            {
                // add the checkbox/radiobutton first
                if (FOrientation == eOrientation.Vertical)
                {
                    AddControl(ctrl, 0, FCurrentRow);
                }
                else if (FOrientation == eOrientation.Horizontal)
                {
                    AddControl(ctrl, FCurrentColumn * 2, 0);
                }
                else if (FOrientation == eOrientation.TableLayout)
                {
                    AddControl(ctrl, FCurrentColumn, FCurrentRow);
                }

                StringCollection childControls = TYml2Xml.GetElements(TXMLParser.GetChild(ctrl.xmlNode, "Controls"));

                if (childControls.Count > 1)
                {
                    // we need another tablelayout to arrange all the controls
                    PanelLayoutGenerator TlpGenerator = new PanelLayoutGenerator();
                    TlpGenerator.SetOrientation(ctrl);

                    Int32 NewHeight = -1;
                    Int32 NewWidth = -1;

                    if (ctrl.HasAttribute("Height"))
                    {
                        NewHeight = Convert.ToInt32(ctrl.GetAttribute("Height"));
                        ctrl.ClearAttribute("Height");
                    }

                    if (ctrl.HasAttribute("Width"))
                    {
                        NewWidth = Convert.ToInt32(ctrl.GetAttribute("Width"));
                        ctrl.ClearAttribute("Width");
                    }

                    TControlDef subTlpControl = TlpGenerator.CreateNewPanel(writer, ctrl);
                    TlpGenerator.CreateLayout(writer, ctrl, subTlpControl, NewWidth, NewHeight);

                    foreach (string ChildControlName in childControls)
                    {
                        TControlDef ChildControl = ctrl.FCodeStorage.GetControl(ChildControlName);
                        TlpGenerator.InsertControl(writer, ChildControl);
                    }

                    TlpGenerator.WriteTableLayout(writer, subTlpControl);

                    if (FOrientation == eOrientation.Vertical)
                    {
                        AddControl(subTlpControl, 1, FCurrentRow);
                    }
                    else if (FOrientation == eOrientation.Horizontal)
                    {
                        AddControl(subTlpControl, FCurrentColumn * 2 + 1, 0);
                    }
                    else if (FOrientation == eOrientation.TableLayout)
                    {
                        AddControl(subTlpControl, FCurrentColumn + 1, FCurrentRow);
                    }
                }
                else if (childControls.Count == 1)
                {
                    // we don't need to add another table layout for just one other control
                    TControlDef ChildCtrl = ctrl.FCodeStorage.GetControl(childControls[0]);
                    IControlGenerator ChildGenerator = writer.FindControlGenerator(ChildCtrl);
                    ChildGenerator.GenerateControl(writer, ChildCtrl);

                    if (FOrientation == eOrientation.Vertical)
                    {
                        AddControl(ChildCtrl, 1, FCurrentRow);
                    }
                    else if (FOrientation == eOrientation.Horizontal)
                    {
                        AddControl(ChildCtrl, FCurrentColumn * 2 + 1, 0);
                    }
                    else if (FOrientation == eOrientation.TableLayout)
                    {
                        AddControl(ChildCtrl, FCurrentColumn + 1, FCurrentRow);
                    }
                }
            }
            else if (ctrl.controlName.StartsWith("pnlEmpty"))
            {
                // don't do anything here!
            }
            else if (ctrlGenerator.GenerateLabel(ctrl))
            {
                // add label
                LabelGenerator lblGenerator = new LabelGenerator();
                string lblName = lblGenerator.CalculateName(controlName);
                TControlDef newLabel = writer.CodeStorage.FindOrCreateControl(lblName, ctrl.controlName);
                newLabel.Label = ctrl.Label;

                if (ctrl.HasAttribute("LabelWidth"))
                {
                    newLabel.SetAttribute("Width", ctrl.GetAttribute("LabelWidth"));
                }

                if (ctrl.HasAttribute("LabelUnit"))
                {
                    // alternative implementation above does not work: add another label control after the input control
                    newLabel.Label = newLabel.Label + " (in " + ctrl.GetAttribute("LabelUnit") + ")";
                }

                lblGenerator.GenerateDeclaration(writer, newLabel);
                lblGenerator.RightAlign = true;
                lblGenerator.SetControlProperties(writer, newLabel);

                AddControl(newLabel,
                    FCurrentColumn * 2,
                    FCurrentRow);
                AddControl(ctrl,
                    FCurrentColumn * 2 + 1,
                    FCurrentRow);
            }
            else
            {
                AddControl(ctrl,
                    FCurrentColumn * 2,
                    FCurrentRow);
            }

            if (FOrientation == eOrientation.Vertical)
            {
                FCurrentRow++;
                FCurrentColumn = 0;
            }
            else if (FOrientation == eOrientation.Horizontal)
            {
                FCurrentColumn++;
            }
            else if (FOrientation == eOrientation.TableLayout)
            {
                FCurrentColumn += ctrl.colSpan;
            }
        }
Пример #4
0
        /// <summary>
        /// process the children
        /// </summary>
        public override void ProcessChildren(TFormWriter writer, TControlDef container)
        {
            // usually, the toolbar buttons are direct children of the toolbar control
            List <XmlNode>childrenlist = TYml2Xml.GetChildren(container.xmlNode, true);

            foreach (XmlNode childNode in childrenlist)
            {
                /* Get unique name if we need it
                 * at the moment we need it only for menu separators
                 */
                String UniqueChildName = childNode.Name;
                TControlDef childCtrl = container.FCodeStorage.GetControl(childNode.Name);

                if (childCtrl == null)
                {
                    UniqueChildName = TYml2Xml.GetAttribute(childNode, "UniqueName");
                    childCtrl = container.FCodeStorage.GetControl(UniqueChildName);
                }

                container.Children.Add(childCtrl);
                IControlGenerator ctrlGenerator = writer.FindControlGenerator(childCtrl);
                ctrlGenerator.GenerateControl(writer, childCtrl);
            }
        }
Пример #5
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)
        {
            // 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);
        }
Пример #6
0
        /// <summary>
        /// declare the control
        /// </summary>
        public override void GenerateDeclaration(TFormWriter writer, TControlDef ctrl)
        {
            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.GenerateDeclaration(writer, hostedCtrl);
            }

            string localControlType = ControlType;

            if (ctrl.controlType.Length > 0)
            {
                localControlType = ctrl.controlType;
            }

            writer.Template.AddToCodelet("CONTROLDECLARATION", "private " + localControlType + " " + ctrl.controlName + ";" +
                Environment.NewLine);
            writer.Template.AddToCodelet("CONTROLCREATION", "this." + ctrl.controlName + " = new " + localControlType + "(" +
                TYml2Xml.GetAttribute(ctrl.xmlNode, "HostedControl") + ");" + Environment.NewLine);
        }
Пример #7
0
        /// <summary>
        /// get the controls that belong to the toolstrip
        /// </summary>
        public override void ProcessChildren(TFormWriter writer, TControlDef container)
        {
            // add all the children

            // TODO add Container elements in statusbar
            if (container.controlName.StartsWith("stb"))
            {
                return;
            }

            List <XmlNode>childrenlist;

            if (TYml2Xml.GetChild(container.xmlNode, "Controls") != null)
            {
                // this is for generated toolbar, eg. for the PrintPreviewControl
                StringCollection childrenNames = TYml2Xml.GetElements(container.xmlNode, "Controls");
                childrenlist = new List <XmlNode>();

                foreach (string name in childrenNames)
                {
                    childrenlist.Add(container.xmlNode.OwnerDocument.CreateElement(name));
                }
            }
            else
            {
                // usually, the toolbar buttons are direct children of the toolbar control
                childrenlist = TYml2Xml.GetChildren(container.xmlNode, true);
            }

            //Console.WriteLine("Container: " + container.controlName);
            foreach (XmlNode child in childrenlist)
            {
                // Console.WriteLine("Child: " + child.Name);

                /* Get unique name if we need it
                 * at the moment we need it only for menu separators
                 */
                String UniqueChildName = child.Name;
                TControlDef ControlDefChild = container.FCodeStorage.GetControl(child.Name);

                if (ControlDefChild == null)
                {
                    UniqueChildName = TYml2Xml.GetAttribute(child, "UniqueName");
                    ControlDefChild = container.FCodeStorage.GetControl(UniqueChildName);
                }

                container.Children.Add(ControlDefChild);

                if (ControlDefChild != null)
                {
                    IControlGenerator ctrlGenerator = writer.FindControlGenerator(ControlDefChild);

                    // add control itself
                    if (ctrlGenerator != null)
                    {
                        ctrlGenerator.GenerateControl(writer, ControlDefChild);
                    }
                }
            }
        }
Пример #8
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, ",");
            }
        }
Пример #9
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, ",");
                    }
                }
            }
        }
        /// <summary>
        /// generate the children
        /// </summary>
        public override void ProcessChildren(TFormWriter writer, TControlDef ctrl)
        {
            base.ProcessChildren(writer, ctrl);

            XmlNode controlsNode = TXMLParser.GetChild(ctrl.xmlNode, "Controls");

            if ((controlsNode != null) && TYml2Xml.GetChildren(controlsNode, true)[0].Name.StartsWith("Row"))
            {
                // this defines the layout with several rows with several controls per row
                Int32 countRow = 0;

                foreach (XmlNode row in TYml2Xml.GetChildren(controlsNode, true))
                {
                    StringCollection controls = TYml2Xml.GetElements(row);

                    foreach (string ctrlname in controls)
                    {
                        TControlDef childCtrl = writer.CodeStorage.GetControl(ctrlname);

                        if (ctrlname.StartsWith("Empty"))
                        {
                            childCtrl = writer.CodeStorage.FindOrCreateControl("pnlEmpty", ctrl.controlName);
                        }

                        if (childCtrl == null)
                        {
                            throw new Exception("cannot find control with name " + ctrlname + "; it belongs to " +
                                ctrl.controlName);
                        }

                        // add control itself
                        ctrl.Children.Add(childCtrl);
                        childCtrl.parentName = ctrl.controlName;
                        IControlGenerator ctrlGenerator = writer.FindControlGenerator(childCtrl);
                        ctrlGenerator.GenerateControl(writer, childCtrl);

                        childCtrl.rowNumber = countRow;
                    }

                    countRow++;
                }
            }
            else
            {
                if ((controlsNode != null) && (ctrl.Children.Count == 0))
                {
                    StringCollection controlNamesCollection = TYml2Xml.GetElements(TXMLParser.GetChild(ctrl.xmlNode, "Controls"));

                    foreach (string childCtrlName in controlNamesCollection)
                    {
                        TControlDef childCtrl = writer.CodeStorage.GetControl(childCtrlName);

                        if (childCtrlName.StartsWith("Empty"))
                        {
                            childCtrl = writer.CodeStorage.FindOrCreateControl("pnlEmpty", ctrl.controlName);
                        }

                        if (childCtrl == null)
                        {
                            throw new Exception("cannot find control with name " + childCtrlName + "; it belongs to " +
                                ctrl.controlName);
                        }

                        childCtrl.parentName = ctrl.controlName;
                        ctrl.Children.Add(childCtrl);
                    }
                }

                foreach (TControlDef childCtrl in ctrl.Children)
                {
                    TLogging.LogAtLevel(1, "foreach (TControlDef childCtrl in ctrl.Children) -- Control: " + childCtrl.controlName);

                    if (!childCtrl.controlName.StartsWith("pnlEmpty"))
                    {
                        // process the control itself
                        IControlGenerator ctrlGenerator = writer.FindControlGenerator(childCtrl);
                        ctrlGenerator.GenerateControl(writer, childCtrl);
                    }
                }
            }

            bool hasDockingChildren = false;

            // don't use a tablelayout for controls where all children have the Dock property set
            foreach (TControlDef ChildControl in ctrl.Children)
            {
                if (!ChildControl.HasAttribute("Dock"))
                {
                    ctrl.SetAttribute("UseTableLayout", "true");
                }
                else
                {
                    hasDockingChildren = true;
                }
            }

            if (ctrl.GetAttribute("UseTableLayout") == "true")
            {
                // show a warning if there are some controls with Docking, and some without
                if (hasDockingChildren)
                {
                    StringCollection clearDockAttributeChildren = new StringCollection();

                    foreach (TControlDef ChildControl in ctrl.Children)
                    {
                        if ((ChildControl.HasAttribute("Dock"))
                            && ((!ChildControl.IsHorizontalGridButtonPanelStrict)
                                && (ChildControl.controlName != TControlDef.STR_GRID_DETAILS_NAME)))
                        {
                            ChildControl.ClearAttribute("Dock");
                            clearDockAttributeChildren.Add(ChildControl.controlName);
                        }
                    }

                    if (clearDockAttributeChildren.Count > 0)
                    {
                        TLogging.Log("Warning: please remove the Dock attribute from control(s) " +
                            StringHelper.StrMerge(clearDockAttributeChildren, ','));
                    }
                }

                if (ctrl.GetAttribute("Margin") == "0")
                {
                    if (!ctrl.HasAttribute("MarginTop"))
                    {
                        ctrl.SetAttribute("MarginTop", "0");
                        ctrl.SetAttribute("MarginBottom", "0");
                        ctrl.SetAttribute("MarginLeft", "0");
                    }
                }

                PanelLayoutGenerator TlpGenerator = new PanelLayoutGenerator();
                TlpGenerator.SetOrientation(ctrl);
                TlpGenerator.CreateLayout(writer, ctrl, null, -1, -1);

                foreach (TControlDef ChildControl in ctrl.Children)
                {
                    TlpGenerator.InsertControl(writer, ChildControl);
                }

                TlpGenerator.WriteTableLayout(writer, ctrl);

                if (ctrl.GetAttribute("Dock", "None") != "None")
                {
                    writer.SetControlProperty(ctrl.controlName, "Dock", ctrl.GetAttribute("Dock"), false);

                    // groupboxes do not have AutoScroll property (grp, rgr)
                    if ((this.FPrefix == "pnl") || (this.FPrefix == "tab") || (this.FPrefix == "rng"))
                    {
                        writer.SetControlProperty(ctrl.controlName, "AutoScroll", "true", false);
                    }
                }
            }

            return;
        }
        /// <summary>
        /// add adhoc controls for the print preview
        /// </summary>
        public override void ProcessChildren(TFormWriter writer, TControlDef ctrl)
        {
            // add the toolbar and the print preview control
            TControlDef toolbar = writer.CodeStorage.FindOrCreateControl("tbr" + ctrl.controlName.Substring(
                    ctrl.controlTypePrefix.Length), ctrl.controlName);
            TControlDef ttxCurrentPage = writer.CodeStorage.FindOrCreateControl("ttxCurrentPage", toolbar.controlName);

            ttxCurrentPage.SetAttribute("OnChange", "CurrentPageTextChanged");
            writer.CodeStorage.FindOrCreateControl("tblTotalNumberPages", toolbar.controlName);
            TControlDef tbbPrevPage = writer.CodeStorage.FindOrCreateControl("tbbPrevPage", toolbar.controlName);
            tbbPrevPage.SetAttribute("ActionClick", "PrevPageClick");
            TControlDef tbbNextPage = writer.CodeStorage.FindOrCreateControl("tbbNextPage", toolbar.controlName);
            tbbNextPage.SetAttribute("ActionClick", "NextPageClick");
            TControlDef tbbPrintCurrentPage = writer.CodeStorage.FindOrCreateControl("tbbPrintCurrentPage", toolbar.controlName);
            tbbPrintCurrentPage.SetAttribute("ActionClick", "PrintCurrentPage");
            TControlDef tbbPrint = writer.CodeStorage.FindOrCreateControl("tbbPrint", toolbar.controlName);
            tbbPrint.SetAttribute("ActionClick", "PrintAllPages");

            TControlDef printPreview = writer.CodeStorage.FindOrCreateControl("ppv" + ctrl.controlName.Substring(
                    ctrl.controlTypePrefix.Length), ctrl.controlName);
            printPreview.SetAttribute("Dock", "Fill");

            ctrl.Children.Add(toolbar);
            ctrl.Children.Add(printPreview);

            IControlGenerator ctrlGenerator = writer.FindControlGenerator(toolbar);
            ctrlGenerator.GenerateControl(writer, toolbar);
            ctrlGenerator = writer.FindControlGenerator(printPreview);
            ctrlGenerator.GenerateControl(writer, printPreview);
        }
        /// <summary>
        /// create the two panels
        /// </summary>
        public override void ProcessChildren(TFormWriter writer, TControlDef ctrl)
        {
            TControlDef ChildCtrl = ctrl.FCodeStorage.GetControl(ctrl.GetAttribute("Panel1"));

            ctrl.Children.Add(ChildCtrl);
            ChildCtrl.parentName = ctrl.controlName;
            IControlGenerator ChildGenerator = writer.FindControlGenerator(ChildCtrl);
            ChildGenerator.GenerateControl(writer, ChildCtrl);

            ChildCtrl = ctrl.FCodeStorage.GetControl(ctrl.GetAttribute("Panel2"));
            ctrl.Children.Add(ChildCtrl);
            ChildCtrl.parentName = ctrl.controlName;
            ChildGenerator = writer.FindControlGenerator(ChildCtrl);
            ChildGenerator.GenerateControl(writer, ChildCtrl);
        }
Пример #13
0
        /// <summary>add GeneratedReadSetControls, and all dependent controls</summary>
        public override void ApplyDerivedFunctionality(TFormWriter writer, TControlDef control)
        {
            string paramName = ReportControls.GetParameterName(control.xmlNode);

            if (paramName == null)
            {
                return;
            }

            StringCollection Controls =
                TYml2Xml.GetElements(TXMLParser.GetChild(control.xmlNode, "Controls"));

            foreach (string controlName in Controls)
            {
                TControlDef rbtCtrl = writer.CodeStorage.GetControl(controlName);
                string rbtValue = rbtCtrl.Label;
                rbtValue = StringHelper.UpperCamelCase(rbtValue.Replace("'", "").Replace(" ", "_"), false, false);

                if (rbtCtrl.HasAttribute("ParameterValue"))
                {
                    rbtValue = rbtCtrl.GetAttribute("ParameterValue");
                }

                string rbtName = "rbt" + controlName.Substring(3);

                if (controlName.StartsWith("layoutPanel"))
                {
                    // the table layouts of sub controls for each radio button need to be skipped
                    continue;
                }

                ProcessTemplate RadioButtonReadControlsSnippet = writer.Template.GetSnippet("RADIOBUTTONREADCONTROLS");
                RadioButtonReadControlsSnippet.SetCodelet("RBTNAME", rbtName);
                RadioButtonReadControlsSnippet.SetCodelet("PARAMNAME", paramName);
                RadioButtonReadControlsSnippet.SetCodelet("RBTVALUE", rbtValue);
                RadioButtonReadControlsSnippet.SetCodelet("READCONTROLS", "");

                XmlNode childControls = TXMLParser.GetChild(rbtCtrl.xmlNode, "Controls");

                // only assign variables that make sense
                if (childControls != null)
                {
                    StringCollection childControlNames = TYml2Xml.GetElements(childControls);

                    foreach (string childName in childControlNames)
                    {
                        if (childName.StartsWith("layoutPanel"))
                        {
                            continue;
                        }

                        TControlDef childCtrl = writer.CodeStorage.GetControl(childName);
                        IControlGenerator generator = writer.FindControlGenerator(childCtrl);

                        // make sure we ignore Button etc
                        if (generator.GetType().ToString().EndsWith("ReportGenerator"))
                        {
                            childCtrl.SetAttribute("DependsOnRadioButton", "");
                            ReportControls.GenerateReadSetControls(writer,
                                childCtrl.xmlNode,
                                RadioButtonReadControlsSnippet,
                                generator.TemplateSnippetName);
                            childCtrl.SetAttribute("DependsOnRadioButton", "true");
                        }
                    }
                }

                writer.Template.InsertSnippet("READCONTROLS", RadioButtonReadControlsSnippet);

                ProcessTemplate RadioButtonSetControlsSnippet = writer.Template.GetSnippet("RADIOBUTTONSETCONTROLS");
                RadioButtonSetControlsSnippet.SetCodelet("RBTNAME", rbtName);
                RadioButtonSetControlsSnippet.SetCodelet("PARAMNAME", paramName);
                RadioButtonSetControlsSnippet.SetCodelet("RBTVALUE", rbtValue);

                // only assign variables that make sense
                if (childControls != null)
                {
                    StringCollection childControlNames = TYml2Xml.GetElements(childControls);

                    foreach (string childName in childControlNames)
                    {
                        if (childName.StartsWith("layoutPanel"))
                        {
                            continue;
                        }

                        TControlDef childCtrl = writer.CodeStorage.GetControl(childName);
                        IControlGenerator generator = writer.FindControlGenerator(childCtrl);

                        // make sure we ignore Button etc
                        if (generator.GetType().ToString().EndsWith("ReportGenerator"))
                        {
                            childCtrl.SetAttribute("DependsOnRadioButton", "");
                            ReportControls.GenerateReadSetControls(writer,
                                childCtrl.xmlNode,
                                RadioButtonSetControlsSnippet,
                                generator.TemplateSnippetName);
                            childCtrl.SetAttribute("DependsOnRadioButton", "true");
                        }
                    }
                }

                writer.Template.InsertSnippet("SETCONTROLS", RadioButtonSetControlsSnippet);
            }
        }
Пример #14
0
        /// <summary>add GeneratedReadSetControls</summary>
        public override void ApplyDerivedFunctionality(TFormWriter writer, TControlDef ctrl)
        {
            ReportControls.GenerateReadSetControls(writer, ctrl.xmlNode, writer.Template, "CHECKBOX");

            // we are not doing it the same way as in RadioGroupComplexReportGenerator.
            // difference here: we will always store the value of the dependant controls, even when the checkbox is not ticked
            foreach (TControlDef childCtrl in ctrl.Children)
            {
                childCtrl.SetAttribute("DependsOnRadioButton", "");
                IControlGenerator ctrlGenerator = writer.FindControlGenerator(childCtrl);
                ctrlGenerator.ApplyDerivedFunctionality(writer, childCtrl);
                childCtrl.SetAttribute("DependsOnRadioButton", "true");
            }
        }