/Main/src/DynamicDataDisplay/ViewportConstraints/DateTimeVerticalAxisConstraint.cs
C# | 25 lines | 22 code | 3 blank | 0 comment | 1 complexity | d966cff764f318136dbded11cea5fe0e MD5 | raw file
Possible License(s): CC-BY-SA-3.0
1using System; 2using System.Collections.Generic; 3using System.Linq; 4using System.Text; 5 6namespace Microsoft.Research.DynamicDataDisplay.ViewportConstraints 7{ 8 public sealed class DateTimeVerticalAxisConstraint : ViewportConstraint 9 { 10 private readonly double minSeconds = new TimeSpan(DateTime.MinValue.Ticks).TotalSeconds; 11 private readonly double maxSeconds = new TimeSpan(DateTime.MaxValue.Ticks).TotalSeconds; 12 13 public override DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport) 14 { 15 DataRect borderRect = DataRect.Create(proposedDataRect.XMin, minSeconds, proposedDataRect.XMax, maxSeconds); 16 if (proposedDataRect.IntersectsWith(borderRect)) 17 { 18 DataRect croppedRect = DataRect.Intersect(proposedDataRect, borderRect); 19 return croppedRect; 20 } 21 22 return previousDataRect; 23 } 24 } 25}