private void loadFiltersIntoUI() { availableFilters.Clear(); filterList.Items.Clear(); filterList.Items.Add("All servers"); filterList.Items.Add("Favourites"); filterList.Items.Add("Friends"); availableFilters.Add(Filter.getDefaultFilter()); // Favourites filter Filter temp = Filter.getDefaultFilter(); temp.Favourites = Filter.YNA.Yes; availableFilters.Add(temp); temp = Filter.getDefaultFilter(); temp.Friends = Filter.YNA.Yes; availableFilters.Add(temp); try { foreach (string f in Directory.GetFiles("filters/", "*.osl", SearchOption.TopDirectoryOnly)) { string fn = Path.GetFileNameWithoutExtension(f); Filter f2 = FilterLoader.LoadFilterClass(fn); availableFilters.Add(f2); filterList.Items.Add(f2.filterName); } } catch (Exception e) { MessageBox.Show("Error while loading filters! " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
private bool saveFilter() { if (!validateFilterName(changingFilter.filterName)) { MessageBox.Show("A filter name can only be alpha-numeric! (letters and numbers only)", "Filter name invalid", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return(false); } if ((File.Exists("filters/" + changingFilter.filterName.ToLower()) && newf) || changingFilter.filterName.ToLower() == "all servers" || // these will always exist anyway :P changingFilter.filterName.ToLower() == "favourites only") { MessageBox.Show("A filter with that name already exists!", "Filter already exists", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return(false); } FilterLoader.SaveFilterClass(changingFilter); return(true); }