/// <summary> /// 加载功法数据 /// </summary> /// <param name="gongfaIndex"></param> public void ShowGongFaData(int gongfaIndex) { var gongfa = gongFaManager.GongFaList.FirstOrDefault(t => t.GongFaId == gongfaIndex); var list = new List <GTextBox>(); Parallel.ForEach(gongfa.GetType().GetProperties(), (prop) => { var attr = GongFaManager.GetGongFaAttribute(prop); if (attr != null) { if (attr.Skip) { return; } var gtb = new GTextBox(prop, prop.GetValue(gongfa)); gtb.Init(); gtb.ValueChanged += (sender, e) => { prop.SetValue(gongfa, e.ChangedValue); gongfa.Original[attr.Index] = e.ChangedValue.ToString(); }; list.Add(gtb); } }); flowLayoutPanel1.Controls.AddRange(list.ToArray()); }
public GTextBox(PropertyInfo pinfo, object value) { InitializeComponent(); Attribute = GongFaManager.GetGongFaAttribute(pinfo); info = pinfo; orginalValue = value; }
public GongFaEdit() { InitializeComponent(); gongFaManager = new GongFaManager(); gongFaManager.LoadGongFaData(); gongFaManager.LoadMessageData(); }
private void textBox1_Leave(object sender, EventArgs e) { if (textBox1.Text == orginalValue.ToString()) { return; } try { OnValueChanged(new ChangeValueEventArgs() { SourceValue = orginalValue, ChangedValue = GongFaManager.DataConvert(textBox1.Text, info.PropertyType), Attribute = this.Attribute }); } catch (Exception ex) { textBox1.Text = orginalValue.ToString(); } }