本文整理汇总了C#中Record.EnumerateElements方法的典型用法代码示例。如果您正苦于以下问题:C# Record.EnumerateElements方法的具体用法?C# Record.EnumerateElements怎么用?C# Record.EnumerateElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record.EnumerateElements方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetContext
public void SetContext(Record r, SubRecord sr, bool hexView)
{
if (this.r == r && this.sr == sr && this.hexView == hexView)
return;
if (r == null || sr == null)
{
ClearControl();
return;
}
// walk each element in standard fashion
int panelOffset = 0;
try
{
BeginUpdate();
ClearControl();
SuspendLayout();
fpanel1.SuspendLayout();
fpanel1.Width = Parent.Width;
controlMap.Clear();
this.hexView = hexView;
this.r = r;
this.sr = sr;
var p = GetPluginFromNode(r);
ss = sr.Structure;
// default to blob if no elements
if (ss == null || ss.elements == null || hexView)
{
var c = new HexElement();
c.Left = 8;
c.Width = fpanel1.Width - 16;
c.Top = panelOffset;
c.Anchor = c.Anchor | AnchorStyles.Left | AnchorStyles.Right;
var elem = r.EnumerateElements(sr, true).FirstOrDefault();
if (elem != null)
{
controlMap.Add(elem.Structure, c);
fpanel1.Controls.Add(c);
c.Data = elem.Data;
}
}
else
{
foreach (var elem in ss.elements)
{
Control c = null;
if (elem.options != null && elem.options.Length > 1)
{
c = new OptionsElement();
}
else if (elem.flags != null && elem.flags.Length > 1)
{
c = new FlagsElement();
}
else
{
switch (elem.type)
{
case ElementValueType.LString:
c = new LStringElement();
break;
case ElementValueType.FormID:
c = new FormIDElement();
break;
case ElementValueType.Blob:
c = new HexElement();
break;
default:
c = new TextElement();
break;
}
}
if (c is IElementControl)
{
var ec = c as IElementControl;
ec.formIDLookup = p.GetRecordByID;
ec.formIDScan = p.EnumerateRecords;
ec.strIDLookup = p.LookupFormStrings;
ec.Element = elem;
if (elem.repeat > 0)
{
var ge = new RepeatingElement();
c = ge;
c.Left = 8;
c.Width = fpanel1.Width - 16;
c.Top = panelOffset;
c.Anchor = c.Anchor | AnchorStyles.Left | AnchorStyles.Right;
ge.InnerControl = ec;
ge.Element = elem;
ec = ge;
}
else if (elem.optional)
{
//.........这里部分代码省略.........