/// <summary> /// AddFilter creates a new filter object, adds it to an internatl list of filters. /// Calculates the place of this filter and adds it to the panel. /// </summary> /// <returns>The complete panel</returns> public Panel AddFilter() { Filter f = new Filter(newID, place, this.GetScrollPosition(), this); f.Parent = filterPanel; allFilter.Add(f); newID++; place = allFilter[allFilter.Count - 1].GetNextElementPlace(); filterPanel.Controls.Add(f.GetStuff()); this.SetButtons(); return filterPanel; }
/// <summary> /// Removes one specific filter from the panel /// </summary> /// <param name="f">The filter which should be removed</param> public void RemoveFilter(Filter f) { if (f != null) { if (f.Parent != null) { if (f.Parent.Controls != null) { f.Parent.Controls.Remove(f.GetStuff()); } else { MessageBox.Show("Error"); } } else { MessageBox.Show("Error2"); } } else { MessageBox.Show("Error3"); } int searchID = f.GetID(); for (int i = 0; i < allFilter.Count; i++) { Filter actFilter = allFilter[i]; if (actFilter.GetID() == searchID) { allFilter.RemoveAt(i); i = allFilter.Count; } } this.ResetPositions(); // this.SearchAll(); }