/// <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); }
/// <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); }
/// <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) { 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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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; } }
/// <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); }
/// <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)); }
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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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, "PositiveValueActivates")) { if (ctrl.HasAttribute("OnChange")) { throw new Exception(ctrl.controlName + " cannot have OnChange and PositiveValueActivates at the same time"); } AssignEventHandlerToControl(writer, ctrl, "ValueChanged", ctrl.controlName + "ValueChanged"); writer.CodeStorage.FEventHandlersImplementation += "private void " + ctrl.controlName + "ValueChanged" + "(object sender, EventArgs e)" + Environment.NewLine + "{" + Environment.NewLine + " ActionEnabledEvent(null, new ActionEventArgs(\"" + TYml2Xml.GetAttribute(ctrl.xmlNode, "PositiveValueActivates") + "\", " + ctrl.controlName + ".Value > 0));" + Environment.NewLine + "}" + Environment.NewLine + Environment.NewLine; } return(writer.FTemplate); }
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; } }
/// <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 snippetDynamicTabPage = null; ProcessTemplate snippetTabPageSelectionChanged = null; string IgnoreFirstTabSel = String.Empty; base.SetControlProperties(writer, ctrl); writer.SetControlProperty(ctrl, "DrawMode", "System.Windows.Forms.TabDrawMode.OwnerDrawFixed"); // by default the tab order cannot be changed if (!ctrl.HasAttribute("DragTabPageEnabled") || (ctrl.GetAttribute("DragTabPageEnabled").ToLower() == "false")) { writer.SetControlProperty(ctrl, "AllowDrop", "false"); } if (ctrl.HasAttribute("ShowToolTips") && (ctrl.GetAttribute("ShowToolTips").ToLower() == "true")) { writer.SetControlProperty(ctrl, "ShowToolTips", "true"); } writer.Template.SetCodelet("TABPAGECTRL", ctrl.controlName); if (ctrl.HasAttribute("IgnoreFirstTabPageSelectionChange") && (ctrl.GetAttribute("IgnoreFirstTabPageSelectionChange").ToLower() == "true")) { IgnoreFirstTabSel += "if (FirstTabPageSelectionChanged)" + Environment.NewLine; IgnoreFirstTabSel += "{" + Environment.NewLine; IgnoreFirstTabSel += " // The first time we run this Method we exit straight away!" + Environment.NewLine; IgnoreFirstTabSel += " return;" + Environment.NewLine; IgnoreFirstTabSel += "}" + Environment.NewLine + Environment.NewLine + Environment.NewLine; writer.Template.AddToCodelet("IGNOREFIRSTTABPAGESELECTIONCHANGEDEVENT", IgnoreFirstTabSel); } if (IgnoreFirstTabSel != String.Empty) { writer.Template.SetCodelet("FIRSTTABPAGESELECTIONCHANGEDVAR", "true"); } if (ctrl.HasAttribute("LoadPagesDynamically") && (ctrl.GetAttribute("LoadPagesDynamically").ToLower() == "true")) { snippetDynamicTabPage = writer.Template.GetSnippet("DYNAMICTABPAGE"); if (IgnoreFirstTabSel != String.Empty) { snippetDynamicTabPage.SetCodelet("FIRSTTABPAGESELECTIONCHANGEDVAR", "true"); } if (writer.IsUserControlTemplate) { snippetDynamicTabPage.SetCodelet("ISUSERCONTROL", "true"); } writer.Template.InsertSnippet("DYNAMICTABPAGEBASICS", snippetDynamicTabPage); snippetTabPageSelectionChanged = writer.Template.GetSnippet("TABPAGESELECTIONCHANGED"); if (writer.IsUserControlTemplate) { snippetTabPageSelectionChanged.SetCodelet("ISUSERCONTROL", "true"); } writer.Template.InsertSnippet("DYNAMICTABPAGEUSERCONTROLSELECTIONCHANGED", snippetTabPageSelectionChanged); } else { writer.Template.AddToCodelet("DYNAMICTABPAGEUSERCONTROLSELECTIONCHANGED", ""); } // writer.Template.FTemplateCode.Contains is not very clean, since it might be in a snippet or in an ifdef that will not be part of the resulting file if ((writer.CodeStorage.ManualFileExistsAndContains("void TabSelectionChanged")) || (writer.Template.FTemplateCode.Contains("void TabSelectionChanged")) || (snippetDynamicTabPage != null)) { AssignEventHandlerToControl(writer, ctrl, "SelectedIndexChanged", "TabSelectionChanged"); writer.Template.AddToCodelet("INITMANUALCODE", ctrl.controlName + ".SelectedIndex = 0;" + Environment.NewLine); writer.Template.AddToCodelet("INITMANUALCODE", "TabSelectionChanged(null, null);" + 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) { 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); }
/// <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; } } } } }
/// <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; }
/// <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; }
/// <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) { 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; }
/// <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(); } } } }
/// <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; }
/// <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 CntrlNameWithoutPrefix = ctrl.controlName.Substring(3); string CntrlVaribleNameWithoutPrefix; StringCollection DynamicControlTypes; base.SetControlProperties(writer, ctrl); writer.SetControlProperty(ctrl, "Dock", "Fill"); if (ctrl.HasAttribute("ToolTip")) { writer.SetControlProperty(ctrl, "ToolTipText", "\"" + ctrl.GetAttribute("ToolTip") + "\""); } #region Dynamic TabPage UserControl loading ('LoadPageDynamically' attribute and 'DynamicControlTypes' Element) if (ctrl.HasAttribute("LoadPageDynamically") && (ctrl.GetAttribute("LoadPageDynamically").ToLower() == "true")) { if ((!ctrl.HasAttribute("DynamicControlType") && (TYml2Xml.GetElements(ctrl.xmlNode, "DynamicControlTypes").Count == 0))) { throw new Exception( "TabPage '" + ctrl.controlName + "': Either the 'DynamicControlType' or the 'DynamicControlTypes' property need to be specified if 'LoadPageDynamically' is specified"); } else if (ctrl.HasAttribute("DynamicControlType")) { DynamicControlTypes = new StringCollection(); DynamicControlTypes.Add(ctrl.GetAttribute("DynamicControlType")); } else { DynamicControlTypes = TYml2Xml.GetElements(ctrl.xmlNode, "DynamicControlTypes"); } ProcessTemplate snippetUserControlInitialisation = writer.Template.GetSnippet("USERCONTROLINITIALISATION"); ProcessTemplate snippetUserControlSetupMethod = writer.Template.GetSnippet("DYNAMICTABPAGEUSERCONTROLSETUPMETHOD"); for (int Counter = 0; Counter < DynamicControlTypes.Count; Counter = Counter + 2) { if (DynamicControlTypes.Count == 1) { CntrlVaribleNameWithoutPrefix = CntrlNameWithoutPrefix; } else { CntrlVaribleNameWithoutPrefix = CntrlNameWithoutPrefix + DynamicControlTypes[Counter + 1]; } //Console.WriteLine("CntrlVaribleNameWithoutPrefix: " + CntrlVaribleNameWithoutPrefix + "; Counter: " + Counter.ToString()); writer.Template.AddToCodelet("DYNAMICTABPAGEUSERCONTROLDECLARATION", "private " + DynamicControlTypes[Counter] + " FUco" + CntrlVaribleNameWithoutPrefix + ";" + Environment.NewLine); // Declare an Enum for each dynamically loaded TabPage string DynamicTabPageEnums = ""; DynamicTabPageEnums += "///<summary>Denotes dynamic loadable UserControl" + " FUco" + CntrlVaribleNameWithoutPrefix + "</summary>" + Environment.NewLine; DynamicTabPageEnums += "dluc" + CntrlVaribleNameWithoutPrefix + "," + Environment.NewLine; writer.Template.AddToCodelet("DYNAMICTABPAGEUSERCONTROLENUM", DynamicTabPageEnums); // Dispose UserControl for each dynamically loaded TabPage string CustomDisposingOfControl = ""; CustomDisposingOfControl += "if (FUco" + CntrlVaribleNameWithoutPrefix + " != null)" + Environment.NewLine; CustomDisposingOfControl += "{" + Environment.NewLine; CustomDisposingOfControl += " FUco" + CntrlVaribleNameWithoutPrefix + ".Dispose();" + Environment.NewLine; CustomDisposingOfControl += "}" + Environment.NewLine; writer.Template.AddToCodelet("CUSTOMDISPOSING", CustomDisposingOfControl); // Initialise each dynamically loaded TabPage ProcessTemplate snippetUserControlSetup = writer.Template.GetSnippet("DYNAMICTABPAGEUSERCONTROLSETUP"); ProcessTemplate snippetTabPageSubseqAct = writer.Template.GetSnippet("DYNAMICTABPAGESUBSEQUENTACTIVATION"); if (writer.IsUserControlTemplate) { snippetUserControlSetup.SetCodelet("ISUSERCONTROL", "true"); } snippetUserControlInitialisation.SetCodelet("CONTROLNAME", ctrl.controlName); snippetUserControlInitialisation.SetCodelet("CONTROLNAMEWITHOUTPREFIX", CntrlNameWithoutPrefix); snippetUserControlSetup.SetCodelet("CONTROLNAME", ctrl.controlName); snippetUserControlInitialisation.SetCodelet("TABCONTROLNAME", TabControlGenerator.TabControlName); snippetUserControlSetup.SetCodelet("DYNAMICCONTROLTYPE", DynamicControlTypes[Counter]); ProcessTemplate snippetUserControlLoading = writer.Template.GetSnippet("USERCONTROLLOADING"); if ((ctrl.HasAttribute("SeparateDynamicControlSetupMethod") && (ctrl.GetAttribute("SeparateDynamicControlSetupMethod").ToLower() == "true")) || (DynamicControlTypes.Count > 1)) { if (DynamicControlTypes.Count == 1) { snippetUserControlInitialisation.SetCodelet("TABKEY", "TDynamicLoadableUserControls.dluc" + CntrlNameWithoutPrefix + ")"); snippetUserControlSetupMethod = writer.Template.GetSnippet("DYNAMICTABPAGEUSERCONTROLSETUPMETHOD"); snippetUserControlSetup.SetCodelet("CONTROLNAMEWITHOUTPREFIX", CntrlNameWithoutPrefix); snippetUserControlSetupMethod.SetCodelet("DYNLOADINFO", "UserControl 'FUco" + CntrlNameWithoutPrefix + "'."); snippetUserControlSetupMethod.SetCodelet("USERORTABCONTROLNAMEWITHOUTPREFIX", "UserControl" + CntrlNameWithoutPrefix); snippetUserControlSetupMethod.InsertSnippet("DYNAMICTABPAGEUSERCONTROLSETUPINLINE2", snippetUserControlSetup); writer.Template.InsertSnippet("DYNAMICTABPAGEUSERCONTROLSETUPMETHODS", snippetUserControlSetupMethod); snippetUserControlInitialisation.AddToCodelet("DYNAMICTABPAGEUSERCONTROLSETUPINLINE1", "SetupUserControl" + CntrlNameWithoutPrefix + "();" + Environment.NewLine); snippetTabPageSubseqAct.SetCodelet("CONTROLNAME", ctrl.controlName); snippetTabPageSubseqAct.SetCodelet("CONTROLNAMEWITHOUTPREFIX", CntrlNameWithoutPrefix); snippetUserControlInitialisation.InsertSnippet("DYNAMICTABPAGESUBSEQUENTACTIVATION", snippetTabPageSubseqAct); writer.Template.InsertSnippet("DYNAMICTABPAGEUSERCONTROLINITIALISATION", snippetUserControlInitialisation); snippetUserControlLoading.SetCodelet("CONTROLNAMEWITHOUTPREFIX", CntrlNameWithoutPrefix); } else { snippetUserControlInitialisation.SetCodelet("TABKEY", "Get" + CntrlNameWithoutPrefix + "VariableUC())"); ProcessTemplate snippetUserControlSetupMethodMultiUC = writer.Template.GetSnippet( "DYNAMICTABPAGEUSERCONTROLSETUPMULTIUCPART"); ProcessTemplate snippetTabPageSubseqActIfStmt = writer.Template.GetSnippet("DYNAMICTABPAGEUSERCONTROLSETUPMULTIUCPART"); snippetUserControlSetup.SetCodelet("CONTROLNAMEWITHOUTPREFIX", CntrlVaribleNameWithoutPrefix); snippetUserControlSetupMethod.SetCodelet("DYNLOADINFO", "TabPage '" + ctrl.controlName + "' with varying UserControls."); snippetUserControlSetupMethod.SetCodelet("USERORTABCONTROLNAMEWITHOUTPREFIX", "VariableUserControlForTabPage" + CntrlNameWithoutPrefix); snippetUserControlSetupMethodMultiUC.SetCodelet("TABCONTROLNAMEWITHOUTPREFIX", CntrlNameWithoutPrefix); snippetUserControlSetupMethodMultiUC.SetCodelet("USERCONTROLNAMEWITHOUTPREFIX", CntrlVaribleNameWithoutPrefix); snippetUserControlSetupMethodMultiUC.InsertSnippet("MULTIUCCODE", snippetUserControlSetup); if (Counter < DynamicControlTypes.Count - 2) { snippetUserControlSetupMethodMultiUC.SetCodelet("ELSESTATEMENT", "else"); snippetTabPageSubseqActIfStmt.SetCodelet("ELSESTATEMENT", "else"); } snippetUserControlSetupMethod.InsertSnippet("DYNAMICTABPAGEUSERCONTROLSETUPINLINE2", snippetUserControlSetupMethodMultiUC); snippetTabPageSubseqActIfStmt.SetCodelet("TABCONTROLNAMEWITHOUTPREFIX", CntrlNameWithoutPrefix); snippetTabPageSubseqActIfStmt.SetCodelet("USERCONTROLNAMEWITHOUTPREFIX", CntrlVaribleNameWithoutPrefix); snippetTabPageSubseqAct.SetCodelet("CONTROLNAME", ctrl.controlName); snippetTabPageSubseqAct.SetCodelet("CONTROLNAMEWITHOUTPREFIX", CntrlVaribleNameWithoutPrefix); snippetTabPageSubseqActIfStmt.InsertSnippet("MULTIUCCODE", snippetTabPageSubseqAct); snippetUserControlInitialisation.InsertSnippet("DYNAMICTABPAGESUBSEQUENTACTIVATION", snippetTabPageSubseqActIfStmt); if (Counter + 2 == DynamicControlTypes.Count) { writer.Template.InsertSnippet("DYNAMICTABPAGEUSERCONTROLSETUPMETHODS", snippetUserControlSetupMethod); snippetUserControlInitialisation.AddToCodelet("DYNAMICTABPAGEUSERCONTROLSETUPINLINE1", "SetupVariableUserControlForTabPage" + CntrlNameWithoutPrefix + "();" + Environment.NewLine); writer.Template.InsertSnippet("DYNAMICTABPAGEUSERCONTROLINITIALISATION", snippetUserControlInitialisation); } snippetUserControlLoading.SetCodelet("CONTROLNAMEWITHOUTPREFIX", CntrlVaribleNameWithoutPrefix); } } else { snippetUserControlInitialisation.SetCodelet("TABKEY", "TDynamicLoadableUserControls.dluc" + CntrlNameWithoutPrefix + ")"); snippetUserControlSetup.SetCodelet("CONTROLNAMEWITHOUTPREFIX", CntrlNameWithoutPrefix); snippetUserControlInitialisation.InsertSnippet("DYNAMICTABPAGEUSERCONTROLSETUPINLINE1", snippetUserControlSetup); snippetTabPageSubseqAct.SetCodelet("CONTROLNAME", ctrl.controlName); snippetTabPageSubseqAct.SetCodelet("CONTROLNAMEWITHOUTPREFIX", CntrlNameWithoutPrefix); snippetUserControlInitialisation.InsertSnippet("DYNAMICTABPAGESUBSEQUENTACTIVATION", snippetTabPageSubseqAct); writer.Template.InsertSnippet("DYNAMICTABPAGEUSERCONTROLINITIALISATION", snippetUserControlInitialisation); snippetUserControlLoading.SetCodelet("CONTROLNAMEWITHOUTPREFIX", CntrlNameWithoutPrefix); } // Dynamically load each dynamically loaded TabPage snippetUserControlLoading.SetCodelet("CONTROLNAME", ctrl.controlName); snippetUserControlLoading.SetCodelet("DYNAMICCONTROLTYPE", DynamicControlTypes[Counter]); writer.Template.InsertSnippet("DYNAMICTABPAGEUSERCONTROLLOADING", snippetUserControlLoading); } } #endregion return writer.FTemplate; }
/// <summary> /// generate the children /// </summary> public override void ProcessChildren(TFormWriter writer, TControlDef ctrl) { base.ProcessChildren(writer, ctrl); XmlNode controlsNode = TXMLParser.GetChild(ctrl.xmlNode, "Controls"); if ((controlsNode != null) && TYml2Xml.GetChildren(controlsNode, true)[0].Name.StartsWith("Row")) { // this defines the layout with several rows with several controls per row Int32 countRow = 0; foreach (XmlNode row in TYml2Xml.GetChildren(controlsNode, true)) { StringCollection controls = TYml2Xml.GetElements(row); foreach (string ctrlname in controls) { TControlDef childCtrl = writer.CodeStorage.GetControl(ctrlname); if (ctrlname.StartsWith("Empty")) { childCtrl = writer.CodeStorage.FindOrCreateControl("pnlEmpty", ctrl.controlName); } if (childCtrl == null) { throw new Exception("cannot find control with name " + ctrlname + "; it belongs to " + ctrl.controlName); } // add control itself ctrl.Children.Add(childCtrl); childCtrl.parentName = ctrl.controlName; IControlGenerator ctrlGenerator = writer.FindControlGenerator(childCtrl); ctrlGenerator.GenerateControl(writer, childCtrl); childCtrl.rowNumber = countRow; } countRow++; } } else { if ((controlsNode != null) && (ctrl.Children.Count == 0)) { StringCollection controlNamesCollection = TYml2Xml.GetElements(TXMLParser.GetChild(ctrl.xmlNode, "Controls")); foreach (string childCtrlName in controlNamesCollection) { TControlDef childCtrl = writer.CodeStorage.GetControl(childCtrlName); if (childCtrlName.StartsWith("Empty")) { childCtrl = writer.CodeStorage.FindOrCreateControl("pnlEmpty", ctrl.controlName); } if (childCtrl == null) { throw new Exception("cannot find control with name " + childCtrlName + "; it belongs to " + ctrl.controlName); } childCtrl.parentName = ctrl.controlName; ctrl.Children.Add(childCtrl); } } foreach (TControlDef childCtrl in ctrl.Children) { TLogging.LogAtLevel(1, "foreach (TControlDef childCtrl in ctrl.Children) -- Control: " + childCtrl.controlName); if (!childCtrl.controlName.StartsWith("pnlEmpty")) { // process the control itself IControlGenerator ctrlGenerator = writer.FindControlGenerator(childCtrl); ctrlGenerator.GenerateControl(writer, childCtrl); } } } bool hasDockingChildren = false; // don't use a tablelayout for controls where all children have the Dock property set foreach (TControlDef ChildControl in ctrl.Children) { if (!ChildControl.HasAttribute("Dock")) { ctrl.SetAttribute("UseTableLayout", "true"); } else { hasDockingChildren = true; } } if (ctrl.GetAttribute("UseTableLayout") == "true") { // show a warning if there are some controls with Docking, and some without if (hasDockingChildren) { StringCollection clearDockAttributeChildren = new StringCollection(); foreach (TControlDef ChildControl in ctrl.Children) { if ((ChildControl.HasAttribute("Dock")) && ((!ChildControl.IsHorizontalGridButtonPanelStrict) && (ChildControl.controlName != TControlDef.STR_GRID_DETAILS_NAME))) { ChildControl.ClearAttribute("Dock"); clearDockAttributeChildren.Add(ChildControl.controlName); } } if (clearDockAttributeChildren.Count > 0) { TLogging.Log("Warning: please remove the Dock attribute from control(s) " + StringHelper.StrMerge(clearDockAttributeChildren, ',')); } } if (ctrl.GetAttribute("Margin") == "0") { if (!ctrl.HasAttribute("MarginTop")) { ctrl.SetAttribute("MarginTop", "0"); ctrl.SetAttribute("MarginBottom", "0"); ctrl.SetAttribute("MarginLeft", "0"); } } PanelLayoutGenerator TlpGenerator = new PanelLayoutGenerator(); TlpGenerator.SetOrientation(ctrl); TlpGenerator.CreateLayout(writer, ctrl, null, -1, -1); foreach (TControlDef ChildControl in ctrl.Children) { TlpGenerator.InsertControl(writer, ChildControl); } TlpGenerator.WriteTableLayout(writer, ctrl); if (ctrl.GetAttribute("Dock", "None") != "None") { writer.SetControlProperty(ctrl.controlName, "Dock", ctrl.GetAttribute("Dock"), false); // groupboxes do not have AutoScroll property (grp, rgr) if ((this.FPrefix == "pnl") || (this.FPrefix == "tab") || (this.FPrefix == "rng")) { writer.SetControlProperty(ctrl.controlName, "AutoScroll", "true", false); } } } return; }
/// <summary>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; }
private void ProcessButtonsForMaxWidthSizing(TFormWriter writer, TControlDef ctrl, SortedSet <int>ButtonWidths, SortedSet <int>ButtonTops, List <TControlDef>Buttons, out int NewButtonWidthForAll) { const int MIN_BUTTON_WIDTH = 76; // 76 seems to be pretty much a standard width (on the Windows OS) int LeftPos = PanelLayoutGenerator.MARGIN_LEFT; int ButtonCounter = 0; bool EnforceMinimumWidth = false; bool RepositionButtonsHorizontally = ButtonTops.Max == ButtonTops.Min; NewButtonWidthForAll = MIN_BUTTON_WIDTH; TLogging.LogAtLevel(1, "Max. Button Width: " + ButtonWidths.Max.ToString() + ", Number of Buttons: " + Buttons.Count.ToString()); if ((!ctrl.HasAttribute("AutoButtonMaxWidthsEnforceMinimumWidth") || (ctrl.GetAttribute("AutoButtonMaxWidthsEnforceMinimumWidth").ToLower() == "true"))) { EnforceMinimumWidth = true; } if ((EnforceMinimumWidth) && (ButtonWidths.Max < MIN_BUTTON_WIDTH)) { if (Buttons.Count > 0) { NewButtonWidthForAll = MIN_BUTTON_WIDTH; TLogging.LogAtLevel(1, "Max. Button width (" + ButtonWidths.Max.ToString() + ") was smaller than MIN_BUTTON_WIDTH, adjusting to the latter!"); } } else { NewButtonWidthForAll = ButtonWidths.Max; } foreach (var Button in Buttons) { // TLogging.LogAtLevel(1, "Button ' " + Button.controlName + "': Width = " + Button.GetAttribute("Width")); if ((!Button.HasAttribute("NoLabel") || (Button.GetAttribute("NoLabel").ToLower() == "false"))) { TLogging.LogAtLevel(1, "Applying Width to Button '" + Button.controlName + "'"); writer.SetControlProperty(Button, "Size", "new System.Drawing.Size(" + NewButtonWidthForAll.ToString() + ", " + Button.GetAttribute("Height").ToString() + ")"); if (ButtonCounter != 0) { LeftPos += NewButtonWidthForAll + PanelLayoutGenerator.HORIZONTAL_SPACE; } } else { TLogging.LogAtLevel( 1, "Not applying Width to Button '" + Button.controlName + "' as its 'NoLabel' Element is set to 'true'! (Current Width: " + Button.Width.ToString() + ")"); if (ButtonCounter != 0) { LeftPos += Button.Width + PanelLayoutGenerator.HORIZONTAL_SPACE; } } if (RepositionButtonsHorizontally) { writer.SetControlProperty(Button, "Location", String.Format("new System.Drawing.Point({0}, {1})", LeftPos, ButtonTops.Max)); TLogging.LogAtLevel(1, "Repositioned Button '" + Button.controlName + "' horizontally. New Location: " + LeftPos.ToString() + "," + ButtonTops.Max.ToString()); } // TLogging.LogAtLevel(1, "Button '" + Button.controlName + "' Width: " + Button.Width.ToString()); ButtonCounter++; } }
/// <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; }
/// <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 (!FManualExtendedPanel) { writer.SetControlProperty(ctrl, "ShadowOffSet", "0"); writer.SetControlProperty(ctrl, "RoundCornerRadius", "0"); writer.SetControlProperty(ctrl, "GradientStartColor", "System.Drawing.Color.AntiqueWhite"); writer.SetControlProperty(ctrl, "GradientEndColor", "System.Drawing.Color.LightGray"); writer.SetControlProperty(ctrl, "GradientDirection", "System.Drawing.Drawing2D.LinearGradientMode.Vertical"); } else { if (ctrl.HasAttribute("ShadowOffSet")) { writer.SetControlProperty(ctrl, "ShadowOffSet", ctrl.GetAttribute("ShadowOffSet")); } else { writer.SetControlProperty(ctrl, "ShadowOffSet", "0"); } if (ctrl.HasAttribute("RoundCornerRadius")) { writer.SetControlProperty(ctrl, "RoundCornerRadius", ctrl.GetAttribute("RoundCornerRadius")); } else { writer.SetControlProperty(ctrl, "RoundCornerRadius", "0"); } if (ctrl.HasAttribute("GradientDirection")) { writer.SetControlProperty(ctrl, "GradientDirection", ctrl.GetAttribute("GradientDirection")); } else { writer.SetControlProperty(ctrl, "GradientDirection", "System.Drawing.Drawing2D.LinearGradientMode.Horizontal"); } if (ctrl.HasAttribute("GradientStartColor")) { writer.SetControlProperty(ctrl, "GradientStartColor", ctrl.GetAttribute("GradientStartColor")); } else { writer.SetControlProperty(ctrl, "GradientStartColor", "System.Drawing.Color.Yellow"); } if (ctrl.HasAttribute("GradientEndColor")) { writer.SetControlProperty(ctrl, "GradientEndColor", ctrl.GetAttribute("GradientEndColor")); } else { writer.SetControlProperty(ctrl, "GradientEndColor", "System.Drawing.Color.Green"); } if (ctrl.HasAttribute("BorderColor")) { writer.SetControlProperty(ctrl, "BorderColor", ctrl.GetAttribute("BorderColor")); } if (ctrl.HasAttribute("BorderWidth")) { writer.SetControlProperty(ctrl, "BorderWidth", ctrl.GetAttribute("BorderWidth")); } } 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.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> /// 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); }
/// <summary> /// Handle 'special' Panels /// </summary> public override void ProcessChildren(TFormWriter writer, TControlDef ctrl) { if (ctrl.IsHorizontalGridButtonPanelStrict) { writer.Template.SetCodelet("BUTTONPANEL", "true"); XmlNode controlsNode = TXMLParser.GetChild(ctrl.xmlNode, "Controls"); TControlDef pnlButtonsInner = writer.CodeStorage.FindOrCreateControl("pnlButtonsInner", ctrl.controlName); if ((controlsNode != null) && (ctrl.Children.Count == 0)) { StringCollection controlNamesCollection = TYml2Xml.GetElements(TXMLParser.GetChild(ctrl.xmlNode, "Controls")); foreach (string childCtrlName in controlNamesCollection) { if (childCtrlName != "pnlButtonsInner") { TControlDef childCtrl = writer.CodeStorage.GetControl(childCtrlName); TLogging.LogAtLevel(1, "Iteration 0: Child: '" + childCtrl.controlName + "'"); pnlButtonsInner.Children.Add(childCtrl); childCtrl.SetAttribute("Top", "3"); childCtrl.parentName = pnlButtonsInner.controlName; } } } pnlButtonsInner.SetAttribute("Dock", "Fill"); pnlButtonsInner.SetAttribute("ControlsOrientation", "horizontal"); pnlButtonsInner.SetAttribute("AutoScroll", "false"); pnlButtonsInner.SetAttribute("BackColor", "System.Drawing.Color.Transparent"); ctrl.Children.Add(pnlButtonsInner); TControlDef pnlButtonsRecordCounter = writer.CodeStorage.FindOrCreateControl("pnlButtonsRecordCounter", ctrl.controlName); pnlButtonsRecordCounter.SetAttribute("AutoSize", "true"); pnlButtonsRecordCounter.SetAttribute("Padding", "0, 4, 5, 2"); pnlButtonsRecordCounter.SetAttribute("Dock", "Right"); pnlButtonsRecordCounter.SetAttribute("BackColor", "System.Drawing.Color.Transparent"); TControlDef lblRecordCounter = writer.CodeStorage.FindOrCreateControl("lblRecordCounter", pnlButtonsRecordCounter.controlName); lblRecordCounter.SetAttribute("AutoSize", "true"); lblRecordCounter.SetAttribute("Text", "n records"); lblRecordCounter.SetAttribute("Dock", "Fill"); if ((ctrl.HasAttribute("ShowRecordCounter")) && (ctrl.GetAttribute("ShowRecordCounter").ToLower() == "false")) { lblRecordCounter.SetAttribute("Visible", "false"); } pnlButtonsRecordCounter.Children.Add(lblRecordCounter); if (writer.CodeStorage.GetControl(PanelGenerator.PNL_FILTER_AND_FIND) != null) { TControlDef chkToggleFilter = writer.CodeStorage.FindOrCreateControl("chkToggleFilter", pnlButtonsRecordCounter.controlName); chkToggleFilter.SetAttribute("Height", "22"); chkToggleFilter.SetAttribute("Dock", "Left"); chkToggleFilter.SetAttribute("Height", "22"); chkToggleFilter.SetAttribute("Tag", "SuppressChangeDetection"); pnlButtonsRecordCounter.Children.Add(chkToggleFilter); } ctrl.Children.Add(pnlButtonsRecordCounter); base.ProcessChildren(writer, ctrl); } else { base.ProcessChildren(writer, ctrl); } }
/// <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 ? "Decimal" : 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> /// 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>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) { 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; }
/// <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) { writer.AddContainer(ctrl.controlName + ".Panel1"); writer.AddContainer(ctrl.controlName + ".Panel2"); base.SetControlProperties(writer, ctrl); if (ctrl.HasAttribute("SplitterDistance")) { writer.SetControlProperty(ctrl, "SplitterDistance"); } if (ctrl.HasAttribute("SplitterOrientation")) { writer.SetControlProperty(ctrl, "Orientation", "System.Windows.Forms.Orientation." + StringHelper.UpperCamelCase(ctrl.GetAttribute("SplitterOrientation"))); } return writer.FTemplate; }
/// <summary>add GeneratedReadSetControls, and all dependent controls</summary> public override void ApplyDerivedFunctionality(TFormWriter writer, TControlDef control) { string paramName = ReportControls.GetParameterName(control.xmlNode); if (paramName == null) { return; } StringCollection Controls = TYml2Xml.GetElements(TXMLParser.GetChild(control.xmlNode, "Controls")); foreach (string controlName in Controls) { TControlDef rbtCtrl = writer.CodeStorage.GetControl(controlName); string rbtValue = rbtCtrl.Label; rbtValue = StringHelper.UpperCamelCase(rbtValue.Replace("'", "").Replace(" ", "_"), false, false); if (rbtCtrl.HasAttribute("ParameterValue")) { rbtValue = rbtCtrl.GetAttribute("ParameterValue"); } string rbtName = "rbt" + controlName.Substring(3); if (controlName.StartsWith("layoutPanel")) { // the table layouts of sub controls for each radio button need to be skipped continue; } ProcessTemplate RadioButtonReadControlsSnippet = writer.Template.GetSnippet("RADIOBUTTONREADCONTROLS"); RadioButtonReadControlsSnippet.SetCodelet("RBTNAME", rbtName); RadioButtonReadControlsSnippet.SetCodelet("PARAMNAME", paramName); RadioButtonReadControlsSnippet.SetCodelet("RBTVALUE", rbtValue); RadioButtonReadControlsSnippet.SetCodelet("READCONTROLS", ""); XmlNode childControls = TXMLParser.GetChild(rbtCtrl.xmlNode, "Controls"); // only assign variables that make sense if (childControls != null) { StringCollection childControlNames = TYml2Xml.GetElements(childControls); foreach (string childName in childControlNames) { if (childName.StartsWith("layoutPanel")) { continue; } TControlDef childCtrl = writer.CodeStorage.GetControl(childName); IControlGenerator generator = writer.FindControlGenerator(childCtrl); // make sure we ignore Button etc if (generator.GetType().ToString().EndsWith("ReportGenerator")) { childCtrl.SetAttribute("DependsOnRadioButton", ""); ReportControls.GenerateReadSetControls(writer, childCtrl.xmlNode, RadioButtonReadControlsSnippet, generator.TemplateSnippetName); childCtrl.SetAttribute("DependsOnRadioButton", "true"); } } } writer.Template.InsertSnippet("READCONTROLS", RadioButtonReadControlsSnippet); ProcessTemplate RadioButtonSetControlsSnippet = writer.Template.GetSnippet("RADIOBUTTONSETCONTROLS"); RadioButtonSetControlsSnippet.SetCodelet("RBTNAME", rbtName); RadioButtonSetControlsSnippet.SetCodelet("PARAMNAME", paramName); RadioButtonSetControlsSnippet.SetCodelet("RBTVALUE", rbtValue); // only assign variables that make sense if (childControls != null) { StringCollection childControlNames = TYml2Xml.GetElements(childControls); foreach (string childName in childControlNames) { if (childName.StartsWith("layoutPanel")) { continue; } TControlDef childCtrl = writer.CodeStorage.GetControl(childName); IControlGenerator generator = writer.FindControlGenerator(childCtrl); // make sure we ignore Button etc if (generator.GetType().ToString().EndsWith("ReportGenerator")) { childCtrl.SetAttribute("DependsOnRadioButton", ""); ReportControls.GenerateReadSetControls(writer, childCtrl.xmlNode, RadioButtonSetControlsSnippet, generator.TemplateSnippetName); childCtrl.SetAttribute("DependsOnRadioButton", "true"); } } } writer.Template.InsertSnippet("SETCONTROLS", RadioButtonSetControlsSnippet); } }
/// <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; }
/// <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; }
/// <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; }
/// <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; }
/// <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; }
/// <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; } } } } }
/// <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; }
/// <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; }
/// <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); }
/// <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; }