Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Windows;
|
---|
6 |
|
---|
7 | namespace Microsoft.Research.DynamicDataDisplay.ViewportConstraints
|
---|
8 | {
|
---|
9 | /// <summary>
|
---|
10 | /// Represents a ViewportConstraint, which the minimal size of <see cref="Viewport"/>'s Visible.
|
---|
11 | /// </summary>
|
---|
12 | public class MinimalSizeConstraint : ViewportConstraint
|
---|
13 | {
|
---|
14 | private double minSize = 1E-11;
|
---|
15 |
|
---|
16 | /// <summary>
|
---|
17 | /// Gets or sets the minimal size of Viewport's Visible.
|
---|
18 | /// </summary>
|
---|
19 | /// <value>The minimal size of Viewport's Visible.</value>
|
---|
20 | public double MinSize
|
---|
21 | {
|
---|
22 | get { return minSize; }
|
---|
23 | set
|
---|
24 | {
|
---|
25 | if (minSize != value)
|
---|
26 | {
|
---|
27 | minSize = value;
|
---|
28 | RaiseChanged();
|
---|
29 | }
|
---|
30 | }
|
---|
31 | }
|
---|
32 |
|
---|
33 | /// <summary>
|
---|
34 | /// Applies the restriction.
|
---|
35 | /// </summary>
|
---|
36 | /// <param name="previousDataRect">Previous data rectangle.</param>
|
---|
37 | /// <param name="proposedDataRect">Proposed data rectangle.</param>
|
---|
38 | /// <param name="viewport">The viewport, to which current restriction is being applied.</param>
|
---|
39 | /// <returns>New changed visible rectangle.</returns>
|
---|
40 | public override DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport)
|
---|
41 | {
|
---|
42 | if (proposedDataRect.Width < minSize || proposedDataRect.Height < minSize)
|
---|
43 | return previousDataRect;
|
---|
44 |
|
---|
45 | return proposedDataRect;
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.