Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/ViewportConstraints/InjectionDelegateConstraint.cs @ 13780

Last change on this file since 13780 was 12503, checked in by aballeit, 10 years ago

#2283 added GUI and charts; fixed MCTS

File size: 1.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5
6namespace Microsoft.Research.DynamicDataDisplay.ViewportConstraints
7{
8  public delegate DataRect ViewportConstraintCallback(DataRect proposedDataRect);
9
10  public class InjectionDelegateConstraint : ViewportConstraint
11  {
12    public InjectionDelegateConstraint(Viewport2D masterViewport, ViewportConstraintCallback callback)
13    {
14      if (callback == null)
15        throw new ArgumentNullException("callback");
16      if (masterViewport == null)
17        throw new ArgumentNullException("masterViewport");
18
19      this.callback = callback;
20      this.masterViewport = masterViewport;
21      masterViewport.PropertyChanged += masterViewport_PropertyChanged;
22    }
23
24    void masterViewport_PropertyChanged(object sender, ExtendedPropertyChangedEventArgs e)
25    {
26      if (e.PropertyName == "Visible")
27      {
28        RaiseChanged();
29      }
30    }
31
32    private Viewport2D masterViewport;
33    private ViewportConstraintCallback callback;
34
35    public override DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport)
36    {
37      return callback(proposedDataRect);
38    }
39  }
40}
Note: See TracBrowser for help on using the repository browser.