private void PopulateRegimens(string Type, TableLayoutPanel TLP, List <RegimenInfo> list) { // Get a list of all Regimen Attregutes in the PKM var RegimenNames = ReflectUtil.GetPropertiesStartWithPrefix(pkm.GetType(), Type); list.AddRange(from RegimenName in RegimenNames let RegimenValue = ReflectUtil.GetValue(pkm, RegimenName) where RegimenValue is bool select new RegimenInfo(RegimenName, (bool)RegimenValue)); TLP.ColumnCount = 1; TLP.RowCount = 0; // Add Regimens foreach (var reg in list) { AddRegimenChoice(reg, TLP); } // Force auto-size foreach (RowStyle style in TLP.RowStyles) { style.SizeType = SizeType.AutoSize; } foreach (ColumnStyle style in TLP.ColumnStyles) { style.SizeType = SizeType.AutoSize; } }
private static IEnumerable <RegimenInfo> GetBooleanRegimenNames(ISuperTrain pkm, string propertyPrefix) { var names = ReflectUtil.GetPropertiesStartWithPrefix(pkm.GetType(), propertyPrefix); foreach (var name in names) { var value = ReflectUtil.GetValue(pkm, name); if (value is bool state) { yield return(new RegimenInfo(name, state)); } } }