本文整理汇总了C#中Ict.Tools.CodeGeneration.TFormWriter.FindControlGenerator方法的典型用法代码示例。如果您正苦于以下问题:C# TFormWriter.FindControlGenerator方法的具体用法?C# TFormWriter.FindControlGenerator怎么用?C# TFormWriter.FindControlGenerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ict.Tools.CodeGeneration.TFormWriter
的用法示例。
在下文中一共展示了TFormWriter.FindControlGenerator方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetControlProperties
/// <summary>write the code for the designer file where the properties of the control are written</summary>
public override ProcessTemplate SetControlProperties(TFormWriter writer, TControlDef ctrl)
{
ProcessTemplate snippetRowDefinition = writer.FTemplate.GetSnippet(FControlDefinitionSnippetName);
((TExtJsFormsWriter)writer).AddResourceString(snippetRowDefinition, "LABEL", ctrl, ctrl.Label);
StringCollection Controls = FindContainedControls(writer, ctrl.xmlNode);
snippetRowDefinition.AddToCodelet("ITEMS", "");
if (Controls.Count > 0)
{
// used for radiogroupbox
foreach (string ChildControlName in Controls)
{
TControlDef childCtrl = FCodeStorage.FindOrCreateControl(ChildControlName, ctrl.controlName);
IControlGenerator ctrlGen = writer.FindControlGenerator(childCtrl);
ProcessTemplate ctrlSnippet = ctrlGen.SetControlProperties(writer, childCtrl);
ctrlSnippet.SetCodelet("COLUMNWIDTH", "");
ctrlSnippet.SetCodelet("ITEMNAME", ctrl.controlName);
ctrlSnippet.SetCodelet("ITEMID", childCtrl.controlName);
if (ctrl.GetAttribute("hideLabel") == "true")
{
ctrlSnippet.SetCodelet("HIDELABEL", "true");
}
else if (ChildControlName == Controls[0])
{
((TExtJsFormsWriter)writer).AddResourceString(ctrlSnippet, "LABEL", ctrl, ctrl.Label);
}
snippetRowDefinition.InsertSnippet("ITEMS", ctrlSnippet, ",");
}
}
else
{
// used for GroupBox, and Composite
TExtJsFormsWriter.InsertControl(ctrl, snippetRowDefinition, "ITEMS", "HiddenValues", writer);
TExtJsFormsWriter.InsertControl(ctrl, snippetRowDefinition, "ITEMS", "Controls", writer);
}
return snippetRowDefinition;
}
示例2: ProcessChildren
/// <summary>
/// generate the children, and write the size of this control
/// </summary>
public override void ProcessChildren(TFormWriter writer, TControlDef ctrl)
{
XmlNode Controls = TXMLParser.GetChild(ctrl.xmlNode, "Controls");
if (Controls != null)
{
StringCollection childControls = TYml2Xml.GetElements(Controls);
// this is a checkbox that enables another control or a group of controls
ctrl.SetAttribute("GenerateWithOtherControls", "yes");
if (childControls.Count == 1)
{
TControlDef ChildCtrl = ctrl.FCodeStorage.GetControl(childControls[0]);
ChildCtrl.parentName = ctrl.controlName;
ctrl.Children.Add(ChildCtrl);
ChildCtrl.SetAttribute("DependsOnRadioButton", "true");
// use the label of the child control
if (ChildCtrl.HasAttribute("Label"))
{
ctrl.Label = ChildCtrl.Label;
}
}
else
{
foreach (string child in childControls)
{
TControlDef ChildCtrl = ctrl.FCodeStorage.GetControl(child);
if (ChildCtrl == null)
{
throw new Exception("cannot find control " + child + " which should belong to " + ctrl.controlName);
}
ChildCtrl.parentName = ctrl.controlName;
ctrl.Children.Add(ChildCtrl);
ChildCtrl.SetAttribute("DependsOnRadioButton", "true");
IControlGenerator ctrlGenerator = writer.FindControlGenerator(ChildCtrl);
ctrlGenerator.GenerateControl(writer, ChildCtrl);
}
}
}
}
示例3: InsertControl
/// <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);
//.........这里部分代码省略.........
示例4: ProcessChildren
/// <summary>
/// process the children
/// </summary>
public override void ProcessChildren(TFormWriter writer, TControlDef container)
{
// usually, the toolbar buttons are direct children of the toolbar control
List <XmlNode>childrenlist = TYml2Xml.GetChildren(container.xmlNode, true);
foreach (XmlNode childNode in childrenlist)
{
/* Get unique name if we need it
* at the moment we need it only for menu separators
*/
String UniqueChildName = childNode.Name;
TControlDef childCtrl = container.FCodeStorage.GetControl(childNode.Name);
if (childCtrl == null)
{
UniqueChildName = TYml2Xml.GetAttribute(childNode, "UniqueName");
childCtrl = container.FCodeStorage.GetControl(UniqueChildName);
}
container.Children.Add(childCtrl);
IControlGenerator ctrlGenerator = writer.FindControlGenerator(childCtrl);
ctrlGenerator.GenerateControl(writer, childCtrl);
}
}
示例5: SetControlProperties
/// <summary>write the code for the designer file where the properties of the control are written</summary>
public override ProcessTemplate SetControlProperties(TFormWriter writer, TControlDef ctrl)
{
// first create the hosted control
string hostedControlName = TYml2Xml.GetAttribute(ctrl.xmlNode, "HostedControl");
TControlDef hostedCtrl = FCodeStorage.FindOrCreateControl(hostedControlName, ctrl.controlName);
IControlGenerator ctrlGenerator = writer.FindControlGenerator(hostedCtrl);
// add control itself
if ((hostedCtrl != null) && (ctrlGenerator != null))
{
ctrlGenerator.SetControlProperties(writer, hostedCtrl);
}
return base.SetControlProperties(writer, ctrl);
}
示例6: GenerateDeclaration
/// <summary>
/// declare the control
/// </summary>
public override void GenerateDeclaration(TFormWriter writer, TControlDef ctrl)
{
string hostedControlName = TYml2Xml.GetAttribute(ctrl.xmlNode, "HostedControl");
TControlDef hostedCtrl = FCodeStorage.FindOrCreateControl(hostedControlName, ctrl.controlName);
IControlGenerator ctrlGenerator = writer.FindControlGenerator(hostedCtrl);
// add control itself
if ((hostedCtrl != null) && (ctrlGenerator != null))
{
ctrlGenerator.GenerateDeclaration(writer, hostedCtrl);
}
string localControlType = ControlType;
if (ctrl.controlType.Length > 0)
{
localControlType = ctrl.controlType;
}
writer.Template.AddToCodelet("CONTROLDECLARATION", "private " + localControlType + " " + ctrl.controlName + ";" +
Environment.NewLine);
writer.Template.AddToCodelet("CONTROLCREATION", "this." + ctrl.controlName + " = new " + localControlType + "(" +
TYml2Xml.GetAttribute(ctrl.xmlNode, "HostedControl") + ");" + Environment.NewLine);
}
示例7: InsertButtons
/// <summary>
/// insert the buttons for the form, eg. submit button, cancel button, etc
/// </summary>
/// <param name="ACtrl"></param>
/// <param name="ATemplate"></param>
/// <param name="AItemsPlaceholder"></param>
/// <param name="AWriter"></param>
public static void InsertButtons(TControlDef ACtrl, ProcessTemplate ATemplate, string AItemsPlaceholder, TFormWriter AWriter)
{
StringCollection children = TYml2Xml.GetElements(ACtrl.xmlNode, "Buttons");
foreach (string child in children)
{
TControlDef childCtrl = AWriter.FCodeStorage.FindOrCreateControl(child, ACtrl.controlName);
IControlGenerator ctrlGen = AWriter.FindControlGenerator(childCtrl);
ProcessTemplate ctrlSnippet = ctrlGen.SetControlProperties(AWriter, childCtrl);
ProcessTemplate snippetCellDefinition = AWriter.FTemplate.GetSnippet("CELLDEFINITION");
LayoutCellInForm(childCtrl, -1, ctrlSnippet, snippetCellDefinition);
ATemplate.InsertSnippet(AItemsPlaceholder, ctrlSnippet, ",");
}
}
示例8: InsertControl
/// <summary>
/// main function for creating a control
/// </summary>
/// <param name="ACtrl"></param>
/// <param name="ATemplate"></param>
/// <param name="AItemsPlaceholder"></param>
/// <param name="ANodeName"></param>
/// <param name="AWriter"></param>
public static void InsertControl(TControlDef ACtrl,
ProcessTemplate ATemplate,
string AItemsPlaceholder,
string ANodeName,
TFormWriter AWriter)
{
XmlNode controlsNode = TXMLParser.GetChild(ACtrl.xmlNode, ANodeName);
List <XmlNode>childNodes = TYml2Xml.GetChildren(controlsNode, true);
if ((childNodes.Count > 0) && childNodes[0].Name.StartsWith("Row"))
{
foreach (XmlNode row in TYml2Xml.GetChildren(controlsNode, true))
{
ProcessTemplate snippetRowDefinition = AWriter.FTemplate.GetSnippet("ROWDEFINITION");
StringCollection children = TYml2Xml.GetElements(controlsNode, row.Name);
foreach (string child in children)
{
TControlDef childCtrl = AWriter.FCodeStorage.FindOrCreateControl(child, ACtrl.controlName);
IControlGenerator ctrlGen = AWriter.FindControlGenerator(childCtrl);
ProcessTemplate ctrlSnippet = ctrlGen.SetControlProperties(AWriter, childCtrl);
ProcessTemplate snippetCellDefinition = AWriter.FTemplate.GetSnippet("CELLDEFINITION");
LayoutCellInForm(childCtrl, children.Count, ctrlSnippet, snippetCellDefinition);
if ((children.Count == 1) && ctrlGen is RadioGroupSimpleGenerator)
{
// do not use the ROWDEFINITION, but insert control directly
// this helps with aligning the label for the group radio buttons
snippetRowDefinition.InsertSnippet("ITEMS", ctrlSnippet, ",");
}
else
{
snippetCellDefinition.InsertSnippet("ITEM", ctrlSnippet);
snippetRowDefinition.InsertSnippet("ITEMS", snippetCellDefinition, ",");
}
}
ATemplate.InsertSnippet(AItemsPlaceholder, snippetRowDefinition, ",");
}
}
else
{
foreach (XmlNode childNode in childNodes)
{
string child = TYml2Xml.GetElementName(childNode);
TControlDef childCtrl = AWriter.FCodeStorage.FindOrCreateControl(child, ACtrl.controlName);
if ((ANodeName != "HiddenValues") && (childCtrl.controlTypePrefix == "hid"))
{
// somehow, hidden values get into the controls list as well. we don't want them there
continue;
}
IControlGenerator ctrlGen = AWriter.FindControlGenerator(childCtrl);
if (ctrlGen is FieldSetGenerator)
{
InsertControl(AWriter.FCodeStorage.FindOrCreateControl(child,
ACtrl.controlName), ATemplate, AItemsPlaceholder, ANodeName, AWriter);
}
else
{
ProcessTemplate ctrlSnippet = ctrlGen.SetControlProperties(AWriter, childCtrl);
ProcessTemplate snippetCellDefinition = AWriter.FTemplate.GetSnippet("CELLDEFINITION");
LayoutCellInForm(childCtrl, -1, ctrlSnippet, snippetCellDefinition);
ATemplate.InsertSnippet(AItemsPlaceholder, ctrlSnippet, ",");
}
}
}
}
示例9: ProcessChildren
/// <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")
//.........这里部分代码省略.........
示例10: ApplyDerivedFunctionality
/// <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");
}
//.........这里部分代码省略.........