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; } }
protected void TransferPropertiesWithReflection(PKM Source, PKM Destination) { var SourceProperties = ReflectUtil.getPropertiesCanWritePublic(Source.GetType()); var DestinationProperties = ReflectUtil.getPropertiesCanWritePublic(Destination.GetType()); foreach (string property in SourceProperties.Intersect(DestinationProperties).Where(prop => prop != nameof(Data))) { var prop = ReflectUtil.GetValue(this, property); if (prop == null) { continue; } ReflectUtil.SetValue(Destination, property, prop); } }
private void populateRibbons() { // Get a list of all Ribbon Attributes in the PKM var RibbonNames = ReflectUtil.getPropertiesStartWithPrefix(pkm.GetType(), "Ribbon"); foreach (var RibbonName in RibbonNames) { object RibbonValue = ReflectUtil.GetValue(pkm, RibbonName); if (RibbonValue is int) { riblist.Add(new RibbonInfo(RibbonName, (int)RibbonValue)); } if (RibbonValue is bool) { riblist.Add(new RibbonInfo(RibbonName, (bool)RibbonValue)); } } TLP_Ribbons.ColumnCount = 2; TLP_Ribbons.RowCount = 0; // Add Ribbons foreach (var rib in riblist) { addRibbonSprite(rib); addRibbonChoice(rib); } // Force auto-size foreach (RowStyle style in TLP_Ribbons.RowStyles) { style.SizeType = SizeType.AutoSize; } foreach (ColumnStyle style in TLP_Ribbons.ColumnStyles) { style.SizeType = SizeType.AutoSize; } }