예제 #1
0
        /// <summary>
        /// how to assign a value to the control
        /// </summary>
        protected override string AssignValue(TControlDef ctrl, string AFieldOrNull, string AFieldTypeDotNet)
        {
            if (AFieldOrNull == null)
            {
                return(ctrl.controlName + ".Text = String.Empty;");
            }

            if (!AFieldTypeDotNet.ToLower().Contains("string"))
            {
                if (ctrl.GetAttribute("Type") == "PartnerKey")
                {
                    // for readonly text box
                    return(ctrl.controlName + ".Text = String.Format(\"{0:0000000000}\", " + AFieldOrNull + ");");
                }
                else if (ctrl.GetAttribute("Type") == "ShortTime")
                {
                    // for seconds to short time
                    return(ctrl.controlName + ".Text = new Ict.Common.TypeConverter.TShortTimeConverter().ConvertTo(" + AFieldOrNull +
                           ", typeof(string)).ToString();");
                }
                else if (ctrl.GetAttribute("Type") == "LongTime")
                {
                    // for seconds to long time
                    return(ctrl.controlName + ".Text = new Ict.Common.TypeConverter.TLongTimeConverter().ConvertTo(" + AFieldOrNull +
                           ", typeof(string)).ToString();");
                }

                return(ctrl.controlName + ".Text = " + AFieldOrNull + ".ToString();");
            }

            return(ctrl.controlName + ".Text = " + AFieldOrNull + ";");
        }
예제 #2
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)
        {
            base.SetControlProperties(writer, ctrl);
            writer.SetControlProperty(ctrl, "ListTable", "TCmbAutoPopulated.TListTableEnum." + ctrl.GetAttribute("List"));

            if (ctrl.GetAttribute("List") != "UserDefinedList")
            {
                writer.Template.AddToCodelet("INITUSERCONTROLS", ctrl.controlName + ".InitialiseUserControl();" + Environment.NewLine);

                if (ctrl.HasAttribute("AllowDbNull"))
                {
                    writer.SetControlProperty(ctrl, "AllowDbNull", ctrl.GetAttribute("AllowDbNull"));
                }

                if (ctrl.HasAttribute("NullValueDesciption"))
                {
                    writer.SetControlProperty(ctrl, "NullValueDesciption", "\"" + ctrl.GetAttribute("NullValueDesciption") + "\"");
                }
            }
            else
            {
                // user defined lists have to be either filled in manual code
                // eg UC_GLJournals.ManualCode.cs, BeforeShowDetailsManual
                // or UC_GLTransactions.ManualCode.cs, LoadTransactions
            }

            if (ctrl.HasAttribute("ComboBoxWidth"))
            {
                writer.SetControlProperty(ctrl, "ComboBoxWidth", ctrl.GetAttribute("ComboBoxWidth"));
            }

            return(writer.FTemplate);
        }
예제 #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 ctrlSnippet = base.SetControlProperties(writer, ctrl);

            if (ctrlSnippet.FTemplateCode.Contains("{#REDIRECTONSUCCESS}"))
            {
                ProcessTemplate redirectSnippet = writer.FTemplate.GetSnippet("REDIRECTONSUCCESS");

                ctrlSnippet.SetCodelet("REDIRECTONSUCCESS", redirectSnippet.FTemplateCode.ToString());
            }

            if (ctrl.HasAttribute("AjaxRequestUrl"))
            {
                ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "VALIDATIONERRORTITLE", ctrl, ctrl.GetAttribute("ValidationErrorTitle"));
                ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "VALIDATIONERRORMESSAGE", ctrl, ctrl.GetAttribute("ValidationErrorMessage"));
                ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "SENDINGDATATITLE", ctrl, ctrl.GetAttribute("SendingMessageTitle"));
                ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "SENDINGDATAMESSAGE", ctrl, ctrl.GetAttribute("SendingMessage"));

                if (ctrl.HasAttribute("SuccessMessage"))
                {
                    ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "REQUESTSUCCESSTITLE", ctrl, ctrl.GetAttribute("SuccessMessageTitle"));
                    ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "REQUESTSUCCESSMESSAGE", ctrl, ctrl.GetAttribute("SuccessMessage"));
                }

                ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "REQUESTFAILURETITLE", ctrl, ctrl.GetAttribute("FailureMessageTitle"));
                ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "REQUESTFAILUREMESSAGE", ctrl, ctrl.GetAttribute("FailureMessage"));
            }

            ctrlSnippet.SetCodelet("REQUESTURL", ctrl.GetAttribute("AjaxRequestUrl"));
            ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "REDIRECTURLONSUCCESS", ctrl, ctrl.GetAttribute("RedirectURLOnSuccess"));

            if (ctrl.GetAttribute("DownloadOnSuccess").StartsWith("jsonData"))
            {
                ctrlSnippet.SetCodelet("REDIRECTDOWNLOAD", ctrl.GetAttribute("DownloadOnSuccess"));
            }

            ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "REDIRECTURLONCANCEL", ctrl, ctrl.GetAttribute("RedirectURLOnCancel"));
            ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "CANCELQUESTIONTITLE", ctrl, ctrl.GetAttribute("CancelQuestionTitle"));
            ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "CANCELQUESTIONMESSAGE", ctrl, ctrl.GetAttribute("CancelQuestionMessage"));

            XmlNode AjaxParametersNode = TYml2Xml.GetChild(ctrl.xmlNode, "AjaxRequestParameters");

            if (AjaxParametersNode != null)
            {
                string ParameterString = String.Empty;

                foreach (XmlAttribute attr in AjaxParametersNode.Attributes)
                {
                    if (!attr.Name.Equals("depth"))
                    {
                        ParameterString += attr.Name + ": '" + attr.Value + "', ";
                    }
                }

                ctrlSnippet.SetCodelet("REQUESTPARAMETERS", ParameterString);
                writer.FTemplate.SetCodelet("REQUESTPARAMETERS", "true");
            }

            return(ctrlSnippet);
        }
예제 #4
0
        /// <summary>
        /// how to get the value from the control
        /// </summary>
        protected override string GetControlValue(TControlDef ctrl, string AFieldTypeDotNet)
        {
            if (AFieldTypeDotNet == null)
            {
                return(ctrl.controlName + ".Text.Length == 0");
            }

            if (ctrl.GetAttribute("Type") == "ShortTime")
            {
                return("(int)new Ict.Common.TypeConverter.TShortTimeConverter().ConvertTo(" + ctrl.controlName + ".Text, typeof(int))");
            }
            else if (ctrl.GetAttribute("Type") == "LongTime")
            {
                return("(int)new Ict.Common.TypeConverter.TLongTimeConverter().ConvertTo(" + ctrl.controlName + ".Text, typeof(int))");
            }
            else if (AFieldTypeDotNet.ToLower().Contains("int64"))
            {
                return("Convert.ToInt64(" + ctrl.controlName + ".Text)");
            }
            else if (AFieldTypeDotNet.ToLower().Contains("int"))
            {
                return("Convert.ToInt32(" + ctrl.controlName + ".Text)");
            }
            else if (AFieldTypeDotNet.ToLower().Contains("decimal"))
            {
                return("Convert.ToDecimal(" + ctrl.controlName + ".Text)");
            }

            return(ctrl.controlName + ".Text");
        }
예제 #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)
        {
            ProcessTemplate ctrlSnippet = base.SetControlProperties(writer, ctrl);

            ProcessTemplate uploadCheckAssistantSnippet = writer.FTemplate.GetSnippet("ASSISTANTPAGEWITHUPLOADVALID");

            ((TExtJsFormsWriter)writer).AddResourceString(uploadCheckAssistantSnippet, "MISSINGUPLOADTITLE", ctrl,
                                                          ctrl.GetAttribute("MissingUploadTitle"));
            ((TExtJsFormsWriter)writer).AddResourceString(uploadCheckAssistantSnippet, "MISSINGUPLOADMESSAGE", ctrl,
                                                          ctrl.GetAttribute("MissingUploadMessage"));

            writer.FTemplate.InsertSnippet("ISVALID", uploadCheckAssistantSnippet);
            writer.FTemplate.InsertSnippet("ONSHOW", writer.FTemplate.GetSnippet("ASSISTANTPAGEWITHUPLOADSHOW"));
            writer.FTemplate.InsertSnippet("ONHIDE", writer.FTemplate.GetSnippet("ASSISTANTPAGEWITHUPLOADHIDE"));

            ProcessTemplate uploadSnippet = writer.FTemplate.GetSnippet("UPLOADFORMDEFINITION");

            if (ctrl.HasAttribute("UploadButtonLabel"))
            {
                ((TExtJsFormsWriter)writer).AddResourceString(uploadCheckAssistantSnippet, "UPLOADBUTTONLABEL", ctrl,
                                                              ctrl.GetAttribute("UploadButtonLabel"));
                uploadSnippet.SetCodelet("UPLOADBUTTONLABEL", ctrl.controlName + "UPLOADBUTTONLABEL");
            }

            writer.FTemplate.InsertSnippet("UPLOADFORM", uploadSnippet);

            ProcessTemplate uploadCheckSnippet = writer.FTemplate.GetSnippet("VALIDUPLOADCHECK");

            writer.FTemplate.InsertSnippet("CHECKFORVALIDUPLOAD", uploadCheckSnippet);

            return(ctrlSnippet);
        }
예제 #6
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)
        {
            string NumberFormat = String.Empty;

            base.SetControlProperties(writer, ctrl);

            if ((ctrl.HasAttribute("ShowLabel") && (ctrl.GetAttribute("ShowLabel").ToLower() == "false")))
            {
                writer.SetControlProperty(ctrl, "ShowLabel", "false");
            }

            // Note: the control defaults to 'ShowLabel' true, so this doesn't need to be set to 'true' in code.

            // Order is important: set Context before ControlMode and before DecimalPlaces
            writer.SetControlProperty(ctrl, "Context", "this");
            writer.SetControlProperty(ctrl, "ControlMode", "TTxtNumericTextBox.TNumericTextBoxMode." + FControlMode);
            writer.SetControlProperty(ctrl, "DecimalPlaces", FDecimalPrecision.ToString());
            writer.SetControlProperty(ctrl, "NullValueAllowed", FNullValueAllowed.ToString().ToLower());

            if (ctrl.HasAttribute("Format"))
            {
                NumberFormat = ctrl.GetAttribute("Format");
            }

            if ((NumberFormat.StartsWith("PercentInteger")) ||
                (NumberFormat.StartsWith("PercentDecimal")))
            {
                writer.SetControlProperty(ctrl, "ShowPercentSign", "true");
            }

            return(writer.FTemplate);
        }
예제 #7
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)
        {
            // TODO this does not work yet. see EventRole Maintain screen
            if ((!ctrl.HasAttribute("Align")) &&
                (!ctrl.HasAttribute("Width")))
            {
                ctrl.SetAttribute("Stretch", "horizontally");
            }

            base.SetControlProperties(writer, ctrl);

            TControlDef parentCtrl = writer.FCodeStorage.GetControl(ctrl.parentName);

            // We need to over-ride any Anchor requests in the YAML to anchor an attached label to anything other than top-left
            // But pure label controls can be anchored to, say, left-top-right
            if ((ctrl.controlName.Substring(ctrl.controlTypePrefix.Length) == parentCtrl.controlName.Substring(parentCtrl.controlTypePrefix.Length)) ||
                ((ctrl.HasAttribute("Dock") == false) && (ctrl.HasAttribute("Align") == false)))
            {
                // stretch at design time, but do not align to the right
                writer.SetControlProperty(ctrl, "Anchor",
                                          "((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)))");
            }

            string labelText = "";

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "Text"))
            {
                labelText = TYml2Xml.GetAttribute(ctrl.xmlNode, "Text");
            }
            else
            {
                labelText = ctrl.Label + ":";
            }

            if (ctrl.HasAttribute("Width"))
            {
                ctrl.SetAttribute("Width", ctrl.GetAttribute("Width"));
            }
            else
            {
                ctrl.SetAttribute("Width", (PanelLayoutGenerator.MeasureTextWidth(labelText) + 5).ToString());
            }

            if (ctrl.HasAttribute("Height"))
            {
                ctrl.SetAttribute("Height", ctrl.GetAttribute("Height"));
            }

            writer.SetControlProperty(ctrl, "Text", "\"" + labelText + "\"");
            writer.SetControlProperty(ctrl, "Padding", "new System.Windows.Forms.Padding(0, 5, 0, 0)");

            if (FRightAlign)
            {
                writer.SetControlProperty(ctrl, "TextAlign", "System.Drawing.ContentAlignment.TopRight");
            }

            return(writer.FTemplate);
        }
예제 #8
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)
        {
            Int32 buttonWidth  = 40;
            Int32 textBoxWidth = 80;

            // seems to be hardcoded in csharp\ICT\Petra\Client\CommonControls\Gui\txtAutoPopulatedButtonLabel.Designer.cs
            Int32 controlWidth = 390;

            base.SetControlProperties(writer, ctrl);

            if ((ctrl.HasAttribute("ShowLabel") && (ctrl.GetAttribute("ShowLabel").ToLower() == "false")))
            {
                writer.SetControlProperty(ctrl, "ShowLabel", "false");
                controlWidth = 120;
            }

            // Note: the control defaults to 'ShowLabel' true, so this doesn't need to be set to 'true' in code.

            writer.SetControlProperty(ctrl, "ASpecialSetting", "true");
            writer.SetControlProperty(ctrl, "ButtonTextAlign", "System.Drawing.ContentAlignment.MiddleCenter");
            writer.SetControlProperty(ctrl, "ListTable", "TtxtAutoPopulatedButtonLabel.TListTableEnum." +
                                      FButtonLabelType);
            writer.SetControlProperty(ctrl, "PartnerClass", "\"" + ctrl.GetAttribute("PartnerClass") + "\"");
            writer.SetControlProperty(ctrl, "MaxLength", "32767");
            writer.SetControlProperty(ctrl, "Tag", "\"CustomDisableAlthoughInvisible\"");
            writer.SetControlProperty(ctrl, "TextBoxWidth", textBoxWidth.ToString());

            if (!(ctrl.HasAttribute("ReadOnly") && (ctrl.GetAttribute("ReadOnly").ToLower() == "true")))
            {
                writer.SetControlProperty(ctrl, "ButtonWidth", buttonWidth.ToString());
                writer.SetControlProperty(ctrl, "ReadOnly", "false");
                writer.SetControlProperty(ctrl,
                                          "Font",
                                          "new System.Drawing.Font(\"Verdana\", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (byte)0)");
                writer.SetControlProperty(ctrl, "ButtonText", "\"Find\"");
            }
            else
            {
                writer.SetControlProperty(ctrl, "ButtonWidth", "0");
                writer.SetControlProperty(ctrl, "BorderStyle", "System.Windows.Forms.BorderStyle.None");
                writer.SetControlProperty(ctrl, "Padding", "new System.Windows.Forms.Padding(0, 4, 0, 0)");
            }

            if (!ctrl.HasAttribute("Width"))
            {
                ctrl.SetAttribute("Width", controlWidth.ToString());
            }

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "DefaultValue"))
            {
                writer.SetControlProperty(ctrl,
                                          "Text",
                                          "\"" + TYml2Xml.GetAttribute(ctrl.xmlNode, "DefaultValue") + "\"");
            }

            return(writer.FTemplate);
        }
예제 #9
0
        /// <summary>
        /// make sure there is a label or not
        /// </summary>
        public override bool GenerateLabel(TControlDef ctrl)
        {
            if (ctrl.HasAttribute("CheckBoxAttachedLabel") &&
                ((ctrl.GetAttribute("CheckBoxAttachedLabel").ToLower() == "left") ||
                 (ctrl.GetAttribute("CheckBoxAttachedLabel").ToLower() == "right")))
            {
                ctrl.hasLabel = false;
                return(false);
            }

            return(base.GenerateLabel(ctrl));
        }
예제 #10
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)
        {
            // TODO this does not work yet. see EventRole Maintain screen
            if ((!ctrl.HasAttribute("Align")) &&
                (!ctrl.HasAttribute("Width")))
            {
                ctrl.SetAttribute("Stretch", "horizontally");
            }

            base.SetControlProperties(writer, ctrl);

            // stretch at design time, but do not align to the right
            writer.SetControlProperty(ctrl, "Anchor",
                                      "((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)))");

            string labelText = "";

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "Text"))
            {
                labelText = TYml2Xml.GetAttribute(ctrl.xmlNode, "Text");
            }
            else
            {
                labelText = ctrl.Label + ":";
            }

            if (ctrl.HasAttribute("Width"))
            {
                ctrl.SetAttribute("Width", ctrl.GetAttribute("Width"));
            }
            else
            {
                ctrl.SetAttribute("Width", (PanelLayoutGenerator.MeasureTextWidth(labelText) + 5).ToString());
            }

            if (ctrl.HasAttribute("Height"))
            {
                ctrl.SetAttribute("Height", ctrl.GetAttribute("Height"));
            }

            writer.SetControlProperty(ctrl, "Text", "\"" + labelText + "\"");
            writer.SetControlProperty(ctrl, "Padding", "new System.Windows.Forms.Padding(0, 5, 0, 0)");

            if (FRightAlign)
            {
                writer.SetControlProperty(ctrl, "TextAlign", "System.Drawing.ContentAlignment.TopRight");
            }

            return(writer.FTemplate);
        }
예제 #11
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 ACtrl)
        {
            ProcessTemplate ctrlSnippet = base.SetControlProperties(writer, ACtrl);

            ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet,
                                                          "URL",
                                                          ACtrl,
                                                          TYml2Xml.GetAttribute(ACtrl.xmlNode, "url"));
            ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet,
                                                          "BROWSERMISSINGIFRAMESUPPORT",
                                                          null,
                                                          "Your browser is not able to display embedded documents. Please click on the following link to read the text: ");
            ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet,
                                                          "IFRAMEINBIGGERWINDOW",
                                                          null,
                                                          "Open this document in a bigger window");

            ctrlSnippet.SetCodelet("HEIGHT", "250");

            if (ACtrl.HasAttribute("Height"))
            {
                ctrlSnippet.SetCodelet("HEIGHT", ACtrl.GetAttribute("Height"));
            }

            return(ctrlSnippet);
        }
예제 #12
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)
        {
            if (IsMniFilterFindClickAndIgnore(writer, ctrl, false))
            {
                return(writer.FTemplate);
            }

            base.SetControlProperties(writer, ctrl);

            // deactivate menu items that have no action assigned yet.
            if ((ctrl.GetAction() == null) && !ctrl.HasAttribute("ActionClick") && !ctrl.HasAttribute("ActionOpenScreen") &&
                (ctrl.NumberChildren == 0) && !(this is MenuItemSeparatorGenerator))
            {
                string ActionEnabling = ctrl.controlName + ".Enabled = false;" + Environment.NewLine;
                writer.Template.AddToCodelet("ACTIONENABLINGDISABLEMISSINGFUNCS", ActionEnabling);
            }

            writer.SetControlProperty(ctrl, "Text", "\"" + ctrl.Label + "\"");

            if (ctrl.HasAttribute("ShortcutKeys"))
            {
                writer.SetControlProperty(ctrl, "ShortcutKeys", ctrl.GetAttribute("ShortcutKeys"));
            }

            // todo: this.toolStripMenuItem1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;

            return(writer.FTemplate);
        }
예제 #13
0
        /// <summary>
        /// Determines whether automatic Data Validation code should be created for a certain Control in a YAML file.
        /// </summary>
        /// <param name="AControl">Control in YAML file.</param>
        /// <param name="AHasDataField"></param>
        /// <param name="AMasterOrDetailTable">Pass in 'true' if the YAML file has got a 'MasterTable' or 'DetailTable' Element. </param>
        /// <param name="AIncludeMasterOrDetailTableControl"></param>
        /// <param name="AScope">Scope of the Data Validation that should be checked for. Specify <see cref="TAutomDataValidationScope.advsAll"/>
        /// to find out if any of the scopes should be checked against, or use any other value of that enum to specifiy a specific scope.</param>
        /// <param name="AReasonForAutomValidation">Contains the reason why automatic data validation code needs to be generated.</param>
        /// <returns>True if automatic Data Validation code should be created for the Control in a YAML that was passed in in <paramref name="AControl" /> for
        /// the scope that was specified with <paramref name="AScope" />, otherwise false. This Method also returns false if the Control specified in
        /// <paramref name="AControl" /> isn't linked to a DB Table Field.</returns>
        public static bool GenerateAutoValidationCodeForControl(TControlDef AControl, bool AHasDataField, bool AMasterOrDetailTable,
            bool AIncludeMasterOrDetailTableControl, TAutomDataValidationScope AScope, out string AReasonForAutomValidation)
        {
            TTableField DBField = null;
            bool IsDetailNotMaster;

            AReasonForAutomValidation = String.Empty;

            if (AHasDataField)
            {
                DBField = TDataBinding.GetTableField(AControl, AControl.GetAttribute("DataField"), out IsDetailNotMaster, true);
            }
            else if (AMasterOrDetailTable && AIncludeMasterOrDetailTableControl)
            {
                DBField = TDataBinding.GetTableField(AControl, AControl.controlName.Substring(
                        AControl.controlTypePrefix.Length), out IsDetailNotMaster, false);
            }

            if (DBField != null)
            {
                return GenerateAutoValidationCodeForDBTableField(DBField, AScope, null, out AReasonForAutomValidation);
            }
            else
            {
                return false;
            }
        }
