Exemple #1
0
        public bool SetFilterText(string filterText)
        {
            if (string.IsNullOrEmpty(filterText))
            {
                if (m_textFilter != null)
                {
                    RemoveFilter(m_textFilter);
                    m_textFilter = null;

                    return(ApplyFilter(this));
                }
            }
            else
            {
                if (m_textFilter != null)
                {
                    string oldText = m_textFilter.Text;
                    m_textFilter.Text = filterText;

                    if (filterText.StartsWith(oldText)) // can only decrease filtered items count: e.g. 'tex' -> 'text'
                    {
                        return(AppendFilter(m_textFilter));
                    }

                    return(ApplyFilter(this));
                }

                m_textFilter = new ConsoleViewTextFilter(filterText);
                bool shouldAppend = this.HasFilters; // not the first filter

                AddFilter(m_textFilter);

                return(shouldAppend ? AppendFilter(m_textFilter) : ApplyFilter(m_textFilter));
            }

            return(false);
        }
        public bool SetFilterText(string filterText)
        {
            if (string.IsNullOrEmpty(filterText))
            {
                if (m_textFilter != null)
                {
                    RemoveFilter(m_textFilter);
                    m_textFilter = null;

                    return ApplyFilter(this);
                }
            }
            else
            {
                if (m_textFilter != null)
                {
                    string oldText = m_textFilter.Text;
                    m_textFilter.Text = filterText;

                    if (filterText.StartsWith(oldText)) // can only decrease filtered items count: e.g. 'tex' -> 'text'
                    {
                        return AppendFilter(m_textFilter);
                    }

                    return ApplyFilter(this);
                }

                m_textFilter = new ConsoleViewTextFilter(filterText);
                bool shouldAppend = this.HasFilters; // not the first filter

                AddFilter(m_textFilter);

                return shouldAppend ? AppendFilter(m_textFilter) : ApplyFilter(m_textFilter);
            }

            return false;
        }