示例#1
0
            public override void Apply(Calendar wc)
            {
                ClearCalendar(wc);

                wc.DayNameFormat  = DayNameFormat.FirstLetter;
                wc.NextPrevFormat = NextPrevFormat.FullMonth;
                wc.TitleFormat    = TitleFormat.Month;

                wc.CellPadding   = 2;
                wc.CellSpacing   = 0;
                wc.ShowGridLines = false;

                wc.Height      = Unit.Pixel(220);
                wc.Width       = Unit.Pixel(400);
                wc.BackColor   = Color.White;
                wc.BorderColor = Color.Black;
                wc.ForeColor   = Color.Black;
                wc.Font.Name   = "Times New Roman";
                wc.Font.Size   = FontUnit.Point(10);

                wc.TitleStyle.Font.Bold     = true;
                wc.TitleStyle.ForeColor     = Color.White;
                wc.TitleStyle.BackColor     = Color.Black;
                wc.TitleStyle.Font.Size     = FontUnit.Point(13);
                wc.TitleStyle.Height        = Unit.Point(14);
                wc.NextPrevStyle.ForeColor  = Color.White;
                wc.NextPrevStyle.Font.Size  = FontUnit.Point(8);
                wc.DayHeaderStyle.Font.Bold = true;
                wc.DayHeaderStyle.Font.Size = FontUnit.Point(7);
                wc.DayHeaderStyle.Font.Name = "Verdana";
                wc.DayHeaderStyle.BackColor = Color.FromArgb(0xCC, 0xCC, 0xCC);
                wc.DayHeaderStyle.ForeColor = Color.FromArgb(0x33, 0x33, 0x33);
                wc.DayHeaderStyle.Height    = Unit.Pixel(10);
                wc.SelectorStyle.BackColor  = Color.FromArgb(0xCC, 0xCC, 0xCC);
                wc.SelectorStyle.ForeColor  = Color.FromArgb(0x33, 0x33, 0x33);
                wc.SelectorStyle.Font.Bold  = true;
                wc.SelectorStyle.Font.Size  = FontUnit.Point(8);
                wc.SelectorStyle.Font.Name  = "Verdana";
                wc.SelectorStyle.Width      = Unit.Percentage(1);

                wc.DayStyle.Width               = Unit.Percentage(14);
                wc.TodayDayStyle.BackColor      = Color.FromArgb(0xCC, 0xCC, 0x99);
                wc.SelectedDayStyle.BackColor   = Color.FromArgb(0xCC, 0x33, 0x33);
                wc.SelectedDayStyle.ForeColor   = Color.White;
                wc.OtherMonthDayStyle.ForeColor = Color.FromArgb(0x99, 0x99, 0x99);
            }
        void WriteTitle(HtmlTextWriter writer, bool enabled)
        {
            TableCell cellNextPrev = null;
            TableCell titleCell    = new TableCell();
            Table     tableTitle   = new Table();

            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            titleCell.ColumnSpan = HasWeekSelectors(SelectionMode) ? 8 : 7;

            if (titleStyle != null && !titleStyle.IsEmpty && !titleStyle.BackColor.IsEmpty)
            {
                titleCell.BackColor = titleStyle.BackColor;
            }
            else
            {
                titleCell.BackColor = Color.Silver;
            }

            titleCell.RenderBeginTag(writer);

            // Table
            tableTitle.Width = Unit.Percentage(100);
            if (titleStyle != null && !titleStyle.IsEmpty)
            {
                tableTitle.ApplyStyle(titleStyle);
            }

            tableTitle.RenderBeginTag(writer);
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            if (ShowNextPrevMonth) // Previous Table Data
            {
                cellNextPrev = new TableCell();
                cellNextPrev.ApplyStyle(nextPrevStyle);
                cellNextPrev.Width = Unit.Percentage(15);

                DateTime date = GetGlobalCalendar().AddMonths(DisplayDate, -1);
                date = GetGlobalCalendar().AddDays(date, -date.Day + 1);
                cellNextPrev.RenderBeginTag(writer);
                writer.Write(BuildLink("V" + GetDaysFromZenith(date), GetNextPrevFormatText(date, false), cellNextPrev.ForeColor, enabled));
                cellNextPrev.RenderEndTag(writer);
            }

            // Current Month Table Data
            {
                DateTimeFormatInfo dti = DateInfo;
                string             str;
                TableCell          cellMonth = new TableCell();
                cellMonth.Width           = Unit.Percentage(70);
                cellMonth.HorizontalAlign = HorizontalAlign.Center;

                cellMonth.RenderBeginTag(writer);

                if (TitleFormat == TitleFormat.MonthYear)
                {
                    str = DisplayDate.ToString(dti.YearMonthPattern, dti);
                }
                else
                {
                    str = dti.GetMonthName(GetGlobalCalendar().GetMonth(DisplayDate));
                }

                writer.Write(str);
                cellMonth.RenderEndTag(writer);
            }

            if (ShowNextPrevMonth) // Next Table Data
            {
                DateTime date = GetGlobalCalendar().AddMonths(DisplayDate, +1);
                date = GetGlobalCalendar().AddDays(date, -date.Day + 1);

                cellNextPrev.HorizontalAlign = HorizontalAlign.Right;
                cellNextPrev.RenderBeginTag(writer);
                writer.Write(BuildLink("V" + GetDaysFromZenith(date), GetNextPrevFormatText(date, true), cellNextPrev.ForeColor, enabled));
                cellNextPrev.RenderEndTag(writer);
            }

            writer.RenderEndTag();
            tableTitle.RenderEndTag(writer);
            titleCell.RenderEndTag(writer);
            writer.RenderEndTag(); //tr
        }