public void FilterButton(string db, Point p, Size s, Color back, Color fore, Form parent, List <string> list) { if (cc == null) { dbstring = db; cc = new ExtendedControls.CheckedListBoxForm(); cc.Items.Add("All"); cc.Items.Add("None"); cc.Items.AddRange(list.ToArray()); cc.SetChecked(SQLiteDBClass.GetSettingString(dbstring, "All")); SetFilterSet(); cc.FormClosed += FilterClosed; cc.CheckedChanged += FilterCheckChanged; cc.PositionSize(p, s); cc.SetColour(back, fore); cc.Show(parent); } else { cc.Close(); } }
private void FilterClosed(Object sender, FormClosedEventArgs e) { SQLiteDBClass.PutSettingString(dbstring, cc.GetChecked(2)); cc = null; if (Changed != null) { Changed(sender, e); } }
private void EditTags(DataGridViewRow rw) { List <string> Dickeys = new List <string>(tags.Keys); Dickeys.Sort(); List <Image> images = (from x in Dickeys select tags[x]).ToList(); dropdown = new ExtendedControls.CheckedListBoxForm(); dropdown.Items.Add("All".Tx()); // displayed, translate dropdown.Items.Add("None".Tx()); dropdown.Items.AddRange(Dickeys.ToArray()); List <string> curtags = rw.Cells[4].Tag as List <string>; // may be null System.Diagnostics.Debug.WriteLine("Cur keys" + curtags); dropdown.SetChecked(curtags); // null allowed SetAllOrNone(); //dropdown.FormClosed += FilterClosed; dropdown.CheckedChanged += (sv, ev) => { dropdown.SetChecked(ev.NewValue == CheckState.Checked, ev.Index, 1); // force check now (its done after it) so our functions work.. if (ev.Index == 0 && ev.NewValue == CheckState.Checked) // all, and checked { dropdown.SetChecked(true, 2); // rest go on.. } if ((ev.Index == 1 && ev.NewValue == CheckState.Checked)) // none is checked.. { dropdown.SetChecked(false, 2); // rest off } SetAllOrNone(); }; dropdown.FormClosed += (sv, ev) => { List <string> newtags = dropdown.GetCheckedList(2, allornone: false); // we don't use all or none to store - too difficult! rw.Cells[4].Tag = newtags; rw.MinimumHeight = Math.Max(newtags.Count * TagSpacing, MinRowSize); StoreRow(rw); dataGridView.InvalidateRow(rw.Index); }; Point loc = dataGridView.PointToScreen(dataGridView.GetCellDisplayRectangle(4, rw.Index, false).Location); dropdown.PositionSize(loc, new Size(400, 400)); EDDTheme.Instance.ApplyToControls(dropdown); dropdown.Show(this.FindForm()); }