Ejemplo n.º 1
0
        /// <summary>
        /// Adds the periods of the specified day to the specified canvas with the specified size.
        /// </summary>
        private void AddPeriodsToCanvas(Canvas canvas, Size size, StudyDay day)
        {
            var matrix = new PeriodMatrix(day);

            double heightPerMinute = size.Height / ((_maxHour - _minHour) * MinutesInHour);
            double widthPerColumn  = size.Width / matrix.ColumnCount;
            var    startDate       = day.Day.AddHours(_minHour);

            foreach (var period in day.Periods)
            {
                var control = new ContentControl
                {
                    ContentTemplate = PeriodTemplate,
                    Content         = period,
                    Style           = ContainerStyle,
                    Height          = (period.End - period.Start).TotalMinutes * heightPerMinute,
                    Width           = matrix.GetWidthMultiplier(period) * size.Width
                };

                Canvas.SetTop(control, (period.Start - startDate).TotalMinutes * heightPerMinute);
                Canvas.SetLeft(control, widthPerColumn * matrix.GetColumn(period));

                canvas.Children.Add(control);
            }
        }
Ejemplo n.º 2
0
        private void AddPeriodsToCanvas( Canvas canvas, Size size, StudyDay day )
        {
            var matrix = new PeriodMatrix( day );

            double heightPerMinute = size.Height / ( ( _maxHour - _minHour ) * MinutesInHour );
            double widthPerColumn = size.Width / matrix.ColumnCount;
            var startDate = day.Day.AddHours( _minHour );

            foreach ( var period in day.Periods )
            {
                var control = new ContentControl
                {
                    ContentTemplate = PeriodTemplate,
                    Content = period,
                    Style = ContainerStyle,
                    Height = ( period.End - period.Start ).TotalMinutes * heightPerMinute,
                    Width = matrix.GetWidthMultiplier( period ) * size.Width
                };

                Canvas.SetTop( control, ( period.Start - startDate ).TotalMinutes * heightPerMinute );
                Canvas.SetLeft( control, widthPerColumn * matrix.GetColumn( period ) );

                canvas.Children.Add( control );
            }
        }