PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/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
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace Microsoft.Research.DynamicDataDisplay.ViewportConstraints
  6. {
  7. public sealed class DateTimeVerticalAxisConstraint : ViewportConstraint
  8. {
  9. private readonly double minSeconds = new TimeSpan(DateTime.MinValue.Ticks).TotalSeconds;
  10. private readonly double maxSeconds = new TimeSpan(DateTime.MaxValue.Ticks).TotalSeconds;
  11. public override DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport)
  12. {
  13. DataRect borderRect = DataRect.Create(proposedDataRect.XMin, minSeconds, proposedDataRect.XMax, maxSeconds);
  14. if (proposedDataRect.IntersectsWith(borderRect))
  15. {
  16. DataRect croppedRect = DataRect.Intersect(proposedDataRect, borderRect);
  17. return croppedRect;
  18. }
  19. return previousDataRect;
  20. }
  21. }
  22. }