Control StringEditor(bool enabled, string name, ref int tabIndex, ObjKeyResource.ObjKeyResource.ComponentDataType cdt) { ObjKeyResource.ObjKeyResource.CDTString cdtString = cdt as ObjKeyResource.ObjKeyResource.CDTString; TextBox tb = new TextBox(); tb.Anchor = AnchorStyles.Left | AnchorStyles.Right; tb.Enabled = enabled; tb.Name = "tb" + name; tb.TabIndex = tabIndex++; tb.Text = cdtString == null ? "" : cdtString.Data; return(tb); }
Control ResourceKeyEditor(bool enabled, string name, ref int tabIndex, ObjKeyResource.ObjKeyResource.ComponentDataType cdt) { ObjKeyResource.ObjKeyResource.CDTResourceKey cdtResourceKey = cdt as ObjKeyResource.ObjKeyResource.CDTResourceKey; Label lb = new Label(); lb.AutoSize = true; lb.Text = "(WWWW) 0xDDDDDDDD-0xDDDDDDDD-0xDDDDDDDDDDDDDDDD"; TGIBlockCombo tbc = new TGIBlockCombo(objk.TGIBlocks, cdtResourceKey == null ? -1 : cdtResourceKey.Data, false); tbc.Anchor = AnchorStyles.Left; tbc.Enabled = enabled; tbc.Name = "tbc" + name; tbc.TabIndex = tabIndex++; tbc.Width = lb.PreferredWidth; tbc.TGIBlockListChanged += new EventHandler(tbc_TGIBlockListChanged); return(tbc); }
Control UInt32Editor(bool enabled, string name, ref int tabIndex, ObjKeyResource.ObjKeyResource.ComponentDataType cdt) { ObjKeyResource.ObjKeyResource.CDTUInt32 cdtUInt32 = cdt as ObjKeyResource.ObjKeyResource.CDTUInt32; Label lb = new Label(); lb.AutoSize = true; lb.Text = "0xDDDDDDDD"; TextBox tb = new TextBox(); tb.Anchor = AnchorStyles.Left; tb.Enabled = enabled; tb.Name = "tb" + name; tb.TabIndex = tabIndex++; tb.Text = cdtUInt32 == null ? "" : "0x" + cdtUInt32.Data.ToString("X8"); tb.Width = lb.PreferredWidth; tb.TextChanged += new EventHandler(tb_TextChanged); return(tb); }
void AddRow(TableLayoutPanel tlp, string name, ref int tabIndex) { tlp.RowCount++; tlp.RowStyles.Insert(tlp.RowCount - 2, new RowStyle(SizeType.AutoSize)); ObjKeyResource.ObjKeyResource.Component component = (ObjKeyResource.ObjKeyResource.Component)Enum.Parse(typeof(ObjKeyResource.ObjKeyResource.Component), name); ObjKeyResource.ObjKeyResource.ComponentElement ce = objk.Components.Find(component); CheckBox ckb = new CheckBox(); ckb.Anchor = AnchorStyles.Left; ckb.AutoSize = true; ckb.Checked = ce != null; ckb.Enabled = !unused.Contains(name); ckb.Name = "ckb" + name; ckb.TabIndex = tabIndex++; ckb.Text = name + (unused.Contains(name) ? " (unused)" : ""); ckb.CheckedChanged += new EventHandler(ckb_CheckedChanged); tlp.Controls.Add(ckb, 0, tlp.RowCount - 2); if (ComponentDataTypeMap.ContainsKey(name)) { TypeKey tk = ComponentDataTypeMap[name]; string type = tk.type.Name.Substring(3); ObjKeyResource.ObjKeyResource.ComponentDataType cdt = null; if (objk.ComponentData.ContainsKey(tk.key)) { cdt = objk.ComponentData[tk.key]; } if (name.Equals("Sim")) { CheckBox ckb2 = new CheckBox(); ckb2.Anchor = AnchorStyles.Right; ckb2.AutoSize = true; ckb2.Enabled = ckb.Checked; ckb2.Checked = cdt != null; ckb2.Name = "ckbData" + tabIndex; ckb2.TabIndex = tabIndex++; ckb2.Text = type + ":"; ckb2.CheckedChanged += new EventHandler(ckb2_CheckedChanged); tlp.Controls.Add(ckb2, 1, tlp.RowCount - 2); } else { Label lb = new Label(); lb.Anchor = AnchorStyles.Right; lb.AutoSize = true; lb.Name = "lbData" + tabIndex; lb.TabIndex = tabIndex++; lb.Text = type + ":"; tlp.Controls.Add(lb, 1, tlp.RowCount - 2); } if (type == "String" || type == "SteeringInstance") { tlp.Controls.Add(StringEditor(ckb.Checked, name, ref tabIndex, cdt), 2, tlp.RowCount - 2); } else if (type == "UInt32") { tlp.Controls.Add(UInt32Editor(ckb.Checked, name, ref tabIndex, cdt), 2, tlp.RowCount - 2); } else { tlp.Controls.Add(ResourceKeyEditor(ckb.Checked, name, ref tabIndex, cdt), 2, tlp.RowCount - 2); } } }