예제 #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
 private EventsDistribution <string, string> Distribute(params Event <string, string>[] events)
 {
     return(_eventsDistributor.Distribute(events));
 }