本文整理汇总了C#中TControlDef.SetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# TControlDef.SetAttribute方法的具体用法?C# TControlDef.SetAttribute怎么用?C# TControlDef.SetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TControlDef
的用法示例。
在下文中一共展示了TControlDef.SetAttribute方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetControlProperties
//.........这里部分代码省略.........
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"))
{
示例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)
{
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
//.........这里部分代码省略.........
示例3: 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);
}
}
}
}
示例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 container)
{
container.SetAttribute("Dock", FDocking);
base.SetControlProperties(writer, container);
// todo: location?
// todo: event handler
/*
* this.menuStrip1.Dock = System.Windows.Forms.DockStyle.None;
* this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
* this.toolStripMenuItem1});
* this.menuStrip1.Location = new System.Drawing.Point(0, 0);
* this.menuStrip1.Name = "menuStrip1";
* this.menuStrip1.Size = new System.Drawing.Size(138, 24);
* this.menuStrip1.TabIndex = 1;
* this.menuStrip1.Text = "menuStrip1";
* this.menuStrip1.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.MenuStrip1ItemClicked);
*/
return writer.FTemplate;
}
示例5: WriteTableLayout
//.........这里部分代码省略.........
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;
}
}
}
}
}
示例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)
{
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;
}
示例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)
{
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;
}
示例8: 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")
//.........这里部分代码省略.........
示例9: 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)
{
// 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;
}