// ----------------------------------------------------------------- // // filter the ListView powered by regular expression. // // ----------------------------------------------------------------- // public void RegexSearch(string filter) { ListView listview; Regex regex = null; try { regex = new Regex(@"" + filter, RegexOptions.IgnoreCase); } catch { return; } switch (typename) { case "user": case "member": listview = Form1.formgen.GetControl("user.list", "listview") as ListView; if (listview == null) { return; } UserListPage userpage = Form1.formgen.GetPage("user.list") as UserListPage; if (userpage == null) { return; } listview.Items.Clear(); foreach (KeyValuePair <string, Member> member in Form1.context.members) { if (!member.Value.RegexMatch(regex)) { continue; } userpage.PopulateListItem(listview, member.Value); } break; case "staff": case "manager": listview = Form1.formgen.GetControl("staff.list", "listview") as ListView; StaffListPage staffpage = Form1.formgen.GetPage("staff.list") as StaffListPage; if (staffpage == null) { return; } listview.Items.Clear(); foreach (KeyValuePair <string, Staff> staff in Form1.context.staffs) { if (!staff.Value.RegexMatch(regex)) { continue; } staffpage.PopulateListItem(listview, staff.Value); } break; case "game": listview = Form1.formgen.GetControl("game.list", "listview") as ListView; GameListPage gamepage = Form1.formgen.GetPage("game.list") as GameListPage; if (gamepage == null) { return; } listview.Items.Clear(); foreach (KeyValuePair <string, Game> game in Form1.context.games) { if (!game.Value.RegexMatch(regex)) { continue; } gamepage.PopulateListItem(listview, game.Value); } break; case "report": listview = Form1.formgen.GetControl("report.list", "listview") as ListView; ReportListPage reportpage = Form1.formgen.GetPage("report.list") as ReportListPage; if (reportpage == null) { return; } listview.Items.Clear(); foreach (KeyValuePair <string, Report> report in Form1.context.reports) { if (!report.Value.RegexMatch(regex)) { continue; } reportpage.PopulateListItem(listview, report.Value); } break; } }
// ----------------------------------------------------------------- // // fill the ListView with everything you possibly can. // // ----------------------------------------------------------------- // public void EmptySearch() { ListView listview; switch (typename) { case "user": case "member": listview = Form1.formgen.GetControl("user.list", "listview") as ListView; UserListPage userpage = Form1.formgen.GetPage(typename + ".list") as UserListPage; if (userpage == null) { return; } listview.Items.Clear(); foreach (KeyValuePair <string, Member> member in Form1.context.members) { userpage.PopulateListItem(listview, member.Value); } break; case "staff": case "manager": listview = Form1.formgen.GetControl("staff.list", "listview") as ListView; StaffListPage staffpage = Form1.formgen.GetPage(typename + ".list") as StaffListPage; if (staffpage == null) { return; } listview.Items.Clear(); foreach (KeyValuePair <string, Staff> staff in Form1.context.staffs) { staffpage.PopulateListItem(listview, staff.Value); } break; case "game": listview = Form1.formgen.GetControl("game.list", "listview") as ListView; GameListPage gamepage = Form1.formgen.GetPage("game.list") as GameListPage; if (gamepage == null) { return; } listview.Items.Clear(); foreach (KeyValuePair <string, Game> game in Form1.context.games) { gamepage.PopulateListItem(listview, game.Value); } break; case "report": listview = Form1.formgen.GetControl("report.list", "listview") as ListView; ReportListPage reportpage = Form1.formgen.GetPage("report.list") as ReportListPage; if (reportpage == null) { return; } listview.Items.Clear(); foreach (KeyValuePair <string, Report> report in Form1.context.reports) { reportpage.PopulateListItem(listview, report.Value); } break; } }