Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Charts/FilterCollection.cs @ 13072

Last change on this file since 13072 was 12503, checked in by aballeit, 9 years ago

#2283 added GUI and charts; fixed MCTS

File size: 1.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Microsoft.Research.DynamicDataDisplay.Filters;
6using Microsoft.Research.DynamicDataDisplay.Common;
7using System.Collections.Specialized;
8using System.Windows;
9
10namespace Microsoft.Research.DynamicDataDisplay.Charts
11{
12  /// <summary>
13  /// Represents a collection of point filters of <see cref="LineGraph"/>.
14  /// </summary>
15  public sealed class FilterCollection : D3Collection<IPointsFilter>
16  {
17    protected override void OnItemAdding(IPointsFilter item)
18    {
19      if (item == null)
20        throw new ArgumentNullException("item");
21    }
22
23    protected override void OnItemAdded(IPointsFilter item)
24    {
25      item.Changed += OnItemChanged;
26    }
27
28    private void OnItemChanged(object sender, EventArgs e)
29    {
30      OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
31    }
32
33    protected override void OnItemRemoving(IPointsFilter item)
34    {
35      item.Changed -= OnItemChanged;
36    }
37
38    internal List<Point> Filter(List<Point> points, Rect screenRect)
39    {
40      foreach (var filter in Items)
41      {
42        filter.SetScreenRect(screenRect);
43        points = filter.Filter(points);
44      }
45
46      return points;
47    }
48  }
49}
Note: See TracBrowser for help on using the repository browser.