Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/ViewportConstraints/DateTimeHorizontalAxisConstraint.cs @ 13376

Last change on this file since 13376 was 12503, checked in by aballeit, 9 years ago

#2283 added GUI and charts; fixed MCTS

File size: 871 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5
6namespace Microsoft.Research.DynamicDataDisplay.ViewportConstraints
7{
8  public sealed class DateTimeHorizontalAxisConstraint : 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(minSeconds, proposedDataRect.YMin, maxSeconds, proposedDataRect.YMax);
16      if (proposedDataRect.IntersectsWith(borderRect))
17      {
18        DataRect croppedRect = DataRect.Intersect(proposedDataRect, borderRect);
19        return croppedRect;
20      }
21
22      return previousDataRect;
23    }
24  }
25}
Note: See TracBrowser for help on using the repository browser.