internal void SetVariants(List <Species> species) { var variantCount = ClbVariants.Items.Count; if (variantCount == 0) { DisabledVariants = Properties.Settings.Default.DisabledVariants?.ToList() ?? new List <string>(); } else { DisabledVariants = new List <string>(); for (int i = 0; i < variantCount; i++) { var v = ClbVariants.Items[i].ToString(); if (!ClbVariants.GetItemChecked(i) && !DisabledVariants.Contains(v)) { DisabledVariants.Add(v); } } } ClbVariants.Items.Clear(); // get all variants var variants = species.Where(s => s.variants != null).SelectMany(s => s.variants).Distinct().OrderBy(s => s).ToList(); variants.Insert(0, string.Empty); var checkAll = DisabledVariants == null || !DisabledVariants.Any(); foreach (var v in variants) { ClbVariants.Items.Add(v, checkAll || !DisabledVariants.Contains(v)); } }
private void CheckBoxAll_CheckedChanged(object sender, EventArgs e) { var isChecked = CheckBoxAll.Checked; int c = ClbVariants.Items.Count; for (int i = 0; i < c; i++) { ClbVariants.SetItemChecked(i, isChecked); } }
/// <summary> /// Call this method before the form is shown to set the checkboxes to their correct state and the location to the cursor. /// </summary> internal void InitializeCheckStates() { var checkAll = DisabledVariants == null || !DisabledVariants.Any(); int c = ClbVariants.Items.Count; for (int i = 0; i < c; i++) { ClbVariants.SetItemChecked(i, checkAll || !DisabledVariants.Contains(ClbVariants.Items[i].ToString())); } SetDesktopLocation(Cursor.Position.X, Cursor.Position.Y); }
private void ButtonOk_Click(object sender, EventArgs e) { DisabledVariants.Clear(); int c = ClbVariants.Items.Count; for (int i = 0; i < c; i++) { if (!ClbVariants.GetItemChecked(i)) { DisabledVariants.Add(ClbVariants.Items[i].ToString()); } } DialogResult = DialogResult.OK; Close(); }