Rev | Line | |
---|
[12503] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 |
|
---|
| 6 | namespace 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.