예제 #1
0
        /// <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();
        }
예제 #2
0
        /// <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;
        }
예제 #3
0
        /// <summary>
        /// Adds a filter object with specific values. If there is an empty filter in the panel, the empty filter gets filled. 
        /// Otherwhise, a new filter is created and filled.
        /// </summary>
        /// <param name="selection">The category which should be selected in this filter</param>
        /// <param name="value">The searchvalue added to the searchbox</param>
        /// <returns>The complete panel</returns>
        public Panel AddFilter(string selection, string value)
        {
            Filter emptyF = null;
            foreach(Filter actF in allFilter)
            {
                if(actF.CompletelyEmpty())
                    emptyF = actF;
            }

            Filter f = null;

            if (emptyF == null)
            {
                f = new Filter(newID, place, this.GetScrollPosition(), this);
            }
            else
            {
                f = emptyF;
            }

            f.SetSearchSelector(selection);
            f.SetSearchValue(value);

            f.Parent = filterPanel;

            if (emptyF == null)
            {
                allFilter.Add(f);

                newID++;
                place = allFilter[allFilter.Count - 1].GetNextElementPlace();
                this.SetButtons();
            }

            filterPanel.Controls.Add(f.GetStuff());

            return filterPanel;
        }