private void btnSearch_Click(object sender, EventArgs e) { DataPanel.Controls.Clear(); InitAddButton(DataPanel); entryComponents.Clear(); string search = textBox1.Text; if (search == "") { return; //should later add some message } switch (search) //super secret dev commands hehe { case "!wipecats": var cats = DatabaseClass.GetCategoriesList(); for (int j = 3; j < cats.Count; j++) { var entries = DatabaseClass.GetDataByCategory(cats[j], ""); if (entries != null) { foreach (Entry entry in entries) { DatabaseClass.RemoveEntry(category, entry.name); } } DatabaseClass.RemoveCategory(cats[j]); } var pp = Parent.Parent as Form1; pp.RedrawCats(); break; case "!wipeentries": var entriess = DatabaseClass.GetDataByCategory(category, ""); foreach (Entry entry in entriess) { DatabaseClass.RemoveEntry(category, entry.name); } break; case "!wipeall": DatabaseClass.RemoveAllEntries(); DatabaseClass.RemoveNonMandatoryCategories(); var ppp = Parent.Parent as Form1; ppp.RedrawCats(); break; } var list = DatabaseClass.GetCategoryEntry(DatabaseClass.FindCategoryId(category), search); int i = 0; foreach (Entry ent in list) { EntryComponent entr = new EntryComponent(i, ent, category); DataPanel.Controls.Add(entr.mainPanel); entryComponents.Add(entr); } }
private void btnSortScore_Click(object sender, EventArgs e) { DataPanel.Controls.Clear(); InitAddButton(DataPanel); entryComponents.Clear(); var list = DatabaseClass.SortEntries(category, 4, true);//sort by score descending int i = 0; foreach (Entry ent in list) { EntryComponent entr = new EntryComponent(i, ent, category); DataPanel.Controls.Add(entr.mainPanel); entryComponents.Add(entr); } }
public void ChildForm_Shown(object sender, EventArgs e) { if (Controls.Count == 0) //when this is called if an entry is deleted the controls should be empty { InitializeComponent(size); //need to init because it also has that big plus button } entryComponents = new List <EntryComponent>(); var entries = DatabaseClass.GetDataByCategory(category, ""); int i = 0; foreach (Entry ent in entries) { EntryComponent entr = new EntryComponent(i, ent, category); DataPanel.Controls.Add(entr.mainPanel); entryComponents.Add(entr); } }