private void Handler(object sender, EventArgs args)
        {
            var  item          = (Type)sender;
            bool filterApplies = Filter(item);

            if (filterApplies)
            {
                if (!Filtered.Contains(item))
                {
                    var previous = Filtered.LastOrDefault();
                    if (previous != null)
                    {
                        _ignoreSourceChangeEvents = true;
                        try
                        {
                            int idxInsertAfter = Source.IndexOf(previous);
                            Source.Remove(item);
                            if (idxInsertAfter < Source.Count)
                            {
                                Source.Insert(idxInsertAfter, item);
                            }
                            else
                            {
                                Source.Add(item);
                            }
                        }
                        finally
                        {
                            _ignoreSourceChangeEvents = false;
                        }
                    }
                    Filtered.Add(item);
                }
                return;
            }
            else
            {
                if (Filtered.Contains(item))
                {
                    Filtered.Remove(item);
                }
                return;
            }
        }
예제 #2
0
 public bool Contains(T item)
 {
     return(Filtered.Contains(item));
 }