本文整理汇总了C#中Ict.Tools.CodeGeneration.TFormWriter.SetControlProperty方法的典型用法代码示例。如果您正苦于以下问题:C# TFormWriter.SetControlProperty方法的具体用法?C# TFormWriter.SetControlProperty怎么用?C# TFormWriter.SetControlProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ict.Tools.CodeGeneration.TFormWriter
的用法示例。
在下文中一共展示了TFormWriter.SetControlProperty方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
{
base.SetControlProperties(writer, ctrl);
if (ctrl.GetAttribute("AutoComplete").EndsWith("History"))
{
writer.SetControlProperty(ctrl, "AcceptNewValues", "true");
writer.SetEventHandlerToControl(ctrl.controlName,
"AcceptNewEntries",
"TAcceptNewEntryEventHandler",
"FPetraUtilsObject.AddComboBoxHistory");
writer.CallControlFunction(ctrl.controlName, "SetDataSourceStringList(\"\")");
writer.Template.AddToCodelet("INITUSERCONTROLS",
"FPetraUtilsObject.LoadComboBoxHistory(" + ctrl.controlName + ");" + Environment.NewLine);
}
return writer.FTemplate;
}
示例2: 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)
{
// Support NoLabel=true
FGenerateLabel = true;
if (GenerateLabel(ctrl))
{
writer.SetControlProperty(ctrl, "Text", "\"" + ctrl.Label + "\"");
ctrl.SetAttribute("Width", (PanelLayoutGenerator.MeasureTextWidth(ctrl.Label) + 30).ToString());
}
else
{
ctrl.SetAttribute("Width", "15");
}
base.SetControlProperties(writer, ctrl);
FGenerateLabel = false;
if (TYml2Xml.HasAttribute(ctrl.xmlNode, "RadioChecked"))
{
writer.SetControlProperty(ctrl,
"Checked",
TYml2Xml.GetAttribute(ctrl.xmlNode, "RadioChecked"));
}
return writer.FTemplate;
}
示例3: SetControlActionProperties
/// <summary>
/// Sets the properties of a control which are defined under "Actions:" in the .yaml file
/// </summary>
/// <param name="writer"></param>
/// <param name="ctrl"></param>
/// <param name="AActionHandler"></param>
public virtual void SetControlActionProperties(TFormWriter writer, TControlDef ctrl, TActionHandler AActionHandler)
{
if (AActionHandler.actionImage.Length > 0)
{
/* Get the name of the image for the toolbar button
* and put it into the resources.
* The images must be in the directory specified by the ResourceDir command line parameter
*/
writer.SetControlProperty(ctrl, "Image",
"((System.Drawing.Bitmap)resources" + ctrl.controlType + ".GetObject(\"" + ctrl.controlName + ".Glyph\"))");
writer.AddImageToResource(ctrl.controlName, AActionHandler.actionImage, "Bitmap");
}
if ((AActionHandler.actionTooltip.Length > 0) && (ctrl.controlTypePrefix != "btn"))
{
writer.SetControlProperty(ctrl, "ToolTipText", "\"" + AActionHandler.actionTooltip + "\"");
}
}
示例4: 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)
{
base.SetControlProperties(writer, ctrl);
writer.SetControlProperty(ctrl, "Text", "\"" + ctrl.Label + "\"");
return writer.FTemplate;
}
示例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)
{
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;
}
示例6: 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)
{
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;
}
示例7: 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)
{
string Width;
base.SetControlProperties(writer, ctrl);
if (ctrl.GetAttribute("Height").ToString() == "36") // 36 is the Height of pnlButtons/pnlDetailButtons Panels that have ControlsOrientation=horizontal and whose Buttons have been shrinked in size to 23 Pixels by the ButtonGenerator - and
{ // whose 'Height' Element hasn't been set in the YAML file...
if (ctrl.IsGridButtonPanel)
{
Width = ctrl.GetAttribute("Width").ToString();
// Somehow we can run into a situation where Width isn't specified. This would lead to writing out an
// invalid Size Property. To prevent that we set it to some value which we can find easily in files and
// which will be ignored anyway at runtime as the Panel will be Docked with 'DockStyle.Bottom'!
if (Width.Length == 0)
{
Width = "1111";
}
FDefaultHeight = 28;
TLogging.LogAtLevel(1, "Adjusted Height of Panel '" + ctrl.controlName + "' as it is a horizontal Grid Button Panel");
writer.SetControlProperty(ctrl, "Size", "new System.Drawing.Size(" +
Width + ", " + FDefaultHeight.ToString() + ")");
writer.SetControlProperty(ctrl, "BackColor", "System.Drawing.Color.Green");
}
}
return writer.FTemplate;
}
示例8: ProcessButtonsForMaxWidthSizing
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++;
}
}
示例9: ProcessChildren
/// <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", "");
//.........这里部分代码省略.........
示例10: WriteTableLayout
//.........这里部分代码省略.........
// 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)
示例11: SetControlProperties
/// <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",
//.........这里部分代码省略.........