Пример #1
0
        private void DrawEvents(Canvas canvas, double yPos)
        {
            var canvasWidth = canvas.ActualWidth;

            var timeLineLength = canvasWidth - FingerWidthInUnits;

            var minimumDuration = (_timeRange.Duration / timeLineLength) * FingerWidthInUnits;

            var distributor = new EventsDistributor(minimumDuration);

            var eventsInRange = _events.Where(e => {
                if (e.Start >= _timeRange.End)
                {
                    return(false);
                }
                if (e.End <= _timeRange.Start)
                {
                    return(false);
                }
                return(true);
            }).ToArray();

            var distribution = distributor.Distribute(eventsInRange);

            foreach (var eventsLine in distribution.Lines)
            {
                if (eventsLine.IsPointEvents)
                {
                    DrawPointEvents(canvas, yPos, eventsLine.Events);
                }
                else
                {
                    DrawIntervalEvents(canvas, yPos, eventsLine.Events, Colors.LightGoldenrodYellow);
                }

                yPos += FingerWidthInUnits;
            }
        }
Пример #2
0
 public EventsDistributorTests()
 {
     _interval          = Duration.Zero.AddYears(1);
     _eventsDistributor = new EventsDistributor(_interval);
 }