Beispiel #1
0
        /// <summary>
        /// Custom cell's content template as a PdfPCell
        /// </summary>
        /// <returns>Content as a PdfPCell</returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var data = attributes.RowData.Value as CalendarData;
            if (data == null)
                throw new InvalidOperationException("Calendar's cell data type is not PdfRpt.Calendar.CalendarData. Use DaysInfoToCalendarData.MapToCalendarDataList to map list of the DayInfo's to the list of CalendarData's.");

            if (attributes.BasicProperties.PdfFont == null)
            {
                return new PdfPCell();
            }

            if (MonthCalendarFieldData.RelativeColumnWidths == null)
                MonthCalendarFieldData.RelativeColumnWidths = new float[] { 1, 1, 1, 1, 1, 1, 1 };

            var table = new MonthCalendar
                {
                    CalendarData = data,
                    CalendarAttributes = new CalendarAttributes
                    {
                        BorderColor = attributes.SharedData.Template.CellBorderColor,
                        Font = attributes.BasicProperties.PdfFont,
                        RelativeColumnWidths = MonthCalendarFieldData.RelativeColumnWidths,
                        UseLongDayNamesOfWeek = MonthCalendarFieldData.UseLongDayNamesOfWeek,
                        CalendarType = MonthCalendarFieldData.CalendarType,
                        CellsCustomizer = MonthCalendarFieldData.CellsCustomizer,
                        GradientEndColor = MonthCalendarFieldData.GradientEndColor,
                        GradientStartColor = MonthCalendarFieldData.GradientStartColor,
                        DescriptionHorizontalAlignment = MonthCalendarFieldData.DescriptionHorizontalAlignment,
                        DayNamesRowBackgroundColor = MonthCalendarFieldData.DayNamesRowBackgroundColor
                    }
                }.CreateMonthCalendar();
            var cell = new PdfPCell(table);
            cell.Padding = MonthCalendarFieldData.Padding;
            return cell;
        }