PageRenderTime 69ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/Main/src/DynamicDataDisplay/ViewportConstraints/DateTimeHorizontalAxisConstraint.cs

#
C# | 25 lines | 22 code | 3 blank | 0 comment | 1 complexity | b44470c889e3b754b1bf2b4e688a469e 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 DateTimeHorizontalAxisConstraint : 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(minSeconds, proposedDataRect.YMin, maxSeconds, proposedDataRect.YMax);
  14. if (proposedDataRect.IntersectsWith(borderRect))
  15. {
  16. DataRect croppedRect = DataRect.Intersect(proposedDataRect, borderRect);
  17. return croppedRect;
  18. }
  19. return previousDataRect;
  20. }
  21. }
  22. }