using Mesnac.Controls.Default; using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Mesnac.Action.ChemicalWeighing.Qu { public class Sb { List Controls; public Sb(List c) { this.Controls = c; PropertyInfo[] sourcePropertyInfoList = this.GetType().GetProperties(); foreach (PropertyInfo sourceProperty in sourcePropertyInfoList) { string name = sourceProperty.Name; var pro = Controls.FirstOrDefault(x => x.Name == name) as SpecialLabelBlue; sourceProperty.SetValue(this, pro); } } public void Action() { PropertyInfo[] sourcePropertyInfoList = this.GetType().GetProperties(); foreach (PropertyInfo sourceProperty in sourcePropertyInfoList) { object value = sourceProperty.GetValue(this); SpecialLabelBlue stu = value as SpecialLabelBlue; if (stu.BackColor == Color.Yellow) { SetWhite(stu); sourceProperty.SetValue(this, stu); } } } public void SetWhite(SpecialLabelBlue special) { special.BackColor = Color.White; } public void SetLightGreen(SpecialLabelBlue special) { special.BackColor = Color.Yellow; } } }