예제 #14
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)
        {
            base.SetControlProperties(writer, ctrl);
            writer.SetControlProperty(ctrl, "FixedRows", "1");
            writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".CancelEditingWithEscapeKey = false;" + Environment.NewLine);

            // Grid AutoFind definition.  Unlike normal grids this applies whether columns and sorting are defined or not.
            // Checked list boxes enable first character auto find by default using column 1/
            // If you want something different it must be specified in YAML
            string autoFindStr = ctrl.controlName + ".AutoFindMode = TAutoFindModeEnum.";

            if (ctrl.HasAttribute("AutoFindMode"))
            {
                autoFindStr += ctrl.GetAttribute("AutoFindMode");
                TLogging.Log("Info: AutoFindMode for checked list box was set from explicit YAML attribute: " + ctrl.controlName);
            }
            else
            {
                autoFindStr += "FirstCharacter";
                TLogging.Log("Info: AutoFindMode for checked list box was set implicitly for: " + ctrl.controlName);
            }

            writer.Template.AddToCodelet("INITMANUALCODE", autoFindStr + ";" + Environment.NewLine);

            if (ctrl.HasAttribute("AutoFindColumn"))
            {
                writer.Template.AddToCodelet("INITMANUALCODE",
                                             ctrl.controlName + ".AutoFindColumn = " + ctrl.GetAttribute("AutoFindColumn") + ";" + Environment.NewLine);
            }

            return(writer.FTemplate);
        }
예제 #15
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)
        {
            if ((ctrl.HasAttribute("CheckBoxAttachedLabel")) &&
                ((ctrl.GetAttribute("CheckBoxAttachedLabel").ToLower() == "left") ||
                 (ctrl.GetAttribute("CheckBoxAttachedLabel").ToLower() == "right")))
            {
                base.FAutoSize = true;

                if (ctrl.HasAttribute("NoLabel") && (ctrl.GetAttribute("NoLabel").ToLower() == "true"))
                {
                    writer.SetControlProperty(ctrl, "Text", "\"\"");
                }
                else
                {
                    writer.SetControlProperty(ctrl, "Text", "\"" + ctrl.Label + "\"");

                    if (ctrl.GetAttribute("CheckBoxAttachedLabel").ToLower() == "left")
                    {
                        writer.SetControlProperty(ctrl, "CheckAlign", "System.Drawing.ContentAlignment.MiddleRight");
                    }
                    else
                    {
                        writer.SetControlProperty(ctrl, "CheckAlign", "System.Drawing.ContentAlignment.MiddleLeft");
                    }

                    writer.SetControlProperty(ctrl, "Margin", "new System.Windows.Forms.Padding(3, 4, 3, 0)");

                    ctrl.SetAttribute("Width", (PanelLayoutGenerator.MeasureTextWidth(ctrl.Label) + 30).ToString());
                    ctrl.SetAttribute("Height", "17");
                }

                base.SetControlProperties(writer, ctrl);
            }
            else
            {
                base.FAutoSize = false;
                ctrl.SetAttribute("Width", 30.ToString ());

                base.SetControlProperties(writer, ctrl);

                writer.SetControlProperty(ctrl, "Text", "\"\"");
                writer.SetControlProperty(ctrl, "Margin", "new System.Windows.Forms.Padding(3, 0, 3, 0)");
            }

            return(writer.FTemplate);
        }
예제 #16
0
        /// <summary>
        /// add controls to the TableLayoutPanel, but don't write yet;
        /// writing is done in WriteTableLayout, when the layout can be optimised
        /// </summary>
        /// <param name="childctrl"></param>
        /// <param name="column"></param>
        /// <param name="row"></param>
        public void AddControl(
            TControlDef childctrl,
            Int32 column, Int32 row)
        {
            FGrid[column, row] = childctrl;

            childctrl.colSpan = childctrl.HasAttribute("ColSpan") ? Convert.ToInt32(childctrl.GetAttribute("ColSpan")) : 1;
            childctrl.rowSpan = childctrl.HasAttribute("RowSpan") ? Convert.ToInt32(childctrl.GetAttribute("RowSpan")) : 1;

            if (!childctrl.hasLabel)
            {
                childctrl.colSpanWithLabel = childctrl.colSpan * 2;
            }
            else
            {
                childctrl.colSpanWithLabel = childctrl.colSpan * 2 - 1;
            }
        }
예제 #17
0
        /// <summary>
        /// write the code for reading and writing the controls with the parameters
        /// </summary>
        public static void GenerateReadSetControls(TFormWriter writer, XmlNode curNode, ProcessTemplate ATargetTemplate, string ATemplateControlType)
        {
            string controlName = curNode.Name;

            // check if this control is already part of an optional group of controls depending on a radiobutton
            TControlDef ctrl = writer.CodeStorage.GetControl(controlName);

            if (ctrl.GetAttribute("DependsOnRadioButton") == "true")
            {
                return;
            }

            if (ctrl.GetAttribute("NoParameter") == "true")
            {
                return;
            }

            string paramName = ReportControls.GetParameterName(curNode);

            if (paramName == null)
            {
                return;
            }

            bool clearIfSettingEmpty = ReportControls.GetClearIfSettingEmpty(curNode);

            ProcessTemplate snippetReadControls = writer.Template.GetSnippet(ATemplateControlType + "READCONTROLS");

            snippetReadControls.SetCodelet("CONTROLNAME", controlName);
            snippetReadControls.SetCodelet("PARAMNAME", paramName);
            ATargetTemplate.InsertSnippet("READCONTROLS", snippetReadControls);

            ProcessTemplate snippetWriteControls = writer.Template.GetSnippet(ATemplateControlType + "SETCONTROLS");

            snippetWriteControls.SetCodelet("CONTROLNAME", controlName);
            snippetWriteControls.SetCodelet("PARAMNAME", paramName);

            if (clearIfSettingEmpty)
            {
                snippetWriteControls.SetCodelet("CLEARIFSETTINGEMPTY", clearIfSettingEmpty.ToString().ToLower());
            }

            ATargetTemplate.InsertSnippet("SETCONTROLS", snippetWriteControls);
        }
예제 #18
0
        /// <summary>add GeneratedReadSetControls</summary>
        public override void ApplyDerivedFunctionality(TFormWriter writer, TControlDef control)
        {
            TControlDef ctrl        = writer.CodeStorage.GetControl(control.xmlNode.Name);
            string      numericType = ctrl.GetAttribute("Format");

            if (numericType == "Currency")
            {
                ReportControls.GenerateReadSetControls(writer, control.xmlNode, writer.Template, "DECIMALTEXTBOX");
            }
        }
예제 #19
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)
        {
            base.SetControlProperties(writer, ctrl);

            if ((ctrl.HasAttribute("AlwaysHideLabel") && (ctrl.GetAttribute("AlwaysHideLabel").ToLower() == "true")))
            {
                writer.SetControlProperty(ctrl, "AlwaysHideLabel", "true");
            }
            else if ((ctrl.HasAttribute("ShowLabel") && (ctrl.GetAttribute("ShowLabel").ToLower() == "false")))
            {
                writer.SetControlProperty(ctrl, "ShowLabel", "false");
            }

            // Order is important: set Context before ControlMode and before CurrencyCode
            writer.SetControlProperty(ctrl, "Context", "this");
            writer.SetControlProperty(ctrl, "ControlMode", "TTxtNumericTextBox.TNumericTextBoxMode.Currency");
            writer.SetControlProperty(ctrl, "NullValueAllowed", FNullValueAllowed.ToString().ToLower());
            writer.SetControlProperty(ctrl, "CurrencyCode", "\"###\"");

            return(writer.FTemplate);
        }
예제 #20
0
        private static void LayoutCellInForm(TControlDef ACtrl,
                                             Int32 AChildrenCount,
                                             ProcessTemplate ACtrlSnippet,
                                             ProcessTemplate ASnippetCellDefinition)
        {
            if (ACtrl.HasAttribute("labelWidth"))
            {
                ASnippetCellDefinition.SetCodelet("LABELWIDTH", ACtrl.GetAttribute("labelWidth"));
            }

            if (ACtrl.HasAttribute("columnWidth"))
            {
                ASnippetCellDefinition.SetCodelet("COLUMNWIDTH", ACtrl.GetAttribute("columnWidth").Replace(",", "."));
            }
            else
            {
                ASnippetCellDefinition.SetCodelet("COLUMNWIDTH", (1.0 / AChildrenCount).ToString().Replace(",", "."));
            }

            string Anchor = ANCHOR_DEFAULT_COLUMN;

            if (AChildrenCount == 1)
            {
                Anchor = ANCHOR_SINGLE_COLUMN;
            }

            if (ACtrl.HasAttribute("columnWidth"))
            {
                Anchor = "94%";
            }

            if (ACtrl.GetAttribute("hideLabel") == "true")
            {
                ACtrlSnippet.SetCodelet("HIDELABEL", "true");
                Anchor = ANCHOR_HIDDEN_LABEL;
            }

            ACtrlSnippet.SetCodelet("ANCHOR", Anchor);
        }
예제 #21
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)
        {
            base.SetControlProperties(writer, ctrl);

            if ((ctrl.HasAttribute("ShowLabel") && (ctrl.GetAttribute("ShowLabel").ToLower() == "false")))
            {
                writer.SetControlProperty(ctrl, "ShowLabel", "false");
            }

            writer.SetControlProperty(ctrl, "DecimalPlaces", FDecimalPrecision.ToString());
            writer.SetControlProperty(ctrl, "NullValueAllowed", FNullValueAllowed.ToString().ToLower());
            writer.SetControlProperty(ctrl, "CurrencyCode", "\"###\"");

            return(writer.FTemplate);
        }
예제 #22
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 ACtrl)
        {
            ProcessTemplate ctrlSnippet = base.SetControlProperties(writer, ACtrl);

            ctrlSnippet.SetCodelet("PAGENUMBER", PageCounter.ToString());

            if (writer.FTemplate.FCodelets.Keys.Contains("CUSTOMFUNCTIONS"))
            {
                ctrlSnippet.SetCodelet("CUSTOMFUNCTIONS", writer.FTemplate.FCodelets["CUSTOMFUNCTIONS"].ToString());
                writer.FTemplate.FCodelets.Remove("CUSTOMFUNCTIONS");
            }
            else
            {
                ctrlSnippet.SetCodelet("CUSTOMFUNCTIONS", String.Empty);
            }

            if (writer.FTemplate.FCodelets.Keys.Contains("ONSHOW"))
            {
                ctrlSnippet.SetCodelet("ONSHOW", writer.FTemplate.FCodelets["ONSHOW"].ToString());
                writer.FTemplate.FCodelets.Remove("ONSHOW");
            }

            if (writer.FTemplate.FCodelets.Keys.Contains("ISVALID"))
            {
                ctrlSnippet.SetCodelet("ISVALID", writer.FTemplate.FCodelets["ISVALID"].ToString());
                writer.FTemplate.FCodelets.Remove("ISVALID");
            }

            if (writer.FTemplate.FCodelets.Keys.Contains("ONHIDE"))
            {
                ctrlSnippet.SetCodelet("ONHIDE", writer.FTemplate.FCodelets["ONHIDE"].ToString());
                writer.FTemplate.FCodelets.Remove("ONHIDE");
            }

            if (ACtrl.HasAttribute("Height"))
            {
                ctrlSnippet.AddToCodelet("ONSHOW", String.Format("MainForm.setHeight({0});", ACtrl.GetAttribute("Height")));
            }

            if (ACtrl.HasAttribute("LabelWidth"))
            {
                ctrlSnippet.SetCodelet("LABELWIDTH", ACtrl.GetAttribute("LabelWidth"));
            }

            PageCounter++;

            return(ctrlSnippet);
        }
예제 #23
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 ctrlSnippet = base.SetControlProperties(writer, ctrl);

            writer.FTemplate.SetCodelet("ASSISTANT", "true");

            string AssistantHeader = "true";

            if (ctrl.HasAttribute("AssistantHeader"))
            {
                AssistantHeader = ctrl.GetAttribute("AssistantHeader");
            }

            ctrlSnippet.SetCodelet("ASSISTANTHEADER", AssistantHeader);

            return(ctrlSnippet);
        }
예제 #24
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);
        }
예제 #25
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)
        {
            base.SetControlProperties(writer, ctrl);

            if (ctrl.GetAttribute("AutoComplete").EndsWith("History"))
            {
                writer.SetControlProperty(ctrl, "AcceptNewValues", "true");
                writer.SetEventHandlerToControl(ctrl.controlName,
                                                "AcceptNewEntries",
                                                "TAcceptNewEntryEventHandler",
                                                "FPetraUtilsObject.AddComboBoxHistory");
                writer.CallControlFunction(ctrl.controlName, "SetDataSourceStringList(\"\")");
                writer.Template.AddToCodelet("INITUSERCONTROLS",
                                             "FPetraUtilsObject.LoadComboBoxHistory(" + ctrl.controlName + ");" + Environment.NewLine);
            }

            return(writer.FTemplate);
        }
        /// <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)
        {
            base.SetControlProperties(writer, ctrl);

            if (ctrl.GetAttribute("AutoComplete").EndsWith("History"))
            {
                writer.SetControlProperty(ctrl, "AcceptNewValues", "true");
                writer.SetEventHandlerToControl(ctrl.controlName,
                    "AcceptNewEntries",
                    "TAcceptNewEntryEventHandler",
                    "FPetraUtilsObject.AddComboBoxHistory");
                writer.CallControlFunction(ctrl.controlName, "SetDataSourceStringList(\"\")");
                writer.Template.AddToCodelet("INITUSERCONTROLS",
                    "FPetraUtilsObject.LoadComboBoxHistory(" + ctrl.controlName + ");" + Environment.NewLine);
            }

            return writer.FTemplate;
        }
예제 #27
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 ctrlSnippet = base.SetControlProperties(writer, ctrl);

            string valuesArray = "[";

            List <XmlNode> optionalValues =
                TYml2Xml.GetChildren(TXMLParser.GetChild(ctrl.xmlNode, "OptionalValues"), true);

            // DefaultValue with = sign before control name
            for (int counter = 0; counter < optionalValues.Count; counter++)
            {
                string loopValue = TYml2Xml.GetElementName(optionalValues[counter]);

                if (loopValue.StartsWith("="))
                {
                    loopValue = loopValue.Substring(1).Trim();
                    ctrlSnippet.SetCodelet("VALUE", loopValue);
                }

                if (counter > 0)
                {
                    valuesArray += ", ";
                }

                ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "OPTION" + counter.ToString(), ctrl, loopValue);

                string strName = "this." + ctrl.controlName + "OPTION" + counter.ToString();

                valuesArray += "['" + loopValue + "', " + strName + "]";
            }

            valuesArray += "]";

            ctrlSnippet.SetCodelet("OPTIONALVALUESARRAY", valuesArray);

            if (ctrl.HasAttribute("width"))
            {
                ctrlSnippet.SetCodelet("WIDTH", ctrl.GetAttribute("width"));
            }

            return(ctrlSnippet);
        }
예제 #28
0
        /// <summary>
        /// get the label text for this control
        /// </summary>
        /// <param name="ctrl"></param>
        /// <returns></returns>
        public virtual bool GenerateLabel(TControlDef ctrl)
        {
            if (ctrl.HasAttribute("NoLabel") && (ctrl.GetAttribute("NoLabel").ToLower() == "true"))
            {
                ctrl.hasLabel = false;
                return false;
            }

            ctrl.hasLabel = FGenerateLabel;
            return ctrl.hasLabel;
        }
예제 #29
0
        private bool GenerateDataValidationCode(TFormWriter writer, TControlDef ctrl, out bool AAutomDataValidation,
            out string AReasonForAutomValidation)
        {
            AAutomDataValidation = false;
            AReasonForAutomValidation = String.Empty;

            if ((ctrl.HasAttribute("Validation"))
                && (ctrl.GetAttribute("Validation").ToLower() != "false"))
            {
                return true;
            }

            if (TDataValidation.GenerateAutoValidationCodeForControl(ctrl,
                    ctrl.HasAttribute("DataField"),
                    (writer.CodeStorage.HasAttribute("MasterTable")
                     || writer.CodeStorage.HasAttribute("DetailTable")),
                    !((this is LabelGenerator) || (this is LinkLabelGenerator)),
                    TDataValidation.TAutomDataValidationScope.advsAll, out AReasonForAutomValidation)
                )
            {
                AAutomDataValidation = true;

                return true;
            }
            else
            {
                return false;
            }
        }
예제 #30
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)
        {
            if (!ctrl.HasAttribute("Width"))
            {
                ctrl.SetAttribute("Width", FDefaultWidth.ToString());
            }

            base.SetControlProperties(writer, ctrl);

            writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".CancelEditingWithEscapeKey = false;" + Environment.NewLine);

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "SelectedRowActivates"))
            {
                // TODO: this function needs to be called by the manual code at the moment when eg a search finishes
                // TODO: call "Activate" + TYml2Xml.GetAttribute(ctrl.xmlNode, "SelectedRowActivates")
            }

            StringCollection Columns = TYml2Xml.GetElements(ctrl.xmlNode, "Columns");

            if (Columns.Count > 0)
            {
                writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".Columns.Clear();" + Environment.NewLine);

                //This needs to come immediately after the Columns.Clear() and before the creation of the columns
                if (ctrl.HasAttribute("SortableHeaders"))
                {
                    string trueOrFalse = ctrl.GetAttribute("SortableHeaders");
                    writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".SortableHeaders = " + trueOrFalse + ";" + Environment.NewLine);
                }

                foreach (string ColumnFieldName in Columns)
                {
                    bool IsDetailNotMaster;
                    TTableField field = null;
                    string TableFieldTable;
                    string ColumnFieldNameResolved;

                    // customfield, eg. UC_GLTransactions, ATransaction.DateEntered and ATransaction.AnalysisAttributes
                    // there needs to be a list of CustomColumns
                    XmlNode CustomColumnsNode = TYml2Xml.GetChild(ctrl.xmlNode, "CustomColumns");
                    XmlNode CustomColumnNode = null;

                    if (CustomColumnsNode != null)
                    {
                        CustomColumnNode = TYml2Xml.GetChild(CustomColumnsNode, ColumnFieldName);
                    }

                    if ((ctrl.controlName == "grdDetails") && FCodeStorage.HasAttribute("DetailTable"))
                    {
                        TableFieldTable = FCodeStorage.GetAttribute("DetailTable");

                        if (ColumnFieldName.StartsWith("Detail") && !IsLegitimateDetailFieldName(TableFieldTable, ColumnFieldName))
                        {
                            ColumnFieldNameResolved = ColumnFieldName.Substring(6);     // Drop 'Details' out of 'Details...'
                        }
                        else
                        {
                            ColumnFieldNameResolved = ColumnFieldName;
                        }
                    }
                    else
                    {
                        TableFieldTable = ctrl.GetAttribute("TableName");
                        ColumnFieldNameResolved = ColumnFieldName;
                    }

                    if (CustomColumnNode != null)
                    {
                        // if grd has no TableName property
                        if ((TableFieldTable == "") && ColumnFieldNameResolved.Contains("."))
                        {
                            int Period = ColumnFieldNameResolved.IndexOf(".");
                            string TableName = ColumnFieldNameResolved.Remove(Period);
                            string ColumnName = ColumnFieldNameResolved.Remove(0, TableName.Length + 1);

                            AddColumnToGrid(writer, ctrl.controlName,
                                TYml2Xml.GetAttribute(CustomColumnNode, "Type"),
                                TYml2Xml.GetAttribute(CustomColumnNode, "Label"),
                                TYml2Xml.GetAttribute(CustomColumnNode, "Tooltip"),
                                TableName,
                                ColumnName);
                        }
                        else
                        {
                            AddColumnToGrid(writer, ctrl.controlName,
                                TYml2Xml.GetAttribute(CustomColumnNode, "Type"),
                                TYml2Xml.GetAttribute(CustomColumnNode, "Label"),
                                TYml2Xml.GetAttribute(CustomColumnNode, "Tooltip"),
                                TableFieldTable,
                                ColumnFieldNameResolved);
                        }
                    }
                    else if (ctrl.HasAttribute("TableName"))
                    {
                        field =
                            TDataBinding.GetTableField(null, ctrl.GetAttribute("TableName") + "." + ColumnFieldName, out IsDetailNotMaster,
                                true);
                    }
                    else
                    {
                        field = TDataBinding.GetTableField(null, ColumnFieldName, out IsDetailNotMaster, true);
                    }

                    if (field != null)
                    {
                        AddColumnToGrid(writer, ctrl.controlName,
                            field.iDecimals == 10 && field.iLength == 24 ? "Currency" : field.GetDotNetType(),
                            field.strLabel.Length > 0 ? field.strLabel : field.strName,
                            String.Empty,
                            TTable.NiceTableName(field.strTableName),
                            TTable.NiceFieldName(field.strName));
                    }
                }
            }
            else
            {
                //If no columns, but the user is able to add columns dynamically during the running of the form, then need this here.
                if (ctrl.HasAttribute("SortableHeaders"))
                {
                    string trueOrFalse = ctrl.GetAttribute("SortableHeaders");
                    writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".SortableHeaders = " + trueOrFalse + ";" + Environment.NewLine);
                }
            }

            if (ctrl.controlName != "grdDetails")
            {
                if (ctrl.HasAttribute("ActionLeavingRow"))
                {
                    AssignEventHandlerToControl(writer, ctrl, "Selection.FocusRowLeaving", "SourceGrid.RowCancelEventHandler",
                        ctrl.GetAttribute("ActionLeavingRow"));
                }

                if (ctrl.HasAttribute("ActionFocusRow"))
                {
                    AssignEventHandlerToControl(writer, ctrl, "Selection.FocusRowEntered", "SourceGrid.RowEventHandler",
                        ctrl.GetAttribute("ActionFocusRow"));
                }
            }

            if (ctrl.HasAttribute("ActionEnterKeyPressed"))
            {
                AssignEventHandlerToControl(writer, ctrl, "EnterKeyPressed", "TKeyPressedEventHandler",
                    ctrl.GetAttribute("ActionEnterKeyPressed"));
            }

            if ((ctrl.controlName == "grdDetails") && FCodeStorage.HasAttribute("DetailTable"))
            {
                writer.Template.AddToCodelet("SHOWDATA", "");

                if (ctrl.HasAttribute("SortOrder"))
                {
                    // SortOrder is comma separated and has DESC or ASC after the column name
                    string SortOrder = ctrl.GetAttribute("SortOrder");

                    foreach (string SortOrderPart in SortOrder.Split(','))
                    {
                        bool temp;
                        TTableField field = null;

                        if ((SortOrderPart.Split(' ')[0].IndexOf(".") == -1) && ctrl.HasAttribute("TableName"))
                        {
                            field = TDataBinding.GetTableField(null, ctrl.GetAttribute("TableName") + "." + SortOrderPart.Split(
                                    ' ')[0], out temp, true);
                        }
                        else
                        {
                            field =
                                TDataBinding.GetTableField(
                                    null,
                                    SortOrderPart.Split(' ')[0],
                                    out temp, true);
                        }

                        if (field != null)
                        {
                            SortOrder = SortOrder.Replace(SortOrderPart.Split(' ')[0], field.strName);
                        }
                    }

                    writer.Template.AddToCodelet("GRIDSORT", SortOrder);
                }

                if (ctrl.HasAttribute("RowFilter"))
                {
                    // this references a field in the table, and assumes there exists a local variable with the same name
                    // eg. FBatchNumber in GL Journals
                    string RowFilter = ctrl.GetAttribute("RowFilter");

                    String FilterString = "\"";

                    foreach (string RowFilterPart in RowFilter.Split(','))
                    {
                        bool temp;
                        string columnName =
                            TDataBinding.GetTableField(
                                null,
                                RowFilterPart,
                                out temp, true).strName;

                        if (FilterString.Length > 1)
                        {
                            FilterString += " + \" and ";
                        }

                        FilterString += columnName + " = \" + F" + TTable.NiceFieldName(columnName) + ".ToString()";
                    }

                    writer.Template.AddToCodelet("GRIDFILTER", FilterString);
                }
            }

            if (ctrl.controlName == "grdDetails")
            {
                if (ctrl.HasAttribute("EnableMultiSelection"))
                {
                    writer.Template.SetCodelet("GRIDMULTISELECTION",
                        String.Format("grdDetails.Selection.EnableMultiSelection = {0};{1}", ctrl.GetAttribute("EnableMultiSelection"),
                            Environment.NewLine));
                }
                else if (FCodeStorage.FControlList.ContainsKey("btnDelete"))
                {
                    writer.Template.SetCodelet("GRIDMULTISELECTION",
                        "grdDetails.Selection.EnableMultiSelection = true;" + Environment.NewLine);
                }
            }

            return writer.FTemplate;
        }
        /// <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)
        {
            if (ctrl.HasAttribute("Width") && ctrl.HasAttribute("Height"))
            {
                FAutoSize = false;
            }
            else if (ctrl.HasAttribute("Height"))
            {
                // assume width of parent control
                ctrl.SetAttribute("Width", (FCodeStorage.FWidth - 10).ToString());
                FAutoSize = false;
            }
            else if (ctrl.HasAttribute("Width") && (ctrl.GetAttribute("Dock") != "Left")
                     && (ctrl.GetAttribute("Dock") != "Right"))
            {
                throw new Exception(
                    "Control " + ctrl.controlName +
                    " must have both Width and Height attributes, or just Height, but not Width alone");
            }

            base.CreateControlsAddStatements = false;
            base.SetControlProperties(writer, ctrl);

            if ((base.FPrefix == "grp") || (base.FPrefix == "rgr") || (base.FPrefix == "tpg"))
            {
                FGenerateLabel = true;

                if (GenerateLabel(ctrl))
                {
                    writer.SetControlProperty(ctrl, "Text", "\"" + ctrl.Label + "\"");
                }

                FGenerateLabel = false;
            }

            return writer.FTemplate;
        }
예제 #32
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)
        {
            bool OverrideImageAlign = false;
            bool OverrideTextAlign  = false;
            bool NoLabel            = false;

            TLogging.LogAtLevel(1, "ButtonGenerator.SetControlProperties for Control " + ctrl.controlName);

            if (!ctrl.HasAttribute("Width"))
            {
                ctrl.SetAttribute("Width", (PanelLayoutGenerator.MeasureTextWidth(ctrl.Label) + 15).ToString());
            }

            if (ctrl.HasAttribute("NoLabel") && (ctrl.GetAttribute("NoLabel").ToLower() == "true"))
            {
                writer.SetControlProperty(ctrl, "Text", "\"\"");

                NoLabel = true;
            }
            else
            {
                writer.SetControlProperty(ctrl, "Size", "new System.Drawing.Size(" +
                                          ctrl.GetAttribute("Width").ToString() + ", " + ctrl.GetAttribute("Height").ToString() + ")");
                writer.SetControlProperty(ctrl, "Text", "\"" + ctrl.Label + "\"");
            }

            if (ctrl.IsOnHorizontalGridButtonPanel)
            {
                TLogging.LogAtLevel(1, "Setting Height for Control '" + ctrl.controlName + "' to 23 as it is on a horizontal Grid Button Panel");
                FDefaultHeight = 23;

                if (!ctrl.HasAttribute("ImageAlign"))
                {
                    if (NoLabel)
                    {
                        //TLogging.LogAtLevel(1, "Setting ImageAlign Attribute of Control '" + ctrl.controlName + "' to System.Drawing.ContentAlignment.BottomCenter as it is on a horizontal Grid Button Panel (no Text)");
                        writer.SetControlProperty(ctrl, "ImageAlign", "System.Drawing.ContentAlignment.BottomCenter");
                    }
                    else
                    {
                        //TLogging.LogAtLevel(1, "Setting ImageAlign Attribute of Control '" + ctrl.controlName + "' to System.Drawing.ContentAlignment.BottomLeft as it is on a horizontal Grid Button Panel");
                        writer.SetControlProperty(ctrl, "ImageAlign", "System.Drawing.ContentAlignment.BottomLeft");

                        // Note: In this case want the text centered on the Button, which the TextAlign Property will achieve.
                        // However, its default value is System.Drawing.ContentAlignment.MiddleCenter which means we don't need to explicitly write this out into the Designer file...
                        //TLogging.LogAtLevel(1, "Setting TextAlign Attribute of Control '" + ctrl.controlName + "' to System.Drawing.ContentAlignment.MiddleCenter as it is on a horizontal Grid Button Panel");
//                        writer.SetControlProperty(ctrl, "TextAlign", "System.Drawing.ContentAlignment.MiddleCenter");
                    }

                    OverrideImageAlign = true;
                    OverrideTextAlign  = true;
                }
            }
            else
            {
                if (!ctrl.HasAttribute("Height"))
                {
                    ctrl.SetAttribute("Height", FDefaultHeight.ToString());
                }
            }

            base.SetControlProperties(writer, ctrl);

            if (ctrl.GetAttribute("AcceptButton").ToLower() == "true")
            {
                writer.Template.AddToCodelet("INITUSERCONTROLS", "this.AcceptButton = " + ctrl.controlName + ";" + Environment.NewLine);
            }

            if (ctrl.GetAction() != null)
            {
                string img = ctrl.GetAction().actionImage;

                if (img.Length > 0)
                {
                    ctrl.SetAttribute("Width", (Convert.ToInt32(ctrl.GetAttribute("Width")) +
                                                Convert.ToInt32(ctrl.GetAttribute("IconWidth", "15"))).ToString());
                    writer.SetControlProperty(ctrl, "Size", "new System.Drawing.Size(" +
                                              ctrl.GetAttribute("Width").ToString() + ", " + ctrl.GetAttribute("Height").ToString() + ")");

                    if (writer.GetControlProperty(ctrl.controlName, "Text") == "\"\"")
                    {
                        if ((!ctrl.HasAttribute("ImageAlign")) &&
                            !OverrideImageAlign)
                        {
                            // Note: In this case we want the Image centered on the Button, which the ImageAlign Property will achieve.
                            // However, its default value is System.Drawing.ContentAlignment.MiddleCenter which means we don't need to explicitly write this out into the Designer file...

//Console.WriteLine("Setting ImageAlign Attribute of Control '" + ctrl.controlName + "' to System.Drawing.ContentAlignment.MiddleCenter as it is NOT on a horizontal Grid Button Panel (no Text)");
//                            writer.SetControlProperty(ctrl, "ImageAlign", "System.Drawing.ContentAlignment.MiddleCenter");
                        }
                    }
                    else
                    {
                        if ((!ctrl.HasAttribute("ImageAlign")) &&
                            !OverrideImageAlign)
                        {
//Console.WriteLine("Setting ImageAlign Attribute of Control '" + ctrl.controlName + "' to System.Drawing.ContentAlignment.MiddleLeft as it is NOT on a horizontal Grid Button Panel");
                            writer.SetControlProperty(ctrl, "ImageAlign", "System.Drawing.ContentAlignment.MiddleLeft");
                        }
                    }

                    if (!OverrideTextAlign)
                    {
//Console.WriteLine("Setting TextAlign Attribute of Control '" + ctrl.controlName + "' to System.Drawing.ContentAlignment.MiddleRight as it is NOT on a horizontal Grid Button Panel");
                        writer.SetControlProperty(ctrl, "TextAlign", "System.Drawing.ContentAlignment.MiddleRight");
                    }
                }
            }

            return(writer.FTemplate);
        }
예제 #33
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 ctrlSnippet = base.SetControlProperties(writer, ctrl);

            if (ctrlSnippet.FTemplateCode.Contains("{#REDIRECTONSUCCESS}"))
            {
                ProcessTemplate redirectSnippet = writer.FTemplate.GetSnippet("REDIRECTONSUCCESS");

                ctrlSnippet.SetCodelet("REDIRECTONSUCCESS", redirectSnippet.FTemplateCode.ToString());
            }

            if (ctrl.HasAttribute("AjaxRequestUrl"))
            {
                ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "VALIDATIONERRORTITLE", ctrl, ctrl.GetAttribute("ValidationErrorTitle"));
                ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "VALIDATIONERRORMESSAGE", ctrl, ctrl.GetAttribute("ValidationErrorMessage"));
                ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "SENDINGDATATITLE", ctrl, ctrl.GetAttribute("SendingMessageTitle"));
                ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "SENDINGDATAMESSAGE", ctrl, ctrl.GetAttribute("SendingMessage"));

                if (ctrl.HasAttribute("SuccessMessage"))
                {
                    ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "REQUESTSUCCESSTITLE", ctrl, ctrl.GetAttribute("SuccessMessageTitle"));
                    ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "REQUESTSUCCESSMESSAGE", ctrl, ctrl.GetAttribute("SuccessMessage"));
                }

                ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "REQUESTFAILURETITLE", ctrl, ctrl.GetAttribute("FailureMessageTitle"));
                ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "REQUESTFAILUREMESSAGE", ctrl, ctrl.GetAttribute("FailureMessage"));
            }

            ctrlSnippet.SetCodelet("REQUESTURL", ctrl.GetAttribute("AjaxRequestUrl"));
            ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "REDIRECTURLONSUCCESS", ctrl, ctrl.GetAttribute("RedirectURLOnSuccess"));

            if (ctrl.GetAttribute("DownloadOnSuccess").StartsWith("jsonData"))
            {
                ctrlSnippet.SetCodelet("REDIRECTDOWNLOAD", ctrl.GetAttribute("DownloadOnSuccess"));
            }

            ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "REDIRECTURLONCANCEL", ctrl, ctrl.GetAttribute("RedirectURLOnCancel"));
            ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "CANCELQUESTIONTITLE", ctrl, ctrl.GetAttribute("CancelQuestionTitle"));
            ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "CANCELQUESTIONMESSAGE", ctrl, ctrl.GetAttribute("CancelQuestionMessage"));

            XmlNode AjaxParametersNode = TYml2Xml.GetChild(ctrl.xmlNode, "AjaxRequestParameters");

            if (AjaxParametersNode != null)
            {
                string ParameterString = String.Empty;

                foreach (XmlAttribute attr in AjaxParametersNode.Attributes)
                {
                    if (!attr.Name.Equals("depth"))
                    {
                        ParameterString += attr.Name + ": '" + attr.Value + "', ";
                    }
                }

                ctrlSnippet.SetCodelet("REQUESTPARAMETERS", ParameterString);
                writer.FTemplate.SetCodelet("REQUESTPARAMETERS", "true");
            }

            return ctrlSnippet;
        }
        /// <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)
        {
            string NumberFormat = String.Empty;

            base.SetControlProperties(writer, ctrl);

            if ((ctrl.HasAttribute("ShowLabel") && (ctrl.GetAttribute("ShowLabel").ToLower() == "false")))
            {
                writer.SetControlProperty(ctrl, "ShowLabel", "false");
            }

            // Note: the control defaults to 'ShowLabel' true, so this doesn't need to be set to 'true' in code.

            writer.SetControlProperty(ctrl, "ControlMode", "TTxtNumericTextBox.TNumericTextBoxMode." + FControlMode);
            writer.SetControlProperty(ctrl, "DecimalPlaces", FDecimalPrecision.ToString());
            writer.SetControlProperty(ctrl, "NullValueAllowed", FNullValueAllowed.ToString().ToLower());

            if (ctrl.HasAttribute("Format"))
            {
                NumberFormat = ctrl.GetAttribute("Format");
            }

            if ((NumberFormat.StartsWith("PercentInteger"))
                || (NumberFormat.StartsWith("PercentDecimal")))
            {
                writer.SetControlProperty(ctrl, "ShowPercentSign", "true");
            }

            return writer.FTemplate;
        }
        /// <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)
        {
            base.SetControlProperties(writer, ctrl);

            if ((ctrl.HasAttribute("ShowLabel") && (ctrl.GetAttribute("ShowLabel").ToLower() == "false")))
            {
                writer.SetControlProperty(ctrl, "ShowLabel", "false");
            }

            writer.SetControlProperty(ctrl, "DecimalPlaces", FDecimalPrecision.ToString());
            writer.SetControlProperty(ctrl, "NullValueAllowed", FNullValueAllowed.ToString().ToLower());
            writer.SetControlProperty(ctrl, "CurrencyCode", "\"###\"");

            return writer.FTemplate;
        }
예제 #36
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 ACtrl)
        {
            ProcessTemplate ctrlSnippet = base.SetControlProperties(writer, ACtrl);

            ctrlSnippet.SetCodelet("PAGENUMBER", PageCounter.ToString());

            if (writer.FTemplate.FCodelets.Keys.Contains("CUSTOMFUNCTIONS"))
            {
                ctrlSnippet.SetCodelet("CUSTOMFUNCTIONS", writer.FTemplate.FCodelets["CUSTOMFUNCTIONS"].ToString());
                writer.FTemplate.FCodelets.Remove("CUSTOMFUNCTIONS");
            }
            else
            {
                ctrlSnippet.SetCodelet("CUSTOMFUNCTIONS", String.Empty);
            }

            if (writer.FTemplate.FCodelets.Keys.Contains("ONSHOW"))
            {
                ctrlSnippet.SetCodelet("ONSHOW", writer.FTemplate.FCodelets["ONSHOW"].ToString());
                writer.FTemplate.FCodelets.Remove("ONSHOW");
            }

            if (writer.FTemplate.FCodelets.Keys.Contains("ISVALID"))
            {
                ctrlSnippet.SetCodelet("ISVALID", writer.FTemplate.FCodelets["ISVALID"].ToString());
                writer.FTemplate.FCodelets.Remove("ISVALID");
            }

            if (writer.FTemplate.FCodelets.Keys.Contains("ONHIDE"))
            {
                ctrlSnippet.SetCodelet("ONHIDE", writer.FTemplate.FCodelets["ONHIDE"].ToString());
                writer.FTemplate.FCodelets.Remove("ONHIDE");
            }

            if (ACtrl.HasAttribute("Height"))
            {
                ctrlSnippet.AddToCodelet("ONSHOW", String.Format("MainForm.setHeight({0});", ACtrl.GetAttribute("Height")));
            }

            if (ACtrl.HasAttribute("LabelWidth"))
            {
                ctrlSnippet.SetCodelet("LABELWIDTH", ACtrl.GetAttribute("LabelWidth"));
            }

            PageCounter++;

            return ctrlSnippet;
        }
예제 #37
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 ctrlSnippet = base.SetControlProperties(writer, ctrl);

            writer.FTemplate.SetCodelet("ASSISTANT", "true");

            string AssistantHeader = "true";

            if (ctrl.HasAttribute("AssistantHeader"))
            {
                AssistantHeader = ctrl.GetAttribute("AssistantHeader");
            }

            ctrlSnippet.SetCodelet("ASSISTANTHEADER", AssistantHeader);

            return ctrlSnippet;
        }
예제 #38
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 ACtrl)
        {
            ProcessTemplate ctrlSnippet = base.SetControlProperties(writer, ACtrl);

            ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet,
                "URL",
                ACtrl,
                TYml2Xml.GetAttribute(ACtrl.xmlNode, "url"));
            ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet,
                "BROWSERMISSINGIFRAMESUPPORT",
                null,
                "Your browser is not able to display embedded documents. Please click on the following link to read the text: ");
            ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet,
                "IFRAMEINBIGGERWINDOW",
                null,
                "Open this document in a bigger window");

            ctrlSnippet.SetCodelet("HEIGHT", "250");

            if (ACtrl.HasAttribute("Height"))
            {
                ctrlSnippet.SetCodelet("HEIGHT", ACtrl.GetAttribute("Height"));
            }

            return ctrlSnippet;
        }
예제 #39
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 ctrlSnippet = base.SetControlProperties(writer, ctrl);

            string valuesArray = "[";

            List <XmlNode>optionalValues =
                TYml2Xml.GetChildren(TXMLParser.GetChild(ctrl.xmlNode, "OptionalValues"), true);

            // DefaultValue with = sign before control name
            for (int counter = 0; counter < optionalValues.Count; counter++)
            {
                string loopValue = TYml2Xml.GetElementName(optionalValues[counter]);

                if (loopValue.StartsWith("="))
                {
                    loopValue = loopValue.Substring(1).Trim();
                    ctrlSnippet.SetCodelet("VALUE", loopValue);
                }

                if (counter > 0)
                {
                    valuesArray += ", ";
                }

                ((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "OPTION" + counter.ToString(), ctrl, loopValue);

                string strName = "this." + ctrl.controlName + "OPTION" + counter.ToString();

                valuesArray += "['" + loopValue + "', " + strName + "]";
            }

            valuesArray += "]";

            ctrlSnippet.SetCodelet("OPTIONALVALUESARRAY", valuesArray);

            if (ctrl.HasAttribute("width"))
            {
                ctrlSnippet.SetCodelet("WIDTH", ctrl.GetAttribute("width"));
            }

            return ctrlSnippet;
        }
예제 #40
0
        /// <summary>write the code for the designer file where the properties of the control are written</summary>
        public virtual ProcessTemplate SetControlProperties(TFormWriter writer, TControlDef ctrl)
        {
            bool AutomDataValidation;
            string ReasonForAutomValidation;
            bool IsDetailNotMaster;

            writer.SetControlProperty(ctrl, "Name", "\"" + ctrl.controlName + "\"");

            if (FLocation && !ctrl.HasAttribute("Dock"))
            {
                writer.SetControlProperty(ctrl, "Location", "new System.Drawing.Point(2,2)");
            }

            #region Aligning and stretching

            if (ctrl.HasAttribute("Align")
                && !(ctrl.HasAttribute("Stretch")))
            {
                if ((ctrl.GetAttribute("Align").ToLower() == "right")
                    || (ctrl.GetAttribute("Align").ToLower() == "top-right"))
                {
                    writer.SetControlProperty(ctrl,
                        "Anchor",
                        "((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)))");
                }
                else if (ctrl.GetAttribute("Align").ToLower() == "middle-right")
                {
                    writer.SetControlProperty(ctrl,
                        "Anchor",
                        "((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Right))");
                }
                else if (ctrl.GetAttribute("Align").ToLower() == "bottom-right")
                {
                    writer.SetControlProperty(ctrl,
                        "Anchor",
                        "((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)))");
                }
                else if ((ctrl.GetAttribute("Align").ToLower() == "center")
                         || (ctrl.GetAttribute("Align").ToLower() == "top-center"))
                {
                    writer.SetControlProperty(ctrl,
                        "Anchor",
                        "((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top))");
                }
                else if (ctrl.GetAttribute("Align").ToLower() == "middle-center")
                {
                    writer.SetControlProperty(ctrl,
                        "Anchor",
                        "((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.None))");
                }
                else if (ctrl.GetAttribute("Align").ToLower() == "bottom-center")
                {
                    writer.SetControlProperty(ctrl,
                        "Anchor",
                        "((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Bottom))");
                }
                else if ((ctrl.GetAttribute("Align").ToLower() == "bottom")
                         || (ctrl.GetAttribute("Align").ToLower() == "bottom-left"))
                {
                    writer.SetControlProperty(ctrl,
                        "Anchor",
                        "((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Bottom)))");
                }
                else if ((ctrl.GetAttribute("Align").ToLower() == "middle")
                         || (ctrl.GetAttribute("Align").ToLower() == "middle-left"))
                {
                    writer.SetControlProperty(ctrl,
                        "Anchor",
                        "((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Left))");
                }
                else if ((ctrl.GetAttribute("Align").ToLower() == "left")
                         || (ctrl.GetAttribute("Align").ToLower() == "top")
                         || (ctrl.GetAttribute("Align").ToLower() == "top-left"))
                {
                    // do nothing (here just to avoid throwing the following Exception)
                    Console.WriteLine(
                        "HINT: Attribute 'Align' with value 'left', 'top' or 'top-left' does not affect the layout since these create the default alignment. Control: '"
                        +
                        ctrl.controlName + "'.");
                }
                else
                {
                    throw new Exception("Invalid value for Attribute 'Align' of Control '" + ctrl.controlName + "': '" + ctrl.GetAttribute(
                            "Align") +
                        "'. Supported values are: Simple: left, right, center; top, middle, bottom; Combined: top-left, middle-left, bottom-left, top-center, middle-center, bottom-center, top-right, middle-right, bottom-right.");
                }
            }

            if (ctrl.HasAttribute("Stretch"))
            {
                if (ctrl.GetAttribute("Stretch").ToLower() == "horizontally")
                {
                    if ((!ctrl.HasAttribute("Align"))
                        || (ctrl.HasAttribute("Align") && (ctrl.GetAttribute("Align").ToLower() == "top")))
                    {
                        // Horizontally stretched, top aligned (=default)
                        writer.SetControlProperty(
                            ctrl,
                            "Anchor",
                            "((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)))");
                    }
                    else
                    {
                        if (ctrl.GetAttribute("Align").ToLower() == "bottom")
                        {
                            // Horizontally stretched, bottom aligned
                            writer.SetControlProperty(
                                ctrl,
                                "Anchor",
                                "((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)))");
                        }
                        else if (ctrl.GetAttribute("Align").ToLower() == "middle")
                        {
                            // Horizontally stretched, vertically centered
                            writer.SetControlProperty(
                                ctrl,
                                "Anchor",
                                "((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)))");
                        }
                        else
                        {
                            throw new Exception("Invalid value '" + ctrl.GetAttribute(
                                    "Align") + "' for Attribute 'Align' of Control '" + ctrl.controlName +
                                "' whose Attribute 'Stretch' is set to '" +
                                ctrl.GetAttribute("Stretch") +
                                "'. Supported values are: top, middle, bottom.");
                        }
                    }
                }
                else if (ctrl.GetAttribute("Stretch").ToLower() == "vertically")
                {
                    if ((!ctrl.HasAttribute("Align"))
                        || (ctrl.HasAttribute("Align") && (ctrl.GetAttribute("Align").ToLower() == "left")))
                    {
                        // Vertically stretched, left aligned (=default)
                        writer.SetControlProperty(
                            ctrl,
                            "Anchor",
                            "((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Bottom)))");
                    }
                    else
                    {
                        if (ctrl.GetAttribute("Align").ToLower() == "right")
                        {
                            // Vertically stretched, right aligned
                            writer.SetControlProperty(
                                ctrl,
                                "Anchor",
                                "((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right) | System.Windows.Forms.AnchorStyles.Bottom)))");
                        }
                        else if (ctrl.GetAttribute("Align").ToLower() == "center")
                        {
                            // Vertically stretched, horizontally centered
                            writer.SetControlProperty(
                                ctrl,
                                "Anchor",
                                "((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)))");
                        }
                        else
                        {
                            throw new Exception("Invalid value '" + ctrl.GetAttribute(
                                    "Align") + "' for Attribute 'Align' of Control '" + ctrl.controlName +
                                "' whose Attribute 'Stretch' is set to  '" +
                                ctrl.GetAttribute("Stretch") +
                                "'. Supported values are: left, center, right.");
                        }
                    }
                }
                else if (ctrl.GetAttribute("Stretch").ToLower() == "fully")
                {
                    // Fully stretched
                    writer.SetControlProperty(
                        ctrl,
                        "Anchor",
                        "((System.Windows.Forms.AnchorStyles)(((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right) | System.Windows.Forms.AnchorStyles.Bottom))))");

                    if (ctrl.HasAttribute("Align"))
                    {
                        Console.WriteLine(
                            "WARNING for Control '" + ctrl.controlName +
                            "': Attribute 'Align' gets ignored when Attribute 'Stretch' with value 'fully' is used.");
                    }
                }
                else if (ctrl.GetAttribute("Stretch").ToLower() == "none")
                {
                    // do nothing (here just to avoid throwing the following Exception)
                    Console.WriteLine(
                        "HINT: Attribute 'Stretch' with value 'none' does not affect the layout since this is the default. Control: '" +
                        ctrl.controlName + "'.");
                }
                else
                {
                    throw new Exception("Invalid value for Attribute 'Stretch' of Control '" + ctrl.controlName + "': '" +
                        ctrl.GetAttribute("Stretch") + "'. Supported values are: horizontally, vertically, fully, none.");
                }
            }

            #endregion

            if (ctrl.HasAttribute("Dock"))
            {
                writer.SetControlProperty(ctrl, "Dock");
            }

            if (ctrl.HasAttribute("Visible")
                && (ctrl.GetAttribute("Visible").ToLower() == "false"))
            {
                writer.SetControlProperty(ctrl, "Visible", "false");
            }

            if (ctrl.HasAttribute("Enabled")
                && (ctrl.GetAttribute("Enabled").ToLower() == "false"))
            {
                writer.SetControlProperty(ctrl, "Enabled", "false");
            }
            else if ((ctrl.GetAction() != null) && (TYml2Xml.GetAttribute(ctrl.GetAction().actionNode, "InitiallyEnabled").ToLower() == "false"))
            {
                string ActionEnabling = ctrl.controlName + ".Enabled = false;" + Environment.NewLine;
                writer.Template.AddToCodelet("INITACTIONSTATE", ActionEnabling);
            }

            if (ctrl.HasAttribute("TabStop")
                && (ctrl.GetAttribute("TabStop").ToLower() == "false"))
            {
                writer.SetControlProperty(ctrl, "TabStop", "false");
            }

            if (ctrl.HasAttribute("TabIndex"))
            {
                writer.SetControlProperty(ctrl, "TabIndex", ctrl.GetAttribute("TabIndex"));
            }

            if (ctrl.HasAttribute("BorderStyle"))
            {
                writer.SetControlProperty(ctrl, "BorderStyle", "System.Windows.Forms.BorderStyle." + ctrl.GetAttribute("BorderStyle"));

                if (ctrl.GetAttribute("BorderStyle").ToLower() == "none")
                {
                    writer.SetControlProperty(ctrl, "Margin", "new System.Windows.Forms.Padding(0, 5, 0, 0)");
                }
            }

            if (ctrl.HasAttribute("Padding"))
            {
                writer.SetControlProperty(ctrl, "Padding", "new System.Windows.Forms.Padding(" + ctrl.GetAttribute("Padding") + ")");
            }

            if (ctrl.HasAttribute("Margin"))
            {
                string margin = ctrl.GetAttribute("Margin");

                if (margin != "0")
                {
                    writer.SetControlProperty(ctrl, "Margin", "new System.Windows.Forms.Padding(" + margin + ")");
                }
            }

            if (ctrl.HasAttribute("BackColor"))
            {
                writer.SetControlProperty(ctrl, "BackColor", ctrl.GetAttribute("BackColor"));
            }

            if (ctrl.HasAttribute("AutoScroll"))
            {
                writer.SetControlProperty(ctrl, "AutoScroll", ctrl.GetAttribute("AutoScroll"));
            }

            // needed so that ctrl.Height and ctrl.Width return correct values
            ctrl.SetAttribute("DefaultWidth", FDefaultWidth.ToString());
            ctrl.SetAttribute("DefaultHeight", FDefaultHeight.ToString());

            if (ctrl.HasAttribute("Width") || ctrl.HasAttribute("Height"))
            {
                if (!ctrl.HasAttribute("Width"))
                {
                    ctrl.SetAttribute("Width", FDefaultWidth.ToString());
                }

                if (!ctrl.HasAttribute("Height"))
                {
                    ctrl.SetAttribute("Height", FDefaultHeight.ToString());
                }

                if (ctrl.HasAttribute("Width") && ctrl.HasAttribute("Height"))
                {
                    writer.SetControlProperty(ctrl, "Size", "new System.Drawing.Size(" +
                        ctrl.GetAttribute("Width").ToString() + ", " + ctrl.GetAttribute("Height").ToString() + ")");
                }
            }
            else if (ctrl.GetAttribute("Dock").ToLower() == "fill")
            {
                // no size information for Dock Fill
            }
            else
            {
                writer.SetControlProperty(ctrl, "Size",
                    "new System.Drawing.Size(" + FDefaultWidth.ToString() + ", " + FDefaultHeight.ToString() + ")");
            }

            if (ctrl.HasAttribute("SuppressChangeDetection") && (ctrl.GetAttribute("SuppressChangeDetection").ToLower() == "true"))
            {
                writer.SetControlProperty(ctrl, "Tag", "\"SuppressChangeDetection\"");
            }

            if (ctrl.GetAction() != null)
            {
                string ActionToPerform = ctrl.GetAction().actionName;

                // deal with enabling and disabling of action, affecting the menu item
                if (!writer.Template.FCodelets.Keys.Contains("ENABLEDEPENDINGACTIONS_" + ActionToPerform))
                {
                    string ActionEnabling = "";
                    ActionEnabling += "if (e.ActionName == \"" + ActionToPerform + "\")" + Environment.NewLine;
                    ActionEnabling += "{" + Environment.NewLine;
                    ActionEnabling += "    {#ENABLEDEPENDINGACTIONS_" + ActionToPerform + "}" + Environment.NewLine;
                    ActionEnabling += "}" + Environment.NewLine;
                    writer.Template.AddToCodelet("ACTIONENABLING", ActionEnabling);
                }

                AddToActionEnabledEvent(writer, ActionToPerform, ctrl.controlName);

                // deal with action handler
                if (((ActionToPerform == "actEditFilter") || (ActionToPerform == "actEditFindNext") || (ActionToPerform == "actEditFindPrevious")
                     || (ActionToPerform == "actEditFind")) && !writer.FCodeStorage.FControlList.ContainsKey("pnlFilterAndFind"))
                {
                    // Do nothing unless there is a manual code handler (on screens with user controls)
                    if (writer.FCodeStorage.ManualFileExistsAndContains("void MniFilterFind_Click("))
                    {
                        AssignEventHandlerToControl(writer, ctrl, "Click", "MniFilterFind_Click");
                    }
                    else if (ActionToPerform == "actEditFind")
                    {
                        TLogging.Log("No implementation of actEditFind on this screen");
                    }
                }
                else
                {
                    AssignEventHandlerToControl(writer, ctrl, "Click", ActionToPerform);
                }

                TActionHandler ActionHandler = writer.CodeStorage.FActionList[ActionToPerform];
                SetControlActionProperties(writer, ctrl, ActionHandler);

                string strMniFilterFindClick = "void MniFilterFind_Click(";

                if ((ActionToPerform == "actEditFind") && (ctrl.controlName == "mniEditFind")
                    && (writer.FCodeStorage.FControlList.ContainsKey("pnlFilterAndFind")
                        || writer.FCodeStorage.ManualFileExistsAndContains(strMniFilterFindClick)))
                {
                    writer.SetControlProperty("mniEditFind", "ShortcutKeys", "Keys.F | Keys.Control", false);
                }

                if ((ActionToPerform == "actEditFindNext") && (ctrl.controlName == "mniEditFindNext")
                    && (writer.FCodeStorage.FControlList.ContainsKey("pnlFilterAndFind")
                        || writer.FCodeStorage.ManualFileExistsAndContains(strMniFilterFindClick)))
                {
                    writer.SetControlProperty("mniEditFindNext", "ShortcutKeys", "Keys.F3", false);
                }

                if ((ActionToPerform == "actEditFindPrevious") && (ctrl.controlName == "mniEditFindPrevious")
                    && (writer.FCodeStorage.FControlList.ContainsKey("pnlFilterAndFind")
                        || writer.FCodeStorage.ManualFileExistsAndContains(strMniFilterFindClick)))
                {
                    writer.SetControlProperty("mniEditFindPrevious", "ShortcutKeys", "Keys.F3 | Keys.Shift", false);
                }

                if ((ActionToPerform == "actEditTop") && (ctrl.controlName == "mniEditTop"))
                {
                    writer.SetControlProperty("mniEditTop", "ShortcutKeys", "Keys.Home | Keys.Control", false);
                }

                if ((ActionToPerform == "actEditPrevious") && (ctrl.controlName == "mniEditPrevious"))
                {
                    writer.SetControlProperty("mniEditPrevious", "ShortcutKeys", "Keys.Up | Keys.Control", false);
                }

                if ((ActionToPerform == "actEditNext") && (ctrl.controlName == "mniEditNext"))
                {
                    writer.SetControlProperty("mniEditNext", "ShortcutKeys", "Keys.Down | Keys.Control", false);
                }

                if ((ActionToPerform == "actEditBottom") && (ctrl.controlName == "mniEditBottom"))
                {
                    writer.SetControlProperty("mniEditBottom", "ShortcutKeys", "Keys.End | Keys.Control", false);
                }

                if ((ActionToPerform == "actEditFocusGrid") && (ctrl.controlName == "mniEditFocusGrid"))
                {
                    writer.SetControlProperty("mniEditFocusGrid", "ShortcutKeys", "Keys.G | Keys.Control", false);
                }

                if ((ActionToPerform == "actEditFilter") && (ctrl.controlName == "mniEditFilter")
                    && (writer.FCodeStorage.FControlList.ContainsKey("pnlFilterAndFind")
                        || writer.FCodeStorage.ManualFileExistsAndContains(strMniFilterFindClick)))
                {
                    writer.SetControlProperty("mniEditFilter", "ShortcutKeys", "Keys.R | Keys.Control", false);
                }

                if ((ActionToPerform == "actSave") && (ctrl.controlName == "mniFileSave"))
                {
                    ProcessTemplate snipCtrlS = writer.FTemplate.GetSnippet("PROCESSCMDKEYCTRLS");
                    writer.FTemplate.InsertSnippet("PROCESSCMDKEY", snipCtrlS);
                    writer.SetControlProperty("mniFileSave", "ShortcutKeys", "Keys.S | Keys.Control", false);
                }

                if ((ActionToPerform == "actPrint") && (ctrl.controlName == "mniFilePrint"))
                {
                    writer.SetControlProperty("mniFilePrint", "ShortcutKeys", "Keys.P | Keys.Control", false);
                }

                if (FCodeStorage.ManualFileExistsAndContains(" " + ActionHandler.actionName.Substring(3) + "(Form AParentForm)"))
                {
                    writer.SetEventHandlerFunction(ActionHandler.actionName.Substring(3), "", ActionHandler.actionName.Substring(
                            3) + "(this);");
                }
            }
            else if (ctrl.HasAttribute("ActionClick"))
            {
                if (ctrl.GetAttribute("ActionClick").EndsWith("FilterFind_Click"))
                {
                    // MniFilterFind_Click is part of the base template for many forms.
                    // We only create an action handler if the screen has a pnlFilterAndFind
                    if (writer.FCodeStorage.FControlList.ContainsKey("pnlFilterAndFind"))
                    {
                        AssignEventHandlerToControl(writer, ctrl, "Click", ctrl.GetAttribute("ActionClick"));
                    }
                }
                else
                {
                    // The control is not mniEditFilter or mniEditFind, so just write the resource file item
                    // The manual code file will have the event handler itself
                    AssignEventHandlerToControl(writer, ctrl, "Click", ctrl.GetAttribute("ActionClick"));
                }
            }
            else if (ctrl.HasAttribute("ActionDoubleClick"))
            {
                AssignEventHandlerToControl(writer, ctrl, "DoubleClick", ctrl.GetAttribute("ActionDoubleClick"));
            }
            else if (ctrl.HasAttribute("ActionOpenScreen"))
            {
                AssignEventHandlerToControl(writer, ctrl, "Click", "OpenScreen" + ctrl.controlName.Substring(ctrl.controlTypePrefix.Length));
                string ActionHandler =
                    "/// auto generated" + Environment.NewLine +
                    "protected void OpenScreen" + ctrl.controlName.Substring(ctrl.controlTypePrefix.Length) + "(object sender, EventArgs e)" +
                    Environment.NewLine +
                    "{" + Environment.NewLine;

                string ActionOpenScreen = ctrl.GetAttribute("ActionOpenScreen");
                ActionHandler += "    " + ActionOpenScreen + " frm = new " + ActionOpenScreen +
                                 "(this);" + Environment.NewLine;

                if (ActionOpenScreen.Contains("."))
                {
                    string namespaceOfScreen = ActionOpenScreen.Substring(0, ActionOpenScreen.LastIndexOf("."));
                    writer.Template.AddToCodelet("USINGNAMESPACES", "using " + namespaceOfScreen + ";" + Environment.NewLine, false);
                }

                // Does PropertyForSubScreens fit a property in the new screen? eg LedgerNumber
                if (FCodeStorage.HasAttribute("PropertyForSubScreens"))
                {
                    string propertyName = FCodeStorage.GetAttribute("PropertyForSubScreens");

                    if (FCodeStorage.ImplementationContains(ctrl.GetAttribute("ActionOpenScreen"), " " + propertyName + Environment.NewLine))
                    {
                        ActionHandler += "    frm." + propertyName + " = F" + propertyName + ";" + Environment.NewLine;
                    }
                }

                /*                for (string propertyName in FCodeStorage.GetFittingProperties(ctrl.GetAttribute("ActionOpenScreen")))
                 *              {
                 *                  ActionHandler += "    frm." + propertyName + " = F" + propertyName + ";" + Environment.NewLine;
                 *              }
                 */
                ActionHandler += "    frm.Show();" + Environment.NewLine;
                ActionHandler += "}" + Environment.NewLine + Environment.NewLine;

                FCodeStorage.FActionHandlers += ActionHandler;
            }

            if (ctrl.HasAttribute("Enabled"))
            {
                AddToActionEnabledEvent(writer, ctrl.GetAttribute("Enabled"), ctrl.controlName);
            }

            if (ctrl.HasAttribute("OnChange"))
            {
                AssignEventHandlerToControl(writer, ctrl,
                    GetEventNameForChangeEvent(),
                    GetEventHandlerTypeForChangeEvent(),
                    ctrl.GetAttribute("OnChange"));
            }

            if (ctrl.HasAttribute("OnEnter"))
            {
                AssignEventHandlerToControl(writer, ctrl,
                    "Enter",
                    "System.EventHandler",
                    ctrl.GetAttribute("OnEnter"));
            }

            if (ctrl.HasAttribute("OnLeave"))
            {
                AssignEventHandlerToControl(writer, ctrl,
                    "Leave",
                    "System.EventHandler",
                    ctrl.GetAttribute("OnLeave"));
            }

            if (ctrl.HasAttribute("Tooltip"))
            {
                writer.Template.AddToCodelet("INITUSERCONTROLS", "FPetraUtilsObject.SetStatusBarText(" + ctrl.controlName +
                    ", Catalog.GetString(\"" +
                    ctrl.GetAttribute("Tooltip") +
                    "\"));" + Environment.NewLine);
            }
            else if (ctrl.controlName == "grdDetails")
            {
                writer.Template.AddToCodelet("INITUSERCONTROLS", "FPetraUtilsObject.SetStatusBarText(" + ctrl.controlName +
                    ", Catalog.GetString(\"Use the mouse or navigation keys to select a data row to view or edit\"));" + Environment.NewLine);
            }
            else if (ctrl.controlName == "btnNew")
            {
                writer.Template.AddToCodelet("INITUSERCONTROLS", "FPetraUtilsObject.SetStatusBarText(" + ctrl.controlName +
                    ", Catalog.GetString(\"Click to create a new record\"));" + Environment.NewLine);
            }
            else if (ctrl.controlName == "btnDelete")
            {
                writer.Template.AddToCodelet("INITUSERCONTROLS", "FPetraUtilsObject.SetStatusBarText(" + ctrl.controlName +
                    ", Catalog.GetString(\"Click to delete the highlighted record(s)\"));" + Environment.NewLine);
            }
            else if (ctrl.controlName.StartsWith("spt"))
            {
                writer.Template.AddToCodelet(
                    "INITUSERCONTROLS",
                    "FPetraUtilsObject.SetStatusBarText(" + ctrl.controlName +
                    ", Catalog.GetString(\"Use the arrow keys to change the Splitter position and change the relative proportions of the panels\"));"
                    +
                    Environment.NewLine);
            }

            //TODO: CT
//            if (ctrl.HasAttribute("DefaultValue"))
//            {
//                writer.Template.AddToCodelet("DEFAULTOVERRIDE", UndoValue(ctrl, ;
//            }

//Console.WriteLine("ctrl.controlTypePrefix: " + ctrl.controlName + ": " + ctrl.controlTypePrefix);
            if (ctrl.HasAttribute("PartnerShortNameLookup"))
            {
                LinkControlPartnerShortNameLookup(writer, ctrl);
            }
            else if (ctrl.HasAttribute("DataField"))
            {
                string dataField = ctrl.GetAttribute("DataField");

                TTableField field = TDataBinding.GetTableField(ctrl, dataField, out IsDetailNotMaster, true);

                LinkControlDataField(writer, ctrl, field, IsDetailNotMaster);
                DataFieldUndoCapability(writer, ctrl, field, IsDetailNotMaster);
            }
            else if (writer.CodeStorage.HasAttribute("MasterTable") || writer.CodeStorage.HasAttribute("DetailTable"))
            {
                //if (ctrl.controlTypePrefix != "lbl" && ctrl.controlTypePrefix != "pnl" && ctrl.controlTypePrefix != "grp" &&
                if (!((this is LabelGenerator) || (this is LinkLabelGenerator)))
                {
                    TTableField field = TDataBinding.GetTableField(ctrl, ctrl.controlName.Substring(
                            ctrl.controlTypePrefix.Length), out IsDetailNotMaster, false);

                    if (field != null)
                    {
                        LinkControlDataField(writer, ctrl, field, IsDetailNotMaster);
                        DataFieldUndoCapability(writer, ctrl, field, IsDetailNotMaster);
                    }
                }
            }
            else if (ctrl.controlTypePrefix == "uco")
            {
                AddChildUserControlExtraCalls(writer, ctrl);
            }
            else if (ctrl.HasAttribute("DynamicControlType"))
            {
                writer.Template.AddToCodelet("SAVEDATA", "if(FUco" + ctrl.controlName.Substring(
                        3) + " != null)" + Environment.NewLine + "{" + Environment.NewLine +
                    "    FUco" + ctrl.controlName.Substring(3) + ".GetDataFromControls();" + Environment.NewLine + "}" + Environment.NewLine);
                writer.Template.AddToCodelet("PRIMARYKEYCONTROLSREADONLY", "if(FUco" + ctrl.controlName.Substring(
                        3) + " != null)" + Environment.NewLine + "{" + Environment.NewLine +
                    "    FUco" + ctrl.controlName.Substring(
                        3) + ".SetPrimaryKeyReadOnly(AReadOnly);" + Environment.NewLine + "}" + Environment.NewLine);
            }

            // Allow for adding of child-usercontrol extra calls *even* if the Template has got 'MasterTable' or 'DetailTable' attribute(s) [see above for those checks]
            if ((ctrl.controlTypePrefix == "uco")
                && (writer.CodeStorage.GetAttribute("DependentChildUserControl") == "true"))
            {
                AddChildUserControlExtraCalls(writer, ctrl);
            }

            // the readonly property eg of Textbox still allows tooltips and copy to clipboard, which enable=false would not allow
            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "ReadOnly")
                && (TYml2Xml.GetAttribute(ctrl.xmlNode, "ReadOnly").ToLower() == "true"))
            {
                if (FHasReadOnlyProperty)
                {
                    writer.SetControlProperty(ctrl,
                        "ReadOnly",
                        "true");
                    writer.SetControlProperty(ctrl,
                        "TabStop",
                        "false");
                }
                else
                {
                    writer.SetControlProperty(ctrl,
                        "Enabled",
                        "false");
                }
            }

            if (GenerateDataValidationCode(writer, ctrl, out AutomDataValidation, out ReasonForAutomValidation))
            {
                AssignEventHandlerToControl(writer, ctrl, "Validated", "ControlValidatedHandler");
            }
            else
            {
                bool AssignControlUpdateDataHandler = false;

                if (ctrl.HasAttribute("DataField"))
                {
                    TDataBinding.GetTableField(ctrl, ctrl.GetAttribute("DataField"), out IsDetailNotMaster, true);

                    if (IsDetailNotMaster)
                    {
                        AssignControlUpdateDataHandler = true;
                    }
                }
                else
                {
                    if (writer.CodeStorage.HasAttribute("DetailTable"))
                    {
                        if (!((this is LabelGenerator) || (this is LinkLabelGenerator)))
                        {
                            if (TDataBinding.GetTableField(ctrl, ctrl.controlName.Substring(
                                        ctrl.controlTypePrefix.Length), out IsDetailNotMaster, false) != null)
                            {
                                if (IsDetailNotMaster)
                                {
                                    AssignControlUpdateDataHandler = true;
                                }
                            }
                        }
                    }
                }

                if (AssignControlUpdateDataHandler)
                {
                    if ((!ctrl.controlTypePrefix.StartsWith("mn"))
                        && (!ctrl.controlTypePrefix.StartsWith("tb"))
                        && (ctrl.controlTypePrefix != "pnl")
                        && (ctrl.controlTypePrefix != "grp")
                        && (ctrl.controlTypePrefix != "grd")
                        && (ctrl.controlTypePrefix != "btn")
                        && (ctrl.controlTypePrefix != "stb")
                        && (ctrl.controlTypePrefix != "lbl"))
                    {
                        AssignEventHandlerToControl(writer, ctrl, "Validated", "ControlUpdateDataHandler");
                        writer.Template.SetCodelet("GENERATECONTROLUPDATEDATAHANDLER", "true");
                    }
                }
            }

            return writer.Template;
        }
예제 #41
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)
        {
            if (!ctrl.HasAttribute("Width"))
            {
                ctrl.SetAttribute("Width", FDefaultWidth.ToString());
            }

            base.SetControlProperties(writer, ctrl);

            writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".CancelEditingWithEscapeKey = false;" + Environment.NewLine);

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "SelectedRowActivates"))
            {
                // TODO: this function needs to be called by the manual code at the moment when eg a search finishes
                // TODO: call "Activate" + TYml2Xml.GetAttribute(ctrl.xmlNode, "SelectedRowActivates")
            }

            StringCollection Columns = TYml2Xml.GetElements(ctrl.xmlNode, "Columns");

            if (Columns.Count > 0)
            {
                writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".Columns.Clear();" + Environment.NewLine);

                //This needs to come immediately after the Columns.Clear() and before the creation of the columns
                if (ctrl.HasAttribute("SortableHeaders"))
                {
                    string trueOrFalse = ctrl.GetAttribute("SortableHeaders");
                    writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".SortableHeaders = " + trueOrFalse + ";" + Environment.NewLine);
                }

                bool isFirstColumnVarchar = false;
                bool doneFirstColumn      = false;

                foreach (string ColumnFieldName in Columns)
                {
                    bool        IsDetailNotMaster;
                    TTableField field = null;
                    string      TableFieldTable;
                    string      ColumnFieldNameResolved;

                    // customfield, eg. UC_GLTransactions, ATransaction.DateEntered and ATransaction.AnalysisAttributes
                    // there needs to be a list of CustomColumns
                    XmlNode CustomColumnsNode = TYml2Xml.GetChild(ctrl.xmlNode, "CustomColumns");
                    XmlNode CustomColumnNode  = null;

                    if (CustomColumnsNode != null)
                    {
                        CustomColumnNode = TYml2Xml.GetChild(CustomColumnsNode, ColumnFieldName);
                    }

                    if ((ctrl.controlName == "grdDetails") && FCodeStorage.HasAttribute("DetailTable"))
                    {
                        TableFieldTable = FCodeStorage.GetAttribute("DetailTable");

                        if (ColumnFieldName.StartsWith("Detail") && !IsLegitimateDetailFieldName(TableFieldTable, ColumnFieldName))
                        {
                            ColumnFieldNameResolved = ColumnFieldName.Substring(6);     // Drop 'Details' out of 'Details...'
                        }
                        else
                        {
                            ColumnFieldNameResolved = ColumnFieldName;
                        }
                    }
                    else
                    {
                        TableFieldTable         = ctrl.GetAttribute("TableName");
                        ColumnFieldNameResolved = ColumnFieldName;
                    }

                    if (CustomColumnNode != null)
                    {
                        TTableField tf = null;

                        // if grd has no TableName property
                        if ((TableFieldTable == "") && ColumnFieldNameResolved.Contains("."))
                        {
                            int    Period     = ColumnFieldNameResolved.IndexOf(".");
                            string TableName  = ColumnFieldNameResolved.Remove(Period);
                            string ColumnName = ColumnFieldNameResolved.Remove(0, TableName.Length + 1);

                            AddColumnToGrid(writer, ctrl.controlName,
                                            TYml2Xml.GetAttribute(CustomColumnNode, "Type"),
                                            TYml2Xml.GetAttribute(CustomColumnNode, "Label"),
                                            TYml2Xml.GetAttribute(CustomColumnNode, "Tooltip"),
                                            TableName,
                                            ColumnName);
                            tf = TDataBinding.GetTableField(null, TableName + "." + ColumnName, out IsDetailNotMaster, true);
                        }
                        else
                        {
                            AddColumnToGrid(writer, ctrl.controlName,
                                            TYml2Xml.GetAttribute(CustomColumnNode, "Type"),
                                            TYml2Xml.GetAttribute(CustomColumnNode, "Label"),
                                            TYml2Xml.GetAttribute(CustomColumnNode, "Tooltip"),
                                            TableFieldTable,
                                            ColumnFieldNameResolved);
                            tf = TDataBinding.GetTableField(null, TableFieldTable + "." + ColumnFieldNameResolved, out IsDetailNotMaster, true);
                        }

                        if (!doneFirstColumn)
                        {
                            isFirstColumnVarchar = tf.strName.EndsWith("_c");
                            doneFirstColumn      = true;
                        }
                    }
                    else if (ctrl.HasAttribute("TableName"))
                    {
                        field = TDataBinding.GetTableField(null, ctrl.GetAttribute("TableName") + "." + ColumnFieldName,
                                                           out IsDetailNotMaster, true);
                    }
                    else
                    {
                        field = TDataBinding.GetTableField(null, ColumnFieldName, out IsDetailNotMaster, true);
                    }

                    if (field != null)
                    {
                        AddColumnToGrid(writer, ctrl.controlName,
                                        field.iDecimals == 10 && field.iLength == 24 ? "Decimal" : field.GetDotNetType(),
                                        field.strLabel.Length > 0 ? field.strLabel : field.strName,
                                        String.Empty,
                                        TTable.NiceTableName(field.strTableName),
                                        TTable.NiceFieldName(field.strName));

                        if (!doneFirstColumn)
                        {
                            isFirstColumnVarchar = field.strName.EndsWith("_c");
                            doneFirstColumn      = true;
                        }
                    }
                }

                if (FControlType == TYPE_DATA_GRID_NON_PAGED)
                {
                    // Grid AutoFind definition (not allowed in paged grids)
                    string autoFindStr = ctrl.controlName + ".AutoFindMode = TAutoFindModeEnum.";
                    string mode        = "NoAutoFind";

                    if (ctrl.HasAttribute("AutoFindMode"))
                    {
                        // Use the specified value in YAML
                        mode = ctrl.GetAttribute("AutoFindMode");
                        TLogging.Log("Info: AutoFindMode (with columns) was set to " + mode + " from explicit YAML attribute: " + ctrl.controlName);
                    }
                    else if (isFirstColumnVarchar)
                    {
                        // We can use auto-find because we have a first column based on a varchar
                        mode = "FirstCharacter";
                        TLogging.Log("Info: AutoFindMode (with columns) was set implicitly for: " + ctrl.controlName);
                    }
                    else
                    {
                        TLogging.Log("Info: AutoFindMode (with columns) was set to NoAutoFind for: " + ctrl.controlName);
                    }

                    writer.Template.AddToCodelet("INITMANUALCODE", autoFindStr + mode + ";" + Environment.NewLine);

                    if (ctrl.HasAttribute("AutoFindColumn"))
                    {
                        string colNum = ctrl.GetAttribute("AutoFindColumn");
                        writer.Template.AddToCodelet("INITMANUALCODE",
                                                     ctrl.controlName + ".AutoFindColumn = " + colNum + ";" + Environment.NewLine);
                        TLogging.Log("Info: AutoFindColumn was set to " + colNum + " for: " + ctrl.controlName);
                    }

                    if ((mode == "FirstCharacter") && !ctrl.HasAttribute("SortOrder"))
                    {
                        TLogging.Log("Info: AutoFind has been turned on for a grid with no YAML-defined sort order: (" + ctrl.controlName +
                                     "). You can remove this message by explicitly setting a SortOrder in the YAML file.");
                    }
                }
            }
            else
            {
                //If no columns, but the user is able to add columns dynamically during the running of the form, then need this here.
                if (ctrl.HasAttribute("SortableHeaders"))
                {
                    string trueOrFalse = ctrl.GetAttribute("SortableHeaders");
                    writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".SortableHeaders = " + trueOrFalse + ";" + Environment.NewLine);
                }

                if (FControlType == TYPE_DATA_GRID_NON_PAGED)
                {
                    // Grid AutoFind definition (not allowed in paged grids)
                    string autoFindStr = ctrl.controlName + ".AutoFindMode = TAutoFindModeEnum.";
                    string mode        = "FirstCharacter";

                    if (ctrl.HasAttribute("AutoFindMode"))
                    {
                        // Use the specified value in YAML
                        mode = ctrl.GetAttribute("AutoFindMode");
                        TLogging.Log("Info: AutoFindMode (without columns) was set to " + mode + " from explicit YAML attribute: " + ctrl.controlName);
                    }
                    else if (writer.FCodeStorage.ManualFileExistsAndContains(ctrl.controlName + ".AddTextColumn("))
                    {
                        // We presume can use auto-find because we have a column (maybe the first) based on a varchar
                        TLogging.Log("Info: AutoFindMode (without columns) was set implicitly for: " + ctrl.controlName);
                    }
                    else
                    {
                        mode = "NoAutoFind";
                        TLogging.Log("Info: AutoFindMode (without columns) was set to NoAutoFind for: " + ctrl.controlName);
                    }

                    writer.Template.AddToCodelet("INITMANUALCODE", autoFindStr + mode + ";" + Environment.NewLine);

                    if (ctrl.HasAttribute("AutoFindColumn"))
                    {
                        string colNum = ctrl.GetAttribute("AutoFindColumn");
                        writer.Template.AddToCodelet("INITMANUALCODE",
                                                     ctrl.controlName + ".AutoFindColumn = " + colNum + ";" + Environment.NewLine);
                        TLogging.Log("Info: AutoFindColumn was set to " + colNum + " for: " + ctrl.controlName);
                    }
                }
            }

            if (ctrl.controlName != "grdDetails")
            {
                if (ctrl.HasAttribute("ActionLeavingRow"))
                {
                    AssignEventHandlerToControl(writer, ctrl, "Selection.FocusRowLeaving", "SourceGrid.RowCancelEventHandler",
                                                ctrl.GetAttribute("ActionLeavingRow"));
                }

                if (ctrl.HasAttribute("ActionFocusRow"))
                {
                    AssignEventHandlerToControl(writer, ctrl, "Selection.FocusRowEntered", "SourceGrid.RowEventHandler",
                                                ctrl.GetAttribute("ActionFocusRow"));
                }
            }

            if (ctrl.HasAttribute("ActionEnterKeyPressed"))
            {
                AssignEventHandlerToControl(writer, ctrl, "EnterKeyPressed", "TKeyPressedEventHandler",
                                            ctrl.GetAttribute("ActionEnterKeyPressed"));
            }

            if ((ctrl.controlName == "grdDetails") && FCodeStorage.HasAttribute("DetailTable"))
            {
                writer.Template.AddToCodelet("SHOWDATA", "");

                if (ctrl.HasAttribute("SortOrder"))
                {
                    // SortOrder is comma separated and has DESC or ASC after the column name
                    string SortOrder = ctrl.GetAttribute("SortOrder");

                    foreach (string SortOrderPart in SortOrder.Split(','))
                    {
                        bool        temp;
                        TTableField field          = null;
                        string      columnNamePart = SortOrderPart.Split(' ')[0];

                        if ((columnNamePart.IndexOf(".") == -1) && ctrl.HasAttribute("TableName"))
                        {
                            field = TDataBinding.GetTableField(null, ctrl.GetAttribute("TableName") + "." + columnNamePart, out temp, true);
                        }
                        else
                        {
                            field = TDataBinding.GetTableField(null, columnNamePart, out temp, true);
                        }

                        if (field != null)
                        {
                            SortOrder = SortOrder.Replace(columnNamePart, field.strName);
                        }
                    }

                    writer.Template.AddToCodelet("GRIDSORT", SortOrder);
                }

                if (ctrl.HasAttribute("RowFilter"))
                {
                    // this references a field in the table, and assumes there exists a local variable with the same name
                    // eg. FBatchNumber in GL Journals
                    string RowFilter = ctrl.GetAttribute("RowFilter");

                    String FilterString = "\"";

                    foreach (string RowFilterPart in RowFilter.Split(','))
                    {
                        bool   temp;
                        string columnName =
                            TDataBinding.GetTableField(
                                null,
                                RowFilterPart,
                                out temp, true).strName;

                        if (FilterString.Length > 1)
                        {
                            FilterString += " + \" and ";
                        }

                        FilterString += columnName + " = \" + F" + TTable.NiceFieldName(columnName) + ".ToString()";
                    }

                    writer.Template.AddToCodelet("GRIDFILTER", FilterString);
                }
            }

            if (ctrl.controlName == "grdDetails")
            {
                if (ctrl.HasAttribute("EnableMultiSelection"))
                {
                    writer.Template.SetCodelet("GRIDMULTISELECTION",
                                               String.Format("grdDetails.Selection.EnableMultiSelection = {0};{1}", ctrl.GetAttribute("EnableMultiSelection"),
                                                             Environment.NewLine));
                }
                else if (FCodeStorage.FControlList.ContainsKey("btnDelete"))
                {
                    writer.Template.SetCodelet("GRIDMULTISELECTION",
                                               "grdDetails.Selection.EnableMultiSelection = true;" + Environment.NewLine);
                }
            }

            return(writer.FTemplate);
        }
        /// <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)
        {
            Int32 buttonWidth = 40;
            Int32 textBoxWidth = 80;

            // seems to be hardcoded in csharp\ICT\Petra\Client\CommonControls\Gui\txtAutoPopulatedButtonLabel.Designer.cs
            Int32 controlWidth = 390;

            base.SetControlProperties(writer, ctrl);

            if ((ctrl.HasAttribute("ShowLabel") && (ctrl.GetAttribute("ShowLabel").ToLower() == "false")))
            {
                writer.SetControlProperty(ctrl, "ShowLabel", "false");
                controlWidth = 120;
            }

            // Note: the control defaults to 'ShowLabel' true, so this doesn't need to be set to 'true' in code.

            writer.SetControlProperty(ctrl, "ASpecialSetting", "true");
            writer.SetControlProperty(ctrl, "ButtonTextAlign", "System.Drawing.ContentAlignment.MiddleCenter");
            writer.SetControlProperty(ctrl, "ListTable", "TtxtAutoPopulatedButtonLabel.TListTableEnum." +
                FButtonLabelType);
            writer.SetControlProperty(ctrl, "PartnerClass", "\"" + ctrl.GetAttribute("PartnerClass") + "\"");
            writer.SetControlProperty(ctrl, "MaxLength", "32767");
            writer.SetControlProperty(ctrl, "Tag", "\"CustomDisableAlthoughInvisible\"");
            writer.SetControlProperty(ctrl, "TextBoxWidth", textBoxWidth.ToString());

            if (!(ctrl.HasAttribute("ReadOnly") && (ctrl.GetAttribute("ReadOnly").ToLower() == "true")))
            {
                writer.SetControlProperty(ctrl, "ButtonWidth", buttonWidth.ToString());
                writer.SetControlProperty(ctrl, "ReadOnly", "false");
                writer.SetControlProperty(ctrl,
                    "Font",
                    "new System.Drawing.Font(\"Verdana\", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (byte)0)");
                writer.SetControlProperty(ctrl, "ButtonText", "\"Find\"");
            }
            else
            {
                writer.SetControlProperty(ctrl, "ButtonWidth", "0");
                writer.SetControlProperty(ctrl, "BorderStyle", "System.Windows.Forms.BorderStyle.None");
                writer.SetControlProperty(ctrl, "Padding", "new System.Windows.Forms.Padding(0, 4, 0, 0)");
            }

            if (!ctrl.HasAttribute("Width"))
            {
                ctrl.SetAttribute("Width", controlWidth.ToString());
            }

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "DefaultValue"))
            {
                writer.SetControlProperty(ctrl,
                    "Text",
                    "\"" + TYml2Xml.GetAttribute(ctrl.xmlNode, "DefaultValue") + "\"");
            }

            return writer.FTemplate;
        }
예제 #43
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;
            }
        }
        /// <summary>
        /// how to get the value from the control
        /// </summary>
        protected override string GetControlValue(TControlDef ctrl, string AFieldTypeDotNet)
        {
            if (AFieldTypeDotNet == null)
            {
                return ctrl.controlName + ".Text.Length == 0";
            }

            if (ctrl.GetAttribute("Type") == "ShortTime")
            {
                return "(int)new Ict.Common.TypeConverter.TShortTimeConverter().ConvertTo(" + ctrl.controlName + ".Text, typeof(int))";
            }
            else if (ctrl.GetAttribute("Type") == "LongTime")
            {
                return "(int)new Ict.Common.TypeConverter.TLongTimeConverter().ConvertTo(" + ctrl.controlName + ".Text, typeof(int))";
            }
            else if (AFieldTypeDotNet.ToLower().Contains("int64"))
            {
                return "Convert.ToInt64(" + ctrl.controlName + ".Text)";
            }
            else if (AFieldTypeDotNet.ToLower().Contains("int"))
            {
                return "Convert.ToInt32(" + ctrl.controlName + ".Text)";
            }
            else if (AFieldTypeDotNet.ToLower().Contains("decimal"))
            {
                return "Convert.ToDecimal(" + ctrl.controlName + ".Text)";
            }

            return ctrl.controlName + ".Text";
        }
        /// <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)
        {
            string Width;

            base.SetControlProperties(writer, ctrl);

            if (ctrl.GetAttribute("Height").ToString() == "36")  // 36 is the Height of pnlButtons/pnlDetailButtons Panels that have ControlsOrientation=horizontal and whose Buttons have been shrinked in size to 23 Pixels by the ButtonGenerator - and
            {                                                    // whose 'Height' Element hasn't been set in the YAML file...
                if (ctrl.IsGridButtonPanel)
                {
                    Width = ctrl.GetAttribute("Width").ToString();

                    // Somehow we can run into a situation where Width isn't specified. This would lead to writing out an
                    // invalid Size Property. To prevent that we set it to some value which we can find easily in files and
                    // which will be ignored anyway at runtime as the Panel will be Docked with 'DockStyle.Bottom'!
                    if (Width.Length == 0)
                    {
                        Width = "1111";
                    }

                    FDefaultHeight = 28;

                    TLogging.LogAtLevel(1, "Adjusted Height of Panel '" + ctrl.controlName + "' as it is a horizontal Grid Button Panel");
                    writer.SetControlProperty(ctrl, "Size", "new System.Drawing.Size(" +
                        Width + ", " + FDefaultHeight.ToString() + ")");

                    writer.SetControlProperty(ctrl, "BackColor", "System.Drawing.Color.Green");
                }
            }

            return writer.FTemplate;
        }
        /// <summary>
        /// how to assign a value to the control
        /// </summary>
        protected override string AssignValue(TControlDef ctrl, string AFieldOrNull, string AFieldTypeDotNet)
        {
            if (AFieldOrNull == null)
            {
                return ctrl.controlName + ".Text = String.Empty;";
            }

            if (!AFieldTypeDotNet.ToLower().Contains("string"))
            {
                if (ctrl.GetAttribute("Type") == "PartnerKey")
                {
                    // for readonly text box
                    return ctrl.controlName + ".Text = String.Format(\"{0:0000000000}\", " + AFieldOrNull + ");";
                }
                else if (ctrl.GetAttribute("Type") == "ShortTime")
                {
                    // for seconds to short time
                    return ctrl.controlName + ".Text = new Ict.Common.TypeConverter.TShortTimeConverter().ConvertTo(" + AFieldOrNull +
                           ", typeof(string)).ToString();";
                }
                else if (ctrl.GetAttribute("Type") == "LongTime")
                {
                    // for seconds to long time
                    return ctrl.controlName + ".Text = new Ict.Common.TypeConverter.TLongTimeConverter().ConvertTo(" + AFieldOrNull +
                           ", typeof(string)).ToString();";
                }

                return ctrl.controlName + ".Text = " + AFieldOrNull + ".ToString();";
            }

            return ctrl.controlName + ".Text = " + AFieldOrNull + ";";
        }
        /// <summary>
        /// add the children
        /// </summary>
        public override void AddChildren(TFormWriter writer, TControlDef ctrl)
        {
            if (ctrl.GetAttribute("UseTableLayout") != "true")
            {
                // first add the control that has Dock=Fill, then the others
                foreach (TControlDef ChildControl in ctrl.Children)
                {
                    if (ChildControl.GetAttribute("Dock") == "Fill")
                    {
                        writer.CallControlFunction(ctrl.controlName,
                            "Controls.Add(this." +
                            ChildControl.controlName + ")");
                    }
                }

                List <TControlDef>ControlsReverse = new List <TControlDef>();

                foreach (TControlDef ChildControl in ctrl.Children)
                {
                    ControlsReverse.Insert(0, ChildControl);
                }

                foreach (TControlDef ChildControl in ControlsReverse)
                {
                    if (ChildControl.GetAttribute("Dock") != "Fill")
                    {
                        writer.CallControlFunction(ctrl.controlName,
                            "Controls.Add(this." +
                            ChildControl.controlName + ")");
                    }
                }
            }
        }
        /// <summary>
        /// Handle 'special' Panels
        /// </summary>
        public override void ProcessChildren(TFormWriter writer, TControlDef ctrl)
        {
            SortedSet <int>ButtonWidths = new SortedSet <int>();
            SortedSet <int>ButtonTops = new SortedSet <int>();
            List <TControlDef>Buttons = new List <TControlDef>();

            int NewButtonWidthForAll = -1;

            if (ctrl.controlName == PNL_FILTER_AND_FIND)
            {
                listNumericColumns.Clear();

                writer.Template.SetCodelet("FILTERANDFIND", "true");

                writer.SetControlProperty(ctrl, "Dock", "Left");
                writer.SetControlProperty(ctrl, "BackColor", "System.Drawing.Color.LightSteelBlue");
                writer.SetControlProperty(ctrl, "Width", "0");

                if (!ctrl.HasAttribute("ExpandedWidth"))
                {
                    writer.Template.SetCodelet("FINDANDFILTERINITIALWIDTH", "150");
                }
                else
                {
                    writer.Template.SetCodelet("FINDANDFILTERINITIALWIDTH", ctrl.GetAttribute("ExpandedWidth"));
                }

                if ((ctrl.HasAttribute("InitiallyExpanded"))
                    && (ctrl.GetAttribute("InitiallyExpanded").ToLower() != "false"))
                {
                    writer.Template.SetCodelet("FINDANDFILTERINITIALLYEXPANDED", "true");
                }
                else
                {
                    writer.Template.SetCodelet("FINDANDFILTERINITIALLYEXPANDED", "false");
                }

                if (!ctrl.HasAttribute("ShowApplyFilterButton"))
                {
                    writer.Template.SetCodelet("FINDANDFILTERAPPLYFILTERBUTTONCONTEXT", "TUcoFilterAndFind.FilterContext.None");
                }
                else
                {
                    writer.Template.SetCodelet("FINDANDFILTERAPPLYFILTERBUTTONCONTEXT", "TUcoFilterAndFind." +
                        ctrl.GetAttribute("ShowApplyFilterButton"));
                }

                if (!ctrl.HasAttribute("ShowKeepFilterTurnedOnButton"))
                {
                    writer.Template.SetCodelet("FINDANDFILTERSHOWKEEPFILTERTURNEDONBUTTONCONTEXT", "TUcoFilterAndFind.FilterContext.None");
                }
                else
                {
                    writer.Template.SetCodelet("FINDANDFILTERSHOWKEEPFILTERTURNEDONBUTTONCONTEXT", "TUcoFilterAndFind." +
                        ctrl.GetAttribute("ShowKeepFilterTurnedOnButton"));
                }

                if (!ctrl.HasAttribute("ShowFilterIsAlwaysOnLabel"))
                {
                    writer.Template.SetCodelet("FINDANDFILTERSHOWFILTERISALWAYSONLABELCONTEXT", "TUcoFilterAndFind.FilterContext.None");
                }
                else
                {
                    writer.Template.SetCodelet("FINDANDFILTERSHOWFILTERISALWAYSONLABELCONTEXT", "TUcoFilterAndFind." +
                        ctrl.GetAttribute("ShowFilterIsAlwaysOnLabel"));
                }

                writer.Template.SetCodelet("CUSTOMDISPOSING",
                    "if (FFilterAndFindObject != null && FFilterAndFindObject.FilterFindPanel != null)" + Environment.NewLine +
                    "{" + Environment.NewLine +
                    "    FFilterAndFindObject.FilterFindPanel.Dispose();" + Environment.NewLine +
                    "}");

                XmlNodeList controlAttributesList = null;
                XmlNode ctrlNode = ctrl.xmlNode;

                foreach (XmlNode child in ctrlNode.ChildNodes)
                {
                    if (child.Name == "ControlAttributes")
                    {
                        controlAttributesList = child.ChildNodes;
                    }
                }

                ProcessTemplate snippetFilterAndFindDeclarations = writer.Template.GetSnippet("FILTERANDFINDDECLARATIONS");
                writer.Template.InsertSnippet("FILTERANDFINDDECLARATIONS", snippetFilterAndFindDeclarations);

                ProcessTemplate snippetFilterAndFindMethods = writer.Template.GetSnippet("FILTERANDFINDMETHODS");

                writer.Template.SetCodelet("INDIVIDUALFILTERPANELS", "");
                writer.Template.SetCodelet("INDIVIDUALEXTRAFILTERPANELS", "");
                writer.Template.SetCodelet("INDIVIDUALFINDPANELS", "");
                writer.Template.SetCodelet("INDIVIDUALFILTERFINDPANELEVENTS", "");
                writer.Template.SetCodelet("INDIVIDUALFILTERFINDPANELPROPERTIES", "");
                writer.Template.SetCodelet("NUMERICFILTERFINDCOLUMNS", "");
                writer.Template.SetCodelet("FILTERBUTTON", "");

                if (ctrl.HasAttribute("FilterButton"))
                {
                    // This specifies the button text (optional) and status bar text separated by semi-colon
                    // eg FilterButton=F&ilter;Click to Toggle the Analysis Values filter on and off
                    string attVal = ctrl.GetAttribute("FilterButton");
                    int pos = attVal.IndexOf(';');

                    if ((pos >= 0) && (pos < attVal.Length - 1))
                    {
                        string codelet = String.Empty;

                        if (pos > 0)
                        {
                            codelet = String.Format("chkToggleFilter.Text = \"{0}\";{1}", attVal.Substring(0, pos), Environment.NewLine);
                        }

                        codelet += String.Format("FPetraUtilsObject.SetStatusBarText(chkToggleFilter, \"{0}\");", attVal.Substring(pos + 1));
                        writer.Template.SetCodelet("FILTERBUTTON", codelet);
                    }
                }

                // Process each of the three Filter/Find definitions
                int TotalPanels = ProcessIndividualFilterFindPanel(writer,
                    "FilterControls",
                    "Filter",
                    "StandardFilter",
                    controlAttributesList,
                    "INDIVIDUALFILTERPANELS");
                TotalPanels += ProcessIndividualFilterFindPanel(writer,
                    "ExtraFilterControls",
                    "Filter",
                    "ExtraFilter",
                    controlAttributesList,
                    "INDIVIDUALEXTRAFILTERPANELS");
                TotalPanels += ProcessIndividualFilterFindPanel(writer, "FindControls", "Find", "Find", controlAttributesList, "INDIVIDUALFINDPANELS");

                if (TotalPanels == 0)
                {
                    throw new Exception("Found no controls for the Filter/Find panel");
                }

                // Manual code methods
                if (FCodeStorage.ManualFileExistsAndContains("void CreateFilterFindPanelsManual()"))
                {
                    writer.Template.SetCodelet("CREATEFILTERFINDPANELSMANUAL", "CreateFilterFindPanelsManual();" + Environment.NewLine);
                }
                else
                {
                    writer.Template.SetCodelet("CREATEFILTERFINDPANELSMANUAL", "");
                }

                if (FCodeStorage.ManualFileExistsAndContains("void FilterToggledManual(bool"))
                {
                    writer.Template.SetCodelet("FILTERTOGGLEDMANUAL", "FilterToggledManual(pnlFilterAndFind.Width == 0);" + Environment.NewLine);
                }
                else
                {
                    writer.Template.SetCodelet("FILTERTOGGLEDMANUAL", "");
                }

                if (FCodeStorage.ManualFileExistsAndContains("void ApplyFilterManual(ref"))
                {
                    writer.Template.SetCodelet("APPLYFILTERMANUAL", "ApplyFilterManual(ref AFilterString);" + Environment.NewLine);
                }
                else
                {
                    writer.Template.SetCodelet("APPLYFILTERMANUAL", "");
                }

                if (FCodeStorage.ManualFileExistsAndContains("bool IsMatchingRowManual("))
                {
                    writer.Template.SetCodelet("ISMATCHINGROW", "IsMatchingRowManual");
                }
                else
                {
                    writer.Template.SetCodelet("ISMATCHINGROW", "FFilterAndFindObject.FindPanelControls.IsMatchingRow");
                }

                // Write the whole thing out
                writer.Template.InsertSnippet("FILTERANDFINDMETHODS", snippetFilterAndFindMethods);
            }
            else
            {
                TControlDef subChildCtrl;

                TLogging.LogAtLevel(1, "PanelGenerator:Processing Children '" + ctrl.controlName + "' (about to call base method)");

                base.ProcessChildren(writer, ctrl);

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

                    if ((childCtrl.HasAttribute("AutoButtonMaxWidths"))
                        || (childCtrl.GetAttribute("AutoButtonMaxWidths") == "true"))
                    {
                        TLogging.LogAtLevel(1, "Control '" + childCtrl.controlName + "' has AutoButtonMaxWidths = true!");


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

                        if ((controlsNode != null) && TYml2Xml.GetChildren(controlsNode, true)[0].Name.StartsWith("Row"))
                        {
                            TLogging.LogAtLevel(1, "Row processing");

                            // this defines the layout with several rows with several controls per row
                            foreach (XmlNode row in TYml2Xml.GetChildren(controlsNode, true))
                            {
                                StringCollection controls = TYml2Xml.GetElements(row);

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

                                    TLogging.LogAtLevel(1, "Child: '" + subChildCtrl.controlName + "'");

                                    ProcessButtonsForMaxWidthDetermination(writer, subChildCtrl, ButtonWidths, ButtonTops, Buttons);
                                }

                                ProcessButtonsForMaxWidthSizing(writer, childCtrl, ButtonWidths, ButtonTops, Buttons, out NewButtonWidthForAll);
                            }
                        }
                        else
                        {
                            if ((controlsNode != null) && (childCtrl.Children.Count != 0))
                            {
                                TLogging.LogAtLevel(1, "Controls processing");

                                foreach (TControlDef subChildCtrl2 in childCtrl.Children)
                                {
                                    TLogging.LogAtLevel(1, "Child: '" + subChildCtrl2.controlName + "'");

                                    ProcessButtonsForMaxWidthDetermination(writer, subChildCtrl2, ButtonWidths, ButtonTops, Buttons);
                                }

                                ProcessButtonsForMaxWidthSizing(writer, childCtrl, ButtonWidths, ButtonTops, Buttons, out NewButtonWidthForAll);
                            }
                        }

                        if ((Buttons.Count > 0)
                            && ((childCtrl.HasAttribute("AutoButtonMaxWidthsAutoSizesContainerWidth"))
                                && ((childCtrl.GetAttribute("AutoButtonMaxWidthsAutoSizesContainerWidth").ToLower() == "true"))))
                        {
                            int NewContainerWidth = 5 + 7 + (Buttons.Count * NewButtonWidthForAll) + ((Buttons.Count - 1) * 5); // + ((Buttons.Count - 1) * 12) - (Buttons.Count * 2);
                            TLogging.LogAtLevel(1, "NewContainerWidth: " + NewContainerWidth.ToString());
                            writer.SetControlProperty(childCtrl, "Size", "new System.Drawing.Size(" +
                                NewContainerWidth.ToString() + ", " + childCtrl.GetAttribute("Height").ToString() + ")");
                        }

                        Buttons.Clear();
                        ButtonWidths.Clear();
                    }
                }
            }
        }
예제 #49
0
        private static void AdjustLabel(XmlNode node, TCodeStorage CodeStorage, XmlDocument AOrigLocalisedYaml)
        {
            XmlNode TranslatedNode = TXMLParser.FindNodeRecursive(AOrigLocalisedYaml, node.Name);
            string TranslatedLabel = string.Empty;

            if (TranslatedNode != null)
            {
                TranslatedLabel = TXMLParser.GetAttribute(TranslatedNode, "Label");
            }

            TControlDef ctrlDef = new TControlDef(node, CodeStorage);
            string Label = ctrlDef.Label;

            if ((ctrlDef.GetAttribute("NoLabel") == "true") || (ctrlDef.controlTypePrefix == "pnl")
                || (TXMLParser.FindNodeRecursive(node.OwnerDocument, "act" + ctrlDef.controlName.Substring(ctrlDef.controlTypePrefix.Length)) != null)
                || ctrlDef.GetAttribute("Action").StartsWith("act"))
            {
                Label = string.Empty;
            }

            if ((ctrlDef.controlTypePrefix == "rgr") && (TXMLParser.GetChild(node, "OptionalValues") != null))
            {
                ProcessRadioGroupLabels(node);
            }
            else if (ctrlDef.controlTypePrefix == "mni")
            {
                // drop all attributes
                node.Attributes.RemoveAll();

                foreach (XmlNode menu in node.ChildNodes)
                {
                    if (menu.Name.Contains("Separator"))
                    {
                        continue;
                    }

                    AdjustLabel(menu, CodeStorage, AOrigLocalisedYaml);
                }
            }
            else
            {
                // drop all attributes and children nodes
                node.RemoveAll();
            }

            if (Label.Length > 0)
            {
                if ((TranslatedLabel != Label) && (TranslatedLabel != Catalog.GetString(Label)) && (TranslatedLabel.Length > 0))
                {
                    // add to po file
                    if (!NewTranslations.ContainsKey(Label))
                    {
                        NewTranslations.Add(Label, TranslatedLabel);
                    }

                    TXMLParser.SetAttribute(node, "Label", TranslatedLabel);
                }
                else
                {
                    TXMLParser.SetAttribute(node, "Label", Catalog.GetString(Label));
                }
            }
        }
예제 #50
0
        private static void AdjustLabel(XmlNode node, TCodeStorage CodeStorage, XmlDocument AOrigLocalisedYaml)
        {
            XmlNode TranslatedNode  = TXMLParser.FindNodeRecursive(AOrigLocalisedYaml, node.Name);
            string  TranslatedLabel = string.Empty;

            if (TranslatedNode != null)
            {
                TranslatedLabel = TXMLParser.GetAttribute(TranslatedNode, "Label");
            }

            TControlDef ctrlDef = new TControlDef(node, CodeStorage);
            string      Label   = ctrlDef.Label;

            if ((ctrlDef.GetAttribute("NoLabel") == "true") || (ctrlDef.controlTypePrefix == "pnl") ||
                (TXMLParser.FindNodeRecursive(node.OwnerDocument, "act" + ctrlDef.controlName.Substring(ctrlDef.controlTypePrefix.Length)) != null) ||
                ctrlDef.GetAttribute("Action").StartsWith("act"))
            {
                Label = string.Empty;
            }

            if ((ctrlDef.controlTypePrefix == "rgr") && (TXMLParser.GetChild(node, "OptionalValues") != null))
            {
                ProcessRadioGroupLabels(node);
            }
            else if (ctrlDef.controlTypePrefix == "mni")
            {
                // drop all attributes
                node.Attributes.RemoveAll();

                foreach (XmlNode menu in node.ChildNodes)
                {
                    if (menu.Name.Contains("Separator"))
                    {
                        continue;
                    }

                    AdjustLabel(menu, CodeStorage, AOrigLocalisedYaml);
                }
            }
            else
            {
                // drop all attributes and children nodes
                node.RemoveAll();
            }

            if (Label.Length > 0)
            {
                if ((TranslatedLabel != Label) && (TranslatedLabel != Catalog.GetString(Label)) && (TranslatedLabel.Length > 0))
                {
                    // add to po file
                    if (!NewTranslations.ContainsKey(Label))
                    {
                        NewTranslations.Add(Label, TranslatedLabel);
                    }

                    TXMLParser.SetAttribute(node, "Label", TranslatedLabel);
                }
                else
                {
                    TXMLParser.SetAttribute(node, "Label", Catalog.GetString(Label));
                }
            }
        }
예제 #51
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)
        {
            base.SetControlProperties(writer, ctrl);

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "SelectedRowActivates"))
            {
                // TODO: this function needs to be called by the manual code at the moment when eg a search finishes
                // TODO: call "Activate" + TYml2Xml.GetAttribute(ctrl.xmlNode, "SelectedRowActivates")
            }

            StringCollection Columns = TYml2Xml.GetElements(ctrl.xmlNode, "Columns");

            if (Columns.Count > 0)
            {
                writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".Columns.Clear();" + Environment.NewLine);

                foreach (string ColumnFieldName in Columns)
                {
                    bool IsDetailNotMaster;
                    TTableField field = null;

                    // customfield, eg. UC_GLTransactions, ATransaction.DateEntered and ATransaction.AnalysisAttributes
                    // there needs to be a list of CustomColumns
                    XmlNode CustomColumnsNode = TYml2Xml.GetChild(ctrl.xmlNode, "CustomColumns");
                    XmlNode CustomColumnNode = null;

                    if (CustomColumnsNode != null)
                    {
                        CustomColumnNode = TYml2Xml.GetChild(CustomColumnsNode, ColumnFieldName);
                    }

                    if (CustomColumnNode != null)
                    {
                        //string ColumnType = "System.String";

                        /* TODO DateTime (tracker: #58)
                         * if (TYml2Xml.GetAttribute(CustomColumnNode, "Type") == "System.DateTime")
                         * {
                         *  ColumnType = "DateTime";
                         * }
                         */

                        // TODO: different behaviour for double???
                        if (TYml2Xml.GetAttribute(CustomColumnNode, "Type") == "Boolean")
                        {
                            //ColumnType = "CheckBox";
                        }

                        writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".Columns.Add(" +
                            "FMainDS." + ctrl.GetAttribute("TableName") + ".Get" + ColumnFieldName + "DBName(), \"" +
                            TYml2Xml.GetAttribute(CustomColumnNode, "Label") + "\");" + Environment.NewLine);
                    }
                    else if (ctrl.HasAttribute("TableName"))
                    {
                        field =
                            TDataBinding.GetTableField(null, ctrl.GetAttribute("TableName") + "." + ColumnFieldName,
                                out IsDetailNotMaster,
                                true);
                    }
                    else
                    {
                        field = TDataBinding.GetTableField(null, ColumnFieldName, out IsDetailNotMaster, true);
                    }

                    if (field != null)
                    {
                        //string ColumnType = "System.String";

                        /* TODO DateTime (tracker: #58)
                         * if (field.GetDotNetType() == "System.DateTime")
                         * {
                         *  ColumnType = "DateTime";
                         * }
                         */

                        // TODO: different behaviour for double???
                        if (field.GetDotNetType() == "Boolean")
                        {
                            //ColumnType = "CheckBox";
                        }

                        writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".Columns.Add(" +
                            TTable.NiceTableName(field.strTableName) + "Table.Get" +
                            TTable.NiceFieldName(field.strName) + "DBName(), \"" +
                            field.strLabel + "\");" + Environment.NewLine);
                    }
                }
            }

            if (ctrl.HasAttribute("ActionLeavingRow"))
            {
                AssignEventHandlerToControl(writer, ctrl, "Selection.FocusRowLeaving", "SourceGrid.RowCancelEventHandler",
                    ctrl.GetAttribute("ActionLeavingRow"));
            }

            if (ctrl.HasAttribute("ActionFocusRow"))
            {
// TODO                AssignEventHandlerToControl(writer, ctrl, "Selection.FocusRowEntered", "SourceGrid.RowEventHandler",
//                    ctrl.GetAttribute("ActionFocusRow"));
            }

            if ((ctrl.controlName == "grdDetails") && FCodeStorage.HasAttribute("DetailTable"))
            {
                writer.Template.AddToCodelet("SHOWDATA", "");

                if (ctrl.HasAttribute("SortOrder"))
                {
                    // SortOrder is comma separated and has DESC or ASC after the column name
                    string SortOrder = ctrl.GetAttribute("SortOrder");

                    foreach (string SortOrderPart in SortOrder.Split(','))
                    {
                        bool temp;
                        TTableField field = null;

                        if ((SortOrderPart.Split(' ')[0].IndexOf(".") == -1) && ctrl.HasAttribute("TableName"))
                        {
                            field =
                                TDataBinding.GetTableField(null, ctrl.GetAttribute("TableName") + "." + SortOrderPart.Split(
                                        ' ')[0], out temp, true);
                        }
                        else
                        {
                            field =
                                TDataBinding.GetTableField(
                                    null,
                                    SortOrderPart.Split(' ')[0],
                                    out temp, true);
                        }

                        if (field != null)
                        {
                            SortOrder = SortOrder.Replace(SortOrderPart.Split(' ')[0], field.strName);
                        }
                    }

                    writer.Template.AddToCodelet("GRIDSORT", SortOrder);
                }

                if (ctrl.HasAttribute("RowFilter"))
                {
                    // this references a field in the table, and assumes there exists a local variable with the same name
                    // eg. FBatchNumber in GL Journals
                    string RowFilter = ctrl.GetAttribute("RowFilter");

                    String FilterString = "\"";

                    foreach (string RowFilterPart in RowFilter.Split(','))
                    {
                        bool temp;
                        string columnName =
                            TDataBinding.GetTableField(
                                null,
                                RowFilterPart,
                                out temp, true).strName;

                        if (FilterString.Length > 1)
                        {
                            FilterString += " + \" and ";
                        }

                        FilterString += columnName + " = \" + F" + TTable.NiceFieldName(columnName) + ".ToString()";
                    }

                    writer.Template.AddToCodelet("GRIDFILTER", FilterString);
                }
            }

            return writer.FTemplate;
        }
예제 #52
0
        private static void LayoutCellInForm(TControlDef ACtrl,
            Int32 AChildrenCount,
            ProcessTemplate ACtrlSnippet,
            ProcessTemplate ASnippetCellDefinition)
        {
            if (ACtrl.HasAttribute("labelWidth"))
            {
                ASnippetCellDefinition.SetCodelet("LABELWIDTH", ACtrl.GetAttribute("labelWidth"));
            }

            if (ACtrl.HasAttribute("columnWidth"))
            {
                ASnippetCellDefinition.SetCodelet("COLUMNWIDTH", ACtrl.GetAttribute("columnWidth").Replace(",", "."));
            }
            else
            {
                ASnippetCellDefinition.SetCodelet("COLUMNWIDTH", (1.0 / AChildrenCount).ToString().Replace(",", "."));
            }

            string Anchor = ANCHOR_DEFAULT_COLUMN;

            if (AChildrenCount == 1)
            {
                Anchor = ANCHOR_SINGLE_COLUMN;
            }

            if (ACtrl.HasAttribute("columnWidth"))
            {
                Anchor = "94%";
            }

            if (ACtrl.GetAttribute("hideLabel") == "true")
            {
                ACtrlSnippet.SetCodelet("HIDELABEL", "true");
                Anchor = ANCHOR_HIDDEN_LABEL;
            }

            ACtrlSnippet.SetCodelet("ANCHOR", Anchor);
        }
예제 #53
0
        /// <summary>
        /// fetch the partner short name from the server;
        /// this control is readonly, therefore we don't need statusbar help
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="ctrl"></param>
        private void LinkControlPartnerShortNameLookup(TFormWriter writer, TControlDef ctrl)
        {
            string PartnerShortNameLookup = ctrl.GetAttribute("PartnerShortNameLookup");
            bool IsDetailNotMaster;

            TTableField field = TDataBinding.GetTableField(ctrl, PartnerShortNameLookup, out IsDetailNotMaster, true);

            string showData = "TPartnerClass partnerClass;" + Environment.NewLine;
            string RowName = "FMainDS." + TTable.NiceTableName(field.strTableName) + "[0]";

            if ((TTable.NiceTableName(field.strTableName) == writer.CodeStorage.GetAttribute("DetailTable"))
                || (TTable.NiceTableName(field.strTableName) == writer.CodeStorage.GetAttribute("MasterTable")))
            {
                RowName = "ARow";
            }

            showData += "string partnerShortName;" + Environment.NewLine;
            showData += "TRemote.MPartner.Partner.ServerLookups.WebConnectors.GetPartnerShortName(" + Environment.NewLine;
            showData += "    " + RowName + "." + TTable.NiceFieldName(field.strName) + "," +
                        Environment.NewLine;
            showData += "    out partnerShortName," + Environment.NewLine;
            showData += "    out partnerClass);" + Environment.NewLine;
            showData += ctrl.controlName + ".Text = partnerShortName;" + Environment.NewLine;

            writer.Template.AddToCodelet("SHOWDATA", showData);
        }
예제 #54
0
        /// <summary>
        /// fill in the attributes for the control
        /// </summary>
        public virtual ProcessTemplate SetControlProperties(TFormWriter writer, TControlDef ACtrl)
        {
            if (FAlreadyInserted.Contains(ACtrl.controlName))
            {
                throw new Exception("Cannot insert control " + ACtrl.controlName + " several times into a form");
            }

            FAlreadyInserted.Add(ACtrl.controlName);

            ProcessTemplate snippetControl = writer.FTemplate.GetSnippet(FControlDefinitionSnippetName);

            snippetControl.SetCodelet("ITEMNAME", ACtrl.controlName);
            snippetControl.SetCodelet("ITEMID", ACtrl.controlName);
            snippetControl.SetCodelet("XTYPE", FControlType);

            if (ACtrl.HasAttribute("xtype"))
            {
                snippetControl.SetCodelet("XTYPE", ACtrl.GetAttribute("xtype"));
            }

            if (ACtrl.HasAttribute("maxLength"))
            {
                snippetControl.SetCodelet("MAXLENGTH", ACtrl.GetAttribute("maxLength"));
            }

            if (ACtrl.HasAttribute("minLength"))
            {
                snippetControl.SetCodelet("MINLENGTH", ACtrl.GetAttribute("minLength"));
            }

            if (ACtrl.HasAttribute("regex"))
            {
                snippetControl.SetCodelet("REGEX", ACtrl.GetAttribute("regex"));
            }

            ((TExtJsFormsWriter)writer).AddResourceString(snippetControl, "LABEL", ACtrl, ACtrl.Label);
            ((TExtJsFormsWriter)writer).AddResourceString(snippetControl, "HELP", ACtrl, ACtrl.GetAttribute("Help"));

            if (ACtrl.HasAttribute("allowBlank") && (ACtrl.GetAttribute("allowBlank") == "true"))
            {
                snippetControl.SetCodelet("ALLOWBLANK", "true");
            }

            if (ACtrl.HasAttribute("inputType"))
            {
                snippetControl.SetCodelet("INPUTTYPE", ACtrl.GetAttribute("inputType"));
            }

            if (ACtrl.HasAttribute("vtype"))
            {
                snippetControl.SetCodelet("VTYPE", ACtrl.GetAttribute("vtype"));
            }

            if (ACtrl.HasAttribute("DateFormat"))
            {
                snippetControl.SetCodelet("DATEFORMAT", ACtrl.GetAttribute("DateFormat"));
            }

            if (ACtrl.HasAttribute("ShowToday"))
            {
                snippetControl.SetCodelet("SHOWTODAY", ACtrl.GetAttribute("ShowToday"));
            }

            if (ACtrl.HasAttribute("MinDateYear"))
            {
                snippetControl.SetCodelet("MINYEAR", ACtrl.GetAttribute("MinDateYear"));
                snippetControl.SetCodelet("MINMONTH", ACtrl.GetAttribute("MinDateMonth"));
                snippetControl.SetCodelet("MINDAY", ACtrl.GetAttribute("MinDateDay"));
            }

            if (ACtrl.HasAttribute("MaxDateYear"))
            {
                snippetControl.SetCodelet("MAXYEAR", ACtrl.GetAttribute("MaxDateYear"));
                snippetControl.SetCodelet("MAXMONTH", ACtrl.GetAttribute("MaxDateMonth"));
                snippetControl.SetCodelet("MAXDAY", ACtrl.GetAttribute("MaxDateDay"));
            }

            if (ACtrl.HasAttribute("DefaultYear"))
            {
                snippetControl.SetCodelet("DEFAULTYEAR", ACtrl.GetAttribute("DefaultYear"));
                snippetControl.SetCodelet("DEFAULTMONTH", ACtrl.GetAttribute("DefaultMonth"));
                snippetControl.SetCodelet("DEFAULTDAY", ACtrl.GetAttribute("DefaultDay"));
            }

            if (ACtrl.HasAttribute("otherPasswordField"))
            {
                snippetControl.SetCodelet("OTHERPASSWORDFIELD", ACtrl.GetAttribute("otherPasswordField"));
                writer.FTemplate.SetCodelet("PASSWORDTWICE", "yes");
                ((TExtJsFormsWriter)writer).AddResourceString(snippetControl, "strErrorPasswordLength", null,
                                                              ACtrl.GetAttribute("ValidationErrorLength"));
                ((TExtJsFormsWriter)writer).AddResourceString(snippetControl, "strErrorPasswordNoMatch", null,
                                                              ACtrl.GetAttribute("ValidationErrorMatching"));
            }

            if (ACtrl.GetAttribute("vtype") == "forcetick")
            {
                writer.FTemplate.SetCodelet("FORCECHECKBOX", "true");
                ((TExtJsFormsWriter)writer).AddResourceString(snippetControl, "strErrorCheckboxRequired", null,
                                                              ACtrl.GetAttribute("ErrorCheckboxRequired"));
            }

            if (FDefaultWidth != -1)
            {
                snippetControl.SetCodelet("WIDTH", FDefaultWidth.ToString());
            }

            snippetControl.SetCodelet("CUSTOMATTRIBUTES", "");

            return(snippetControl);
        }
예제 #55
0
        private void LinkControlDataField(TFormWriter writer, TControlDef ctrl, TTableField AField, bool AIsDetailNotMaster)
        {
            ProcessTemplate snippetValidationControlsDictAdd;
            bool AutomDataValidation;
            string ReasonForAutomValidation;
            string ColumnIDStr;
            bool OKToGenerateDVCode = true;

            if (AField == null)
            {
                return;
            }

            string tablename = TTable.NiceTableName(AField.strTableName);
            string fieldname = TTable.NiceFieldName(AField);
            string RowName = "FMainDS." + tablename + "[0]";
            string TestForNullTable = "FMainDS." + tablename;

            if ((tablename == writer.CodeStorage.GetAttribute("DetailTable")) || (tablename == writer.CodeStorage.GetAttribute("MasterTable")))
            {
                RowName = "ARow";
                TestForNullTable = "";
            }

            string targetCodelet = "SHOWDATA";

            if (tablename == writer.CodeStorage.GetAttribute("DetailTable"))
            {
                targetCodelet = "SHOWDETAILS";
            }

            ProcessTemplate snippetShowData = GenerateShowDataSnippetCode(ref fieldname, ref RowName, ref TestForNullTable, writer, ctrl, AField);

            writer.Template.InsertSnippet(targetCodelet, snippetShowData);

            if (AField.bPartOfPrimKey)
            {
                // check if the current row is new; then allow changing the primary key; otherwise make the control readonly
                writer.Template.AddToCodelet(targetCodelet, ctrl.controlName + "." + (FHasReadOnlyProperty ? "ReadOnly" : "Enabled") + " = " +
                    "(" + RowName + ".RowState " + (FHasReadOnlyProperty ? "!=" : "==") + " DataRowState.Added);" + Environment.NewLine);
                writer.Template.AddToCodelet("PRIMARYKEYCONTROLSREADONLY",
                    ctrl.controlName + "." + (FHasReadOnlyProperty ? "ReadOnly = " : "Enabled = !") + "AReadOnly;" + Environment.NewLine);
            }

            if (ctrl.GetAttribute("ReadOnly").ToLower() != "true")
            {
                targetCodelet = targetCodelet.Replace("SHOW", "SAVE");

                ProcessTemplate snippetGetData = writer.Template.GetSnippet("GETDATAFORCOLUMNTHATCANBENULL");

                if (AField.GetDotNetType().ToLower().Contains("string"))
                {
                    snippetGetData.SetCodelet("GETVALUEORNULL", "{#ROW}.{#COLUMNNAME} = {#CONTROLVALUE};");
                    snippetGetData.InsertSnippet("GETROWVALUEORNULL", writer.Template.GetSnippet("GETROWVALUEORNULLSTRING"));
                }
                else
                {
                    snippetGetData.InsertSnippet("GETVALUEORNULL", writer.Template.GetSnippet("GETVALUEORNULL"));
                    snippetGetData.InsertSnippet("GETROWVALUEORNULL", writer.Template.GetSnippet("GETROWVALUEORNULL"));
                }

                snippetGetData.SetCodelet("CANBENULL", !AField.bNotNull && (this.GetControlValue(ctrl, null) != null) ? "yes" : "");
                snippetGetData.SetCodelet("NOTDEFAULTTABLE", TestForNullTable);
                snippetGetData.SetCodelet("DETERMINECONTROLISNULL", this.GetControlValue(ctrl, null));
                snippetGetData.SetCodelet("ROW", RowName);
                snippetGetData.SetCodelet("COLUMNNAME", fieldname);
                snippetGetData.SetCodelet("CONTROLVALUE", this.GetControlValue(ctrl, AField.GetDotNetType()));
                snippetGetData.SetCodelet("CONTROLNAME", ctrl.controlName);

                writer.Template.InsertSnippet(targetCodelet, snippetGetData);
            }

            // setstatusbar tooltips for datafields, with getstring plus value from petra.xml
            string helpText = AField.strHelp;

            if (helpText.Length == 0)
            {
                helpText = AField.strDescription;
            }

            if ((helpText.Length > 0) && (ctrl.GetAttribute("Tooltip").Length == 0))
            {
                writer.Template.AddToCodelet("INITUSERCONTROLS", "FPetraUtilsObject.SetStatusBarText(" + ctrl.controlName +
                    ", Catalog.GetString(\"" +
                    helpText.Replace("\"", "\\\"") +                           // properly escape double quotation marks
                    "\"));" + Environment.NewLine);
            }

            // Data Validation
            if (GenerateDataValidationCode(writer, ctrl, out AutomDataValidation, out ReasonForAutomValidation))
            {
                string targetCodeletValidation = "ADDCONTROLTOVALIDATIONCONTROLSDICT";

                ColumnIDStr = "FMainDS." + tablename + ".Columns[(short)FMainDS." + tablename + ".GetType().GetField(\"Column" + fieldname +
                              "Id\", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).GetValue(FMainDS." + tablename +
                              ".GetType())]";

                if (writer.Template.FCodelets.Keys.Contains(targetCodeletValidation))
                {
                    // Check if code for the addition of a certain DataColumn is is already contained in Template;
                    // if so, skip a further addition to prevent an Exception at runtime
                    if (writer.Template.FCodelets[targetCodeletValidation].ToString().Contains(ColumnIDStr))
                    {
                        OKToGenerateDVCode = false;
                    }
                }

                if (OKToGenerateDVCode)
                {
                    if (!ctrl.GetAttribute("Validation").ToLower().StartsWith("pair("))
                    {
                        snippetValidationControlsDictAdd = writer.Template.GetSnippet("VALIDATIONCONTROLSDICTADD");
                    }
                    else
                    {
                        snippetValidationControlsDictAdd = writer.Template.GetSnippet("VALIDATIONCONTROLSDICTADDMULTI");

                        string PairControlName = ctrl.GetAttribute("Validation").Substring(5, ctrl.GetAttribute("Validation").Length - 6);
                        TControlDef SecondValidationControl = writer.CodeStorage.GetControl(PairControlName);

                        if (SecondValidationControl != null)
                        {
                            snippetValidationControlsDictAdd.SetCodelet("VALIDATIONCONTROL2", SecondValidationControl.controlName);

                            if (TFormWriter.ProperI18NCatalogGetString(StringHelper.TrimQuotes(SecondValidationControl.Label)))
                            {
                                snippetValidationControlsDictAdd.SetCodelet("LABELTEXT2",
                                    "Catalog.GetString(" + "\"" + SecondValidationControl.Label + "\")");
                            }
                            else
                            {
                                snippetValidationControlsDictAdd.SetCodelet("LABELTEXT2", "\"" + SecondValidationControl.Label + "\"");
                            }
                        }
                        else
                        {
                            throw new ApplicationException(
                                "Pair Control for Validation '" + PairControlName + "' does not exist. Please specify a valid control!");
                        }
                    }

                    snippetValidationControlsDictAdd.SetCodelet("TABLENAME", tablename);
                    snippetValidationControlsDictAdd.SetCodelet("COLUMNID", ColumnIDStr);
                    snippetValidationControlsDictAdd.SetCodelet("VALIDATIONCONTROLSDICTVAR",
                        writer.Template.FTemplateCode.Contains(
                            "FValidationControlsDict") ? "FValidationControlsDict" : "FPetraUtilsObject.ValidationControlsDict");

                    if (AutomDataValidation)
                    {
                        snippetValidationControlsDictAdd.SetCodelet("AUTOMATICVALIDATIONCOMMENT",
                            " // Automatic Data Validation based on DB specification: " + ReasonForAutomValidation);
                    }
                    else
                    {
                        snippetValidationControlsDictAdd.SetCodelet("AUTOMATICVALIDATIONCOMMENT", "");
                    }

                    snippetValidationControlsDictAdd.SetCodelet("VALIDATIONCONTROL", ctrl.controlName);

                    if (TFormWriter.ProperI18NCatalogGetString(StringHelper.TrimQuotes(ctrl.Label)))
                    {
                        snippetValidationControlsDictAdd.SetCodelet("LABELTEXT", "Catalog.GetString(" + "\"" + ctrl.Label + "\")");
                    }
                    else
                    {
                        snippetValidationControlsDictAdd.SetCodelet("LABELTEXT", "\"" + ctrl.Label + "\"");
                    }

                    writer.Template.InsertSnippet(targetCodeletValidation, snippetValidationControlsDictAdd);
                }
            }
        }
예제 #56
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)
        {
            if (IsMniFilterFindClickAndIgnore(writer, ctrl, false))
            {
                return writer.FTemplate;
            }

            base.SetControlProperties(writer, ctrl);

            // deactivate menu items that have no action assigned yet.
            if ((ctrl.GetAction() == null) && !ctrl.HasAttribute("ActionClick") && !ctrl.HasAttribute("ActionOpenScreen")
                && (ctrl.NumberChildren == 0) && !(this is MenuItemSeparatorGenerator))
            {
                string ActionEnabling = ctrl.controlName + ".Enabled = false;" + Environment.NewLine;
                writer.Template.AddToCodelet("ACTIONENABLINGDISABLEMISSINGFUNCS", ActionEnabling);
            }

            writer.SetControlProperty(ctrl, "Text", "\"" + ctrl.Label + "\"");

            if (ctrl.HasAttribute("ShortcutKeys"))
            {
                writer.SetControlProperty(ctrl, "ShortcutKeys", ctrl.GetAttribute("ShortcutKeys"));
            }

            // todo: this.toolStripMenuItem1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;

            return writer.FTemplate;
        }
예제 #57
0
        /// <summary>
        /// add controls to the TableLayoutPanel, but don't write yet;
        /// writing is done in WriteTableLayout, when the layout can be optimised
        /// </summary>
        /// <param name="childctrl"></param>
        /// <param name="column"></param>
        /// <param name="row"></param>
        public void AddControl(
            TControlDef childctrl,
            Int32 column, Int32 row)
        {
            FGrid[column, row] = childctrl;

            childctrl.colSpan = childctrl.HasAttribute("ColSpan") ? Convert.ToInt32(childctrl.GetAttribute("ColSpan")) : 1;
            childctrl.rowSpan = childctrl.HasAttribute("RowSpan") ? Convert.ToInt32(childctrl.GetAttribute("RowSpan")) : 1;

            if (!childctrl.hasLabel)
            {
                childctrl.colSpanWithLabel = childctrl.colSpan * 2;
            }
            else
            {
                childctrl.colSpanWithLabel = childctrl.colSpan * 2 - 1;
            }
        }
예제 #58
0
        /// <summary>
        /// optimise the table layout, and write it;
        /// </summary>
        public void WriteTableLayout(TFormWriter writer, TControlDef LayoutCtrl)
        {
            // calculate the width and height for the columns and rows
            int[] ColumnWidth = new int[FColumnCount];
            int[] RowHeight = new int[FRowCount];

            // first go: ignore cells spanning rows and columns; second go: check that spanning cells fit as well
            for (int spanRunCounter = 0; spanRunCounter < 2; spanRunCounter++)
            {
                for (int columnCounter = 0; columnCounter < FColumnCount; columnCounter++)
                {
                    // initialise the summary values
                    if (spanRunCounter == 0)
                    {
                        ColumnWidth[columnCounter] = 0;

                        if (columnCounter == 0)
                        {
                            for (int rowCounter = 0; rowCounter < FRowCount; rowCounter++)
                            {
                                RowHeight[rowCounter] = 0;
                            }
                        }
                    }

                    for (int rowCounter = 0; rowCounter < FRowCount; rowCounter++)
                    {
                        if ((FGrid[columnCounter, rowCounter] != null))
                        {
                            TControlDef ctrl = FGrid[columnCounter, rowCounter];

                            int CellWidth = ctrl.Width;
                            TLogging.LogAtLevel(1, "Control '" + ctrl.controlName + "' Width in WriteTableLayout: " + CellWidth.ToString());

                            if ((spanRunCounter == 0) && (ctrl.colSpanWithLabel == 1))
                            {
                                if (CellWidth > ColumnWidth[columnCounter])
                                {
                                    ColumnWidth[columnCounter] = CellWidth;
                                }
                            }
                            else
                            {
                                int CurrentSpanWidth = 0;

                                if (columnCounter + ctrl.colSpanWithLabel > FColumnCount)
                                {
                                    // TODO: make an exception again?
                                    TLogging.Log("Warning: invalid colspan " + ctrl.colSpan.ToString() + " in control " + ctrl.controlName +
                                        ". There are only " +
                                        (FColumnCount / 2).ToString() + " columns overall");

                                    ctrl.colSpanWithLabel = ctrl.colSpan;
                                }

                                for (int columnCounter2 = columnCounter; columnCounter2 < columnCounter + ctrl.colSpanWithLabel; columnCounter2++)
                                {
                                    CurrentSpanWidth += ColumnWidth[columnCounter2];
                                }

                                if (CurrentSpanWidth < CellWidth)
                                {
                                    ColumnWidth[columnCounter + ctrl.colSpanWithLabel - 1] += CellWidth - CurrentSpanWidth;
                                }
                            }

                            int CellHeight = ctrl.Height;

                            if (CellHeight == 17)
                            {
                                // for labels, we should consider the margin top as well.
                                CellHeight = 22;
                            }

                            if ((spanRunCounter == 0) && (ctrl.colSpanWithLabel == 1))
                            {
                                if (CellHeight > RowHeight[rowCounter])
                                {
                                    RowHeight[rowCounter] = CellHeight;
                                }
                            }
                            else
                            {
                                int CurrentSpanHeight = 0;

                                for (int rowCounter2 = rowCounter; rowCounter2 < rowCounter + ctrl.rowSpan; rowCounter2++)
                                {
                                    CurrentSpanHeight += RowHeight[rowCounter2];
                                }

                                if (CurrentSpanHeight < CellHeight)
                                {
                                    RowHeight[rowCounter + ctrl.rowSpan - 1] += CellHeight - CurrentSpanHeight;
                                }
                            }
                        }
                    }
                }
            }

            // now apply settings about the column width and row height
            if (FColWidths != null)
            {
                bool simpleColumnWidth = false;

                // for the simple column width specification, you need to provide a width for each column, without the label columns
                if (FColWidths.Count * 2 == FColumnCount)
                {
                    simpleColumnWidth = true;

                    for (int columnCounter = 0; columnCounter < FColWidths.Count; columnCounter++)
                    {
                        if (!FColWidths.ContainsKey(columnCounter))
                        {
                            simpleColumnWidth = false;
                        }
                    }
                }

                for (int columnCounter = 0; columnCounter < FColumnCount; columnCounter++)
                {
                    if (simpleColumnWidth)
                    {
                        // the specified width includes the label column
                        if (FColWidths.ContainsKey(columnCounter / 2))
                        {
                            string[] ColWidthSpec = FColWidths[columnCounter / 2].Split(':');

                            if (ColWidthSpec[0].ToLower() == "fixed")
                            {
                                ColumnWidth[columnCounter] = Convert.ToInt32(ColWidthSpec[1]) / 2;
                            }
                            else if (ColWidthSpec[0].ToLower() == "percent")
                            {
                                // TODO
                            }
                        }
                    }
                    else
                    {
                        if (FColWidths.ContainsKey(columnCounter))
                        {
                            string[] ColWidthSpec = FColWidths[columnCounter].Split(':');

                            if (ColWidthSpec[0].ToLower() == "fixed")
                            {
                                ColumnWidth[columnCounter] = Convert.ToInt32(ColWidthSpec[1]);
                            }
                            else if (ColWidthSpec[0].ToLower() == "percent")
                            {
                                // TODO
                                TLogging.Log("Warning: we currently don't support colwidth in percentage, control " + LayoutCtrl.controlName);
                            }
                        }
                    }
                }
            }

            if (FRowHeights != null)
            {
                for (int rowCounter = 0; rowCounter < FRowCount; rowCounter++)
                {
                    if (FRowHeights.ContainsKey(rowCounter))
                    {
                        string[] RowHeightSpec = FRowHeights[rowCounter].Split(':');

                        if (RowHeightSpec[0].ToLower() == "fixed")
                        {
                            RowHeight[rowCounter] = Convert.ToInt32(RowHeightSpec[1]);
                        }
                        else if (RowHeightSpec[0].ToLower() == "percent")
                        {
                            // TODO
                            TLogging.Log("Warning: we currently don't support rowheight in percentage, control " + LayoutCtrl.controlName);
                        }
                    }
                }
            }

            if (TLogging.DebugLevel >= 4)
            {
                StringCollection widthStringCollection = new StringCollection();

                for (int columnCounter = 0; columnCounter < FColumnCount; columnCounter++)
                {
                    widthStringCollection.Add(ColumnWidth[columnCounter].ToString());
                }

                TLogging.Log("column width for " + LayoutCtrl.controlName + ": " + StringHelper.StrMerge(widthStringCollection, ','));

                for (int rowCounter = 0; rowCounter < FRowCount; rowCounter++)
                {
                    string rowText = string.Empty;

                    for (int columnCounter = 0; columnCounter < FColumnCount; columnCounter++)
                    {
                        if (FGrid[columnCounter, rowCounter] != null)
                        {
                            TControlDef childctrl = FGrid[columnCounter, rowCounter];

                            for (int countspan = 0; countspan < childctrl.colSpanWithLabel; countspan++)
                            {
                                rowText += string.Format("{0}:{1} ", columnCounter + countspan, childctrl.controlName);
                            }
                        }
                    }

                    TLogging.Log(String.Format(" Row{0}: {1}", rowCounter, rowText));
                }
            }

            int Width = 0;
            int Height = 0;

            int CurrentLeftPosition = Convert.ToInt32(LayoutCtrl.GetAttribute("MarginLeft", MARGIN_LEFT.ToString()));

            for (int columnCounter = 0; columnCounter < FColumnCount; columnCounter++)
            {
                int CurrentTopPosition;

                if (LayoutCtrl.IsHorizontalGridButtonPanel)
                {
                    TLogging.LogAtLevel(1,
                        "Setting CurrentTopPosition to 3 for all Controls on Control '" + LayoutCtrl.controlName +
                        "' as it is a horizontal Grid Button Panel (used for Buttons).");
                    CurrentTopPosition = 3;
                }
                else
                {
                    CurrentTopPosition = Convert.ToInt32(LayoutCtrl.GetAttribute("MarginTop", MARGIN_TOP.ToString()));
                }

                // only twice the margin for groupboxes
                if ((LayoutCtrl.controlTypePrefix == "grp") || (LayoutCtrl.controlTypePrefix == "rgr"))
                {
                    CurrentTopPosition += MARGIN_TOP;
                }

                for (int rowCounter = 0; rowCounter < FRowCount; rowCounter++)
                {
                    if (FGrid[columnCounter, rowCounter] != null)
                    {
                        TControlDef childctrl = FGrid[columnCounter, rowCounter];

                        if (childctrl.GetAttribute("Stretch") == "horizontally")
                        {
                            // use the full column width
                            // add up spanning columns
                            int concatenatedColumnWidth = ColumnWidth[columnCounter];

                            for (int colSpanCounter = 1; colSpanCounter < childctrl.colSpanWithLabel; colSpanCounter++)
                            {
                                concatenatedColumnWidth += ColumnWidth[columnCounter + colSpanCounter];
                            }

                            if (concatenatedColumnWidth > 0)
                            {
                                TControlDef ParentControl = childctrl.FCodeStorage.GetControl(childctrl.parentName);
                                System.Windows.Forms.Padding? ParentPad = null;

                                if (ParentControl.HasAttribute("Padding"))
                                {
                                    string ParentPadding = ParentControl.GetAttribute("Padding");
                                    TLogging.LogAtLevel(1, "ParentControl '" + ParentControl.controlName + "' Padding: " + ParentPadding);

                                    if (ParentPadding.IndexOf(',') == -1)
                                    {
                                        ParentPad = new Padding(Convert.ToInt32(ParentPadding));
                                    }
                                    else
                                    {
                                        string[] Paddings = ParentPadding.Split(',');
                                        ParentPad = new Padding(Convert.ToInt32(Paddings[0]), Convert.ToInt32(Paddings[1]),
                                            Convert.ToInt32(Paddings[2]), Convert.ToInt32(Paddings[3]));
                                    }

                                    TLogging.LogAtLevel(1, "ParentControl Padding (parsed): " + ParentPad.ToString());
                                }

                                writer.SetControlProperty(childctrl, "Size",
                                    String.Format("new System.Drawing.Size({0}, {1})", concatenatedColumnWidth -
                                        (ParentPad.HasValue ? ParentPad.Value.Right : 0),
                                        childctrl.Height));
                            }
                        }

                        int ControlTopPosition = CurrentTopPosition;
                        int ControlLeftPosition = CurrentLeftPosition;
                        TLogging.LogAtLevel(1, "WriteTableLayout for Control '" + childctrl.controlName + "'");
                        // add margin or padding
                        string padding = writer.GetControlProperty(childctrl.controlName, "Padding");

                        if (padding.Length > 0)
                        {
                            string[] values = padding.Substring(padding.IndexOf("(") + 1).Replace(")", "").Split(new char[] { ',' });
                            ControlLeftPosition += Convert.ToInt32(values[0]);
                            ControlTopPosition += Convert.ToInt32(values[1]);
                            TLogging.LogAtLevel(1, "Removing Padding Property from Control '" + childctrl.controlName + "'!");
                            writer.ClearControlProperty(childctrl.controlName, "Padding");
                        }

                        string margin = writer.GetControlProperty(childctrl.controlName, "Margin");

                        if (margin.Length > 0)
                        {
                            string[] values = margin.Substring(margin.IndexOf("(") + 1).Replace(")", "").Split(new char[] { ',' });
                            ControlLeftPosition += Convert.ToInt32(values[0]);
                            ControlTopPosition += Convert.ToInt32(values[1]);
                            writer.ClearControlProperty(childctrl.controlName, "Margin");
                        }

                        if ((childctrl.IsOnHorizontalGridButtonPanel)
                            && (columnCounter != 0)
                            && !((childctrl.HasAttribute("StartNewButtonGroup"))
                                 && (childctrl.GetAttribute("StartNewButtonGroup").ToLower() == "true")))
                        {
                            TLogging.LogAtLevel(1,
                                "Adjusted ControlLeftPosition for Control '" + childctrl.controlName +
                                "' as it is on a horizontal Grid Button Panel.");
                            ControlLeftPosition -= 8;
                        }

                        writer.SetControlProperty(childctrl.controlName,
                            "Location",
                            String.Format("new System.Drawing.Point({0},{1})",
                                ControlLeftPosition.ToString(),
                                ControlTopPosition.ToString()),
                            false);
                        writer.CallControlFunction(LayoutCtrl.controlName,
                            "Controls.Add(this." + childctrl.controlName + ")");

                        if (FTabOrder == "Horizontal")
                        {
                            writer.SetControlProperty(childctrl.controlName, "TabIndex", FCurrentTabIndex.ToString(), false);
                            FCurrentTabIndex += 10;
                        }
                    }

                    CurrentTopPosition += RowHeight[rowCounter];

                    CurrentTopPosition += Convert.ToInt32(LayoutCtrl.GetAttribute("VerticalSpace", VERTICAL_SPACE.ToString()));

                    if (CurrentTopPosition > Height)
                    {
                        Height = CurrentTopPosition;
                    }
                }

                CurrentLeftPosition += ColumnWidth[columnCounter];

                CurrentLeftPosition += Convert.ToInt32(LayoutCtrl.GetAttribute("HorizontalSpace", HORIZONTAL_SPACE.ToString()));

                if (CurrentLeftPosition > Width)
                {
                    Width = CurrentLeftPosition;
                }
            }

            Height +=
                Convert.ToInt32(LayoutCtrl.GetAttribute("MarginBottom", MARGIN_BOTTOM.ToString())) -
                Convert.ToInt32(LayoutCtrl.GetAttribute("VerticalSpace", VERTICAL_SPACE.ToString()));

            if (!LayoutCtrl.HasAttribute("Width"))
            {
                LayoutCtrl.SetAttribute("Width", Width.ToString());
            }
            else
            {
                Width = Convert.ToInt32(LayoutCtrl.GetAttribute("Width"));
            }

            if (!LayoutCtrl.HasAttribute("Height"))
            {
                LayoutCtrl.SetAttribute("Height", Height.ToString());
            }
            else
            {
                Height = Convert.ToInt32(LayoutCtrl.GetAttribute("Height"));
            }

            writer.SetControlProperty(LayoutCtrl, "Location", String.Format("new System.Drawing.Point({0}, {1})", MARGIN_LEFT, MARGIN_TOP));
            writer.SetControlProperty(LayoutCtrl, "Size", String.Format("new System.Drawing.Size({0}, {1})", Width, Height));

            // by default, the TabOrder is by column, Vertical
            if (FTabOrder != "Horizontal")
            {
                for (int rowCounter = 0; rowCounter < FRowCount; rowCounter++)
                {
                    for (int columnCounter = 0; columnCounter < FColumnCount; columnCounter++)
                    {
                        if (FGrid[columnCounter, rowCounter] != null)
                        {
                            TControlDef childctrl = FGrid[columnCounter, rowCounter];

                            writer.SetControlProperty(childctrl.controlName, "TabIndex", FCurrentTabIndex.ToString(), false);
                            FCurrentTabIndex += 10;
                        }
                    }
                }
            }
        }
예제 #59
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)
        {
            base.SetControlProperties(writer, ctrl);

            if (TYml2Xml.HasAttribute(ctrl.xmlNode, "SelectedRowActivates"))
            {
                // TODO: this function needs to be called by the manual code at the moment when eg a search finishes
                // TODO: call "Activate" + TYml2Xml.GetAttribute(ctrl.xmlNode, "SelectedRowActivates")
            }

            StringCollection Columns = TYml2Xml.GetElements(ctrl.xmlNode, "Columns");

            if (Columns.Count > 0)
            {
                writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".Columns.Clear();" + Environment.NewLine);

                foreach (string ColumnFieldName in Columns)
                {
                    bool        IsDetailNotMaster;
                    TTableField field = null;

                    // customfield, eg. UC_GLTransactions, ATransaction.DateEntered and ATransaction.AnalysisAttributes
                    // there needs to be a list of CustomColumns
                    XmlNode CustomColumnsNode = TYml2Xml.GetChild(ctrl.xmlNode, "CustomColumns");
                    XmlNode CustomColumnNode  = null;

                    if (CustomColumnsNode != null)
                    {
                        CustomColumnNode = TYml2Xml.GetChild(CustomColumnsNode, ColumnFieldName);
                    }

                    if (CustomColumnNode != null)
                    {
                        //string ColumnType = "System.String";

                        /* TODO DateTime (tracker: #58)
                         * if (TYml2Xml.GetAttribute(CustomColumnNode, "Type") == "System.DateTime")
                         * {
                         *  ColumnType = "DateTime";
                         * }
                         */

                        // TODO: different behaviour for double???
                        if (TYml2Xml.GetAttribute(CustomColumnNode, "Type") == "Boolean")
                        {
                            //ColumnType = "CheckBox";
                        }

                        writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".Columns.Add(" +
                                                     "FMainDS." + ctrl.GetAttribute("TableName") + ".Get" + ColumnFieldName + "DBName(), \"" +
                                                     TYml2Xml.GetAttribute(CustomColumnNode, "Label") + "\");" + Environment.NewLine);
                    }
                    else if (ctrl.HasAttribute("TableName"))
                    {
                        field =
                            TDataBinding.GetTableField(null, ctrl.GetAttribute("TableName") + "." + ColumnFieldName,
                                                       out IsDetailNotMaster,
                                                       true);
                    }
                    else
                    {
                        field = TDataBinding.GetTableField(null, ColumnFieldName, out IsDetailNotMaster, true);
                    }

                    if (field != null)
                    {
                        //string ColumnType = "System.String";

                        /* TODO DateTime (tracker: #58)
                         * if (field.GetDotNetType() == "System.DateTime")
                         * {
                         *  ColumnType = "DateTime";
                         * }
                         */

                        // TODO: different behaviour for double???
                        if (field.GetDotNetType() == "Boolean")
                        {
                            //ColumnType = "CheckBox";
                        }

                        writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".Columns.Add(" +
                                                     TTable.NiceTableName(field.strTableName) + "Table.Get" +
                                                     TTable.NiceFieldName(field.strName) + "DBName(), \"" +
                                                     field.strLabel + "\");" + Environment.NewLine);
                    }
                }
            }

            if (ctrl.HasAttribute("ActionLeavingRow"))
            {
                AssignEventHandlerToControl(writer, ctrl, "Selection.FocusRowLeaving", "SourceGrid.RowCancelEventHandler",
                                            ctrl.GetAttribute("ActionLeavingRow"));
            }

            if (ctrl.HasAttribute("ActionFocusRow"))
            {
// TODO                AssignEventHandlerToControl(writer, ctrl, "Selection.FocusRowEntered", "SourceGrid.RowEventHandler",
//                    ctrl.GetAttribute("ActionFocusRow"));
            }

            if ((ctrl.controlName == "grdDetails") && FCodeStorage.HasAttribute("DetailTable"))
            {
                writer.Template.AddToCodelet("SHOWDATA", "");

                if (ctrl.HasAttribute("SortOrder"))
                {
                    // SortOrder is comma separated and has DESC or ASC after the column name
                    string SortOrder = ctrl.GetAttribute("SortOrder");

                    foreach (string SortOrderPart in SortOrder.Split(','))
                    {
                        bool        temp;
                        TTableField field = null;

                        if ((SortOrderPart.Split(' ')[0].IndexOf(".") == -1) && ctrl.HasAttribute("TableName"))
                        {
                            field =
                                TDataBinding.GetTableField(null, ctrl.GetAttribute("TableName") + "." + SortOrderPart.Split(
                                                               ' ')[0], out temp, true);
                        }
                        else
                        {
                            field =
                                TDataBinding.GetTableField(
                                    null,
                                    SortOrderPart.Split(' ')[0],
                                    out temp, true);
                        }

                        if (field != null)
                        {
                            SortOrder = SortOrder.Replace(SortOrderPart.Split(' ')[0], field.strName);
                        }
                    }

                    writer.Template.AddToCodelet("GRIDSORT", SortOrder);
                }

                if (ctrl.HasAttribute("RowFilter"))
                {
                    // this references a field in the table, and assumes there exists a local variable with the same name
                    // eg. FBatchNumber in GL Journals
                    string RowFilter = ctrl.GetAttribute("RowFilter");

                    String FilterString = "\"";

                    foreach (string RowFilterPart in RowFilter.Split(','))
                    {
                        bool   temp;
                        string columnName =
                            TDataBinding.GetTableField(
                                null,
                                RowFilterPart,
                                out temp, true).strName;

                        if (FilterString.Length > 1)
                        {
                            FilterString += " + \" and ";
                        }

                        FilterString += columnName + " = \" + F" + TTable.NiceFieldName(columnName) + ".ToString()";
                    }

                    writer.Template.AddToCodelet("GRIDFILTER", FilterString);
                }
            }

            return(writer.FTemplate);
        }
예제 #60
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 ctrlSnippet = base.SetControlProperties(writer, ctrl);

            ProcessTemplate uploadCheckAssistantSnippet = writer.FTemplate.GetSnippet("ASSISTANTPAGEWITHUPLOADVALID");

            ((TExtJsFormsWriter)writer).AddResourceString(uploadCheckAssistantSnippet, "MISSINGUPLOADTITLE", ctrl,
                ctrl.GetAttribute("MissingUploadTitle"));
            ((TExtJsFormsWriter)writer).AddResourceString(uploadCheckAssistantSnippet, "MISSINGUPLOADMESSAGE", ctrl,
                ctrl.GetAttribute("MissingUploadMessage"));

            writer.FTemplate.InsertSnippet("ISVALID", uploadCheckAssistantSnippet);
            writer.FTemplate.InsertSnippet("ONSHOW", writer.FTemplate.GetSnippet("ASSISTANTPAGEWITHUPLOADSHOW"));
            writer.FTemplate.InsertSnippet("ONHIDE", writer.FTemplate.GetSnippet("ASSISTANTPAGEWITHUPLOADHIDE"));

            ProcessTemplate uploadSnippet = writer.FTemplate.GetSnippet("UPLOADFORMDEFINITION");

            if (ctrl.HasAttribute("UploadButtonLabel"))
            {
                ((TExtJsFormsWriter)writer).AddResourceString(uploadCheckAssistantSnippet, "UPLOADBUTTONLABEL", ctrl,
                    ctrl.GetAttribute("UploadButtonLabel"));
                uploadSnippet.SetCodelet("UPLOADBUTTONLABEL", ctrl.controlName + "UPLOADBUTTONLABEL");
            }

            writer.FTemplate.InsertSnippet("UPLOADFORM", uploadSnippet);

            ProcessTemplate uploadCheckSnippet = writer.FTemplate.GetSnippet("VALIDUPLOADCHECK");
            writer.FTemplate.InsertSnippet("CHECKFORVALIDUPLOAD", uploadCheckSnippet);

            return ctrlSnippet;
        }