Beispiel #1
0
        /// <summary>
        /// Draws the days.
        /// </summary>
        /// <param name="days">a sorted list of days to draw</param>
        private void RenderDays(IEnumerable <DayInfo> days)
        {
            foreach (DayInfo day in days)
            {
                RectangleF dayRect = day.Bounds;

                var headerBorderPath = new PathEx();
                var borderPath       = new PathEx();
                {
                    // create day-box area
                    borderPath.AddLines(
                        new PointF[]
                    {
                        new PointF(dayRect.X, dayRect.Y),
                        new PointF(dayRect.X + dayRect.Width, dayRect.Y),
                        new PointF(dayRect.X + dayRect.Width, dayRect.Y + dayRect.Height),
                        new PointF(dayRect.X, dayRect.Y + dayRect.Height),
                    });
                    borderPath.CloseAllFigures();

                    //Fix for case 44962
                    headerBorderPath.AddLines(
                        new PointF[]
                    {
                        new PointF(dayRect.X, dayRect.Y),
                        new PointF(dayRect.X + dayRect.Width, dayRect.Y),
                        new PointF(dayRect.X + dayRect.Width, dayRect.Y + day.HeaderSize.Height),
                        new PointF(dayRect.X, dayRect.Y + day.HeaderSize.Height),
                    });
                    headerBorderPath.CloseAllFigures();

                    // fill day-box area
                    using (BrushEx brush = Canvas.CreateSolidBrush(CalendarData.GetDayBackcolor(day.DayKind)))
                    {
                        Canvas.DrawAndFillPath(null, brush, borderPath);
                        Canvas.DrawAndFillPath(null, brush, headerBorderPath);
                    }
                    // draw the day label
                    TextStyle fontStyle = CalendarData.GetDayFontStyle(day.DayKind);
                    var       font      = fontStyle.CreateFontInfo();
                    using (BrushEx brush = Canvas.CreateSolidBrush(fontStyle.FontColor))
                    {
                        float      borderWidth  = CalendarData.GetDayBorderStyle(day.DayKind).LineWidth.ToTwips() / 2;
                        RectangleF dayLabelRect = new RectangleF(
                            dayRect.X + borderWidth, dayRect.Top + borderWidth,
                            day.Bounds.Width - 2 * borderWidth, day.HeaderSize.Height - 2 * borderWidth);

                        // HACK: we should consider the issue with drawing string later. the issue comes about in the designer when caledar has small width to fit titles. --SergeyP
                        Canvas.PushState();
                        Canvas.DrawString(day.Label, font, brush, dayLabelRect, ToEx(CalendarData.GetDayStringFormat(day.DayKind)));
                        Canvas.PopState();
                    }
                    // draw borders
                    using (PenEx pen = LineStyle.CreatePen(Canvas, CalendarData.GetDayBorderStyle(day.DayKind)))
                    {
                        Canvas.DrawAndFillPath(pen, null, borderPath);
                        Canvas.DrawAndFillPath(pen, null, headerBorderPath);
                    }
                }
            }
        }