private void checkboxchanged(CheckedIconListBoxForm sender, ItemCheckEventArgs e) // called after check changed for the new system { if (e.NewValue == CheckState.Checked) // all or none set all of them { if (e.Index < groupoptions.Count()) { bool shift = Control.ModifierKeys.HasFlag(Keys.Control); if (!shift) { cc.SetCheckedFromToEnd(groupoptions.Count(), false); // if not shift, we clear all, and apply this tag } string tag = groupoptions[e.Index].Tag; if (tag == "All") { cc.SetCheckedFromToEnd(groupoptions.Count(), true); } else if (tag == "None") { cc.SetCheckedFromToEnd(groupoptions.Count(), false); } else { cc.SetChecked(tag); } } } else { if (e.Index < groupoptions.Count()) // off on this clears the entries of it only { string tag = groupoptions[e.Index].Tag; if (tag != "All" && tag != "None ") { cc.SetChecked(tag, false); } } } SetGroupOptions(); CheckedChanged?.Invoke(this, e); if (CloseOnChange) { cc.Close(); } }
public void Show(string settings, Point p, Size s, Form parent, Object tag = null, bool applytheme = true) { if (cc == null) { cc = new ExtendedControls.CheckedIconListBoxForm(); foreach (var x in groupoptions) { cc.AddItem(x.Tag, x.Text, x.Image); } foreach (var x in standardoptions) { cc.AddItem(x.Tag, x.Text, x.Image); } string[] slist = settings.SplitNoEmptyStartFinish(';'); if (slist.Length == 1 && slist[0].Equals("All")) { cc.SetCheckedFromToEnd(groupoptions.Count()); } else { cc.SetChecked(settings); } SetGroupOptions(); cc.FormClosed += FormClosed; cc.CheckedChanged += checkboxchanged; if (s.Height < 1) { s.Height = cc.HeightNeeded(); } cc.PositionSize(p, s); cc.LargeChange = cc.ItemCount * Properties.Resources.All.Height / 40; // 40 ish scroll movements cc.CloseOnDeactivate = CloseOnDeactivate; if (applytheme) { ThemeableFormsInstance.Instance?.ApplyToControls(cc, applytothis: true); } tagback = tag; cc.Show(parent); } else { cc.Close(); } }