public static void CreateControls(Type itemsEnumType, Action <CleanerItemUIInfo> action, bool sortDesc = false) { try { var cleannerItemsAttributes = ExtractCleannerItemsAttributes(itemsEnumType); if (!sortDesc) { cleannerItemsAttributes = cleannerItemsAttributes.OrderBy(x => x.Value.Order.GetValueOrDefault(x.Key)); } else { cleannerItemsAttributes = cleannerItemsAttributes.OrderByDescending(x => x.Value.Order.GetValueOrDefault(x.Key)); } foreach (var item in cleannerItemsAttributes) { var tempCheckBoxItemUiInfo = new CleanerItemUIInfo { CleanerType = item.Key, ShouldBeSelectedByDefault = item.Value.SelectedByDefault, Order = item.Value.Order.GetValueOrDefault(item.Key) }; if (!string.IsNullOrEmpty(item.Value.Title)) { tempCheckBoxItemUiInfo.Name = item.Value.Title; } else { tempCheckBoxItemUiInfo.Name = Enum.GetName(itemsEnumType, item.Key).ToString(); } action(tempCheckBoxItemUiInfo); } } catch { } }
void AddNewCheckboxItem(CleanerItemUIInfo checkBoxItem) { customCheckListBox1.AddItem(checkBoxItem); }