void WriteTitle (HtmlTextWriter writer)
		{
			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

		}
        private void RenderTitle(HtmlTextWriter writer, DateTime visibleDate, CalendarSelectionMode selectionMode, bool buttonsActive, bool useAccessibleHeader)
        {
            string str4;
            writer.Write("<tr>");
            TableCell titleCell = new TableCell();
            Table titleTable = new Table();
            titleCell.ColumnSpan = this.HasWeekSelectors(selectionMode) ? 8 : 7;
            titleCell.BackColor = Color.Silver;
            titleTable.GridLines = GridLines.None;
            titleTable.Width = Unit.Percentage(100.0);
            titleTable.CellSpacing = 0;
            TableItemStyle titleStyle = this.TitleStyle;
            this.ApplyTitleStyle(titleCell, titleTable, titleStyle);
            titleCell.RenderBeginTag(writer);
            titleTable.RenderBeginTag(writer);
            writer.Write("<tr>");
            System.Web.UI.WebControls.NextPrevFormat nextPrevFormat = this.NextPrevFormat;
            TableItemStyle style = new TableItemStyle {
                Width = Unit.Percentage(15.0)
            };
            style.CopyFrom(this.NextPrevStyle);
            if (this.ShowNextPrevMonth)
            {
                if (this.IsMinSupportedYearMonth(visibleDate))
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    writer.RenderEndTag();
                }
                else
                {
                    string monthName;
                    DateTime minSupportedDate;
                    switch (nextPrevFormat)
                    {
                        case System.Web.UI.WebControls.NextPrevFormat.ShortMonth:
                        case System.Web.UI.WebControls.NextPrevFormat.FullMonth:
                        {
                            int month = this.threadCalendar.GetMonth(this.threadCalendar.AddMonths(visibleDate, -1));
                            monthName = this.GetMonthName(month, nextPrevFormat == System.Web.UI.WebControls.NextPrevFormat.FullMonth);
                            break;
                        }
                        default:
                            monthName = this.PrevMonthText;
                            break;
                    }
                    DateTime time2 = this.threadCalendar.AddMonths(this.minSupportedDate, 1);
                    if (this.IsTheSameYearMonth(time2, visibleDate))
                    {
                        minSupportedDate = this.minSupportedDate;
                    }
                    else
                    {
                        minSupportedDate = this.threadCalendar.AddMonths(visibleDate, -1);
                    }
                    string eventArgument = "V" + minSupportedDate.Subtract(baseDate).Days.ToString(CultureInfo.InvariantCulture);
                    string title = null;
                    if (useAccessibleHeader)
                    {
                        title = System.Web.SR.GetString("Calendar_PreviousMonthTitle");
                    }
                    this.RenderCalendarCell(writer, style, monthName, title, buttonsActive, eventArgument);
                }
            }
            TableItemStyle style3 = new TableItemStyle();
            if (titleStyle.HorizontalAlign != HorizontalAlign.NotSet)
            {
                style3.HorizontalAlign = titleStyle.HorizontalAlign;
            }
            else
            {
                style3.HorizontalAlign = HorizontalAlign.Center;
            }
            style3.Wrap = titleStyle.Wrap;
            style3.Width = Unit.Percentage(70.0);
            switch (this.TitleFormat)
            {
                case System.Web.UI.WebControls.TitleFormat.Month:
                    str4 = visibleDate.ToString("MMMM", CultureInfo.CurrentCulture);
                    break;

                default:
                {
                    string yearMonthPattern = DateTimeFormatInfo.CurrentInfo.YearMonthPattern;
                    if (yearMonthPattern.IndexOf(',') >= 0)
                    {
                        yearMonthPattern = "MMMM yyyy";
                    }
                    str4 = visibleDate.ToString(yearMonthPattern, CultureInfo.CurrentCulture);
                    break;
                }
            }
            this.RenderCalendarCell(writer, style3, str4, null, false, null);
            if (this.ShowNextPrevMonth)
            {
                if (this.IsMaxSupportedYearMonth(visibleDate))
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    writer.RenderEndTag();
                }
                else
                {
                    string nextMonthText;
                    style.HorizontalAlign = HorizontalAlign.Right;
                    switch (nextPrevFormat)
                    {
                        case System.Web.UI.WebControls.NextPrevFormat.ShortMonth:
                        case System.Web.UI.WebControls.NextPrevFormat.FullMonth:
                        {
                            int m = this.threadCalendar.GetMonth(this.threadCalendar.AddMonths(visibleDate, 1));
                            nextMonthText = this.GetMonthName(m, nextPrevFormat == System.Web.UI.WebControls.NextPrevFormat.FullMonth);
                            break;
                        }
                        default:
                            nextMonthText = this.NextMonthText;
                            break;
                    }
                    DateTime time3 = this.threadCalendar.AddMonths(visibleDate, 1);
                    string str7 = "V" + time3.Subtract(baseDate).Days.ToString(CultureInfo.InvariantCulture);
                    string str8 = null;
                    if (useAccessibleHeader)
                    {
                        str8 = System.Web.SR.GetString("Calendar_NextMonthTitle");
                    }
                    this.RenderCalendarCell(writer, style, nextMonthText, str8, buttonsActive, str7);
                }
            }
            writer.Write("</tr>");
            titleTable.RenderEndTag(writer);
            titleCell.RenderEndTag(writer);
            writer.Write("</tr>");
        }
Example #3
0
        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
        }
 protected internal override void Render(HtmlTextWriter writer)
 {
     bool isEnabled;
     this.threadCalendar = DateTimeFormatInfo.CurrentInfo.Calendar;
     this.minSupportedDate = this.threadCalendar.MinSupportedDateTime;
     this.maxSupportedDate = this.threadCalendar.MaxSupportedDateTime;
     DateTime visibleDate = this.EffectiveVisibleDate();
     DateTime firstDay = this.FirstCalendarDay(visibleDate);
     CalendarSelectionMode selectionMode = this.SelectionMode;
     if (this.Page != null)
     {
         this.Page.VerifyRenderingInServerForm(this);
     }
     if ((this.Page == null) || base.DesignMode)
     {
         isEnabled = false;
     }
     else
     {
         isEnabled = base.IsEnabled;
     }
     this.defaultForeColor = this.ForeColor;
     if (this.defaultForeColor == Color.Empty)
     {
         this.defaultForeColor = DefaultForeColor;
     }
     this.defaultButtonColorText = ColorTranslator.ToHtml(this.defaultForeColor);
     Table table = new Table();
     if (this.ID != null)
     {
         table.ID = this.ClientID;
     }
     table.CopyBaseAttributes(this);
     if (base.ControlStyleCreated)
     {
         table.ApplyStyle(base.ControlStyle);
     }
     table.Width = this.Width;
     table.Height = this.Height;
     table.CellPadding = this.CellPadding;
     table.CellSpacing = this.CellSpacing;
     if ((!base.ControlStyleCreated || !base.ControlStyle.IsSet(0x20)) || this.BorderWidth.Equals(Unit.Empty))
     {
         table.BorderWidth = Unit.Pixel(1);
     }
     if (this.ShowGridLines)
     {
         table.GridLines = GridLines.Both;
     }
     else
     {
         table.GridLines = GridLines.None;
     }
     bool useAccessibleHeader = this.UseAccessibleHeader;
     if (useAccessibleHeader && (table.Attributes["title"] == null))
     {
         table.Attributes["title"] = System.Web.SR.GetString("Calendar_TitleText");
     }
     string caption = this.Caption;
     if (caption.Length > 0)
     {
         table.Caption = caption;
         table.CaptionAlign = this.CaptionAlign;
     }
     table.RenderBeginTag(writer);
     if (this.ShowTitle)
     {
         this.RenderTitle(writer, visibleDate, selectionMode, isEnabled, useAccessibleHeader);
     }
     if (this.ShowDayHeader)
     {
         this.RenderDayHeader(writer, visibleDate, selectionMode, isEnabled, useAccessibleHeader);
     }
     this.RenderDays(writer, firstDay, visibleDate, selectionMode, isEnabled, useAccessibleHeader);
     table.RenderEndTag(writer);
 }
		protected override void Render(HtmlTextWriter writer)
		{
			globCal = DateTimeFormatInfo.CurrentInfo.Calendar;
			DateTime visDate   = GetEffectiveVisibleDate();
			DateTime firstDate = GetFirstCalendarDay(visDate);

			bool isEnabled;
			bool isHtmlTextWriter;
			//FIXME: when Control.Site works, reactivate this
			//if (Page == null || Site == null) {
			//	isEnabled = false;
			//	isHtmlTextWriter = false;
			//} else {
				isEnabled = Enabled;
				isHtmlTextWriter = (writer.GetType() != typeof(HtmlTextWriter));
			//}
			defaultTextColor = ForeColor;
			if(defaultTextColor == Color.Empty)
				defaultTextColor = Color.Black;

			Table calTable = new Table ();
			calTable.ID = ID;
			calTable.CopyBaseAttributes(this);
			if(ControlStyleCreated)
				calTable.ApplyStyle(ControlStyle);
			calTable.Width = Width;
			calTable.Height = Height;
			calTable.CellSpacing = CellSpacing;
			calTable.CellPadding = CellPadding;

			if (ControlStyleCreated &&
			    ControlStyle.IsSet (WebControls.Style.BORDERWIDTH) &&
			    BorderWidth != Unit.Empty)
				calTable.BorderWidth = BorderWidth;
			else
				calTable.BorderWidth = Unit.Pixel(1);

			if (ShowGridLines)
				calTable.GridLines = GridLines.Both;
			else
				calTable.GridLines = GridLines.None;
				
#if NET_2_0
			calTable.Caption = Caption;
			calTable.CaptionAlign = CaptionAlign;
#endif

			calTable.RenderBeginTag (writer);

			if (ShowTitle)
				RenderTitle (writer, visDate, SelectionMode, isEnabled);

			if (ShowDayHeader)
				RenderHeader (writer, firstDate, SelectionMode, isEnabled, isHtmlTextWriter);

			RenderAllDays (writer, firstDate, visDate, SelectionMode, isEnabled, isHtmlTextWriter);

			calTable.RenderEndTag(writer);
		}
		private void RenderTitle (HtmlTextWriter writer,
					  DateTime visibleDate,
					  CalendarSelectionMode mode,
					  bool isActive)
		{
			writer.Write("<tr>");
			Table innerTable = new Table ();
			TableCell titleCell = new TableCell();
			bool isWeekMode = (mode == CalendarSelectionMode.DayWeek ||
					   mode == CalendarSelectionMode.DayWeekMonth);

			titleCell.ColumnSpan = (isWeekMode ? 8 : 7);
			titleCell.BackColor = Color.Silver;

			innerTable.GridLines = GridLines.None;
			innerTable.Width = Unit.Percentage (100);
			innerTable.CellSpacing = 0;
			ApplyTitleStyle (innerTable, titleCell, TitleStyle);

			titleCell.RenderBeginTag (writer);
			innerTable.RenderBeginTag (writer);

			writer.Write ("<tr>");
			string prevContent = String.Empty;
			if (ShowNextPrevMonth) {
				TableCell prevCell = new TableCell ();
				prevCell.Width = Unit.Percentage (15);
				prevCell.HorizontalAlign = HorizontalAlign.Left;
				if (NextPrevFormat == NextPrevFormat.CustomText) {
					prevContent = PrevMonthText;
				} else {
					int pMthInt = globCal.GetMonth(globCal.AddMonths (visibleDate, -1));
					if (NextPrevFormat == NextPrevFormat.FullMonth)
						prevContent = infoCal.GetMonthName (pMthInt);
					else
						prevContent = infoCal.GetAbbreviatedMonthName (pMthInt);
				}
				DateTime prev_month = visibleDate.AddMonths (-1);
				int prev_offset = (int) (new DateTime (prev_month.Year,
									  prev_month.Month, 1) - begin_date).TotalDays;
				prevCell.ApplyStyle (NextPrevStyle);
				RenderCalendarCell (writer,
						    prevCell,
						    GetCalendarLinkText ("V" + prev_offset,
							    		 prevContent,
										 "Go to previous month",
									 NextPrevStyle.ForeColor,
									 isActive)
						    );
			}

			TableCell currCell = new TableCell ();
			currCell.Width = Unit.Percentage (70);
			if (TitleStyle.HorizontalAlign == HorizontalAlign.NotSet)
				currCell.HorizontalAlign = HorizontalAlign.Center;
			else
				currCell.HorizontalAlign = TitleStyle.HorizontalAlign;

			currCell.Wrap = TitleStyle.Wrap;
			string currMonthContent = String.Empty;
			if (TitleFormat == TitleFormat.Month) {
				currMonthContent = visibleDate.ToString ("MMMM");
			} else {
				string cmcFmt = infoCal.YearMonthPattern;
				if (cmcFmt.IndexOf (',') >= 0)
					cmcFmt = "MMMM yyyy";

				currMonthContent = visibleDate.ToString (cmcFmt);
			}

			RenderCalendarCell (writer, currCell, currMonthContent);
								 
			string nextContent = String.Empty;
			if (ShowNextPrevMonth) {
				TableCell nextCell = new TableCell ();
				nextCell.Width = Unit.Percentage(15);
				nextCell.HorizontalAlign = HorizontalAlign.Right;
				if (NextPrevFormat == NextPrevFormat.CustomText) {
					nextContent = NextMonthText;
				} else {
					int nMthInt = globCal.GetMonth (globCal.AddMonths (visibleDate, 1));
					if(NextPrevFormat == NextPrevFormat.FullMonth)
						nextContent = infoCal.GetMonthName(nMthInt);
					else
						nextContent = infoCal.GetAbbreviatedMonthName(nMthInt);
				}
				DateTime next_month = visibleDate.AddMonths (1);
				int next_offset = (int) (new DateTime (next_month.Year,
									  next_month.Month, 1) - begin_date).TotalDays;
				nextCell.ApplyStyle(NextPrevStyle);
				RenderCalendarCell (writer,
						    nextCell,
						    GetCalendarLinkText ("V" + next_offset,
									 nextContent,
									 "Go to next month",
									 NextPrevStyle.ForeColor,
									 isActive)
						    );
			}

			writer.Write("</tr>");
			innerTable.RenderEndTag(writer);
			titleCell.RenderEndTag(writer);

			writer.Write("</tr>");
		}
Example #7
0
        /// <devdoc>
        /// </devdoc>
        private void RenderTitle(HtmlTextWriter writer, DateTime visibleDate, CalendarSelectionMode selectionMode, bool buttonsActive, bool useAccessibleHeader) {
            writer.Write(ROWBEGINTAG);

            TableCell titleCell = new TableCell();
            Table titleTable = new Table();

            // default title table/cell styles
            titleCell.ColumnSpan = HasWeekSelectors(selectionMode) ? 8 : 7;
            titleCell.BackColor = Color.Silver;
            titleTable.GridLines = GridLines.None;
            titleTable.Width = Unit.Percentage(100);
            titleTable.CellSpacing = 0;

            TableItemStyle titleStyle = TitleStyle;
            ApplyTitleStyle(titleCell, titleTable, titleStyle);

            titleCell.RenderBeginTag(writer);
            titleTable.RenderBeginTag(writer);
            writer.Write(ROWBEGINTAG);

            NextPrevFormat nextPrevFormat = NextPrevFormat;

            TableItemStyle nextPrevStyle = new TableItemStyle();
            nextPrevStyle.Width = Unit.Percentage(15);
            nextPrevStyle.CopyFrom(NextPrevStyle);
            if (ShowNextPrevMonth) {
                if (IsMinSupportedYearMonth(visibleDate)) {
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    writer.RenderEndTag();
                }
                else {
                    string prevMonthText;
                    if (nextPrevFormat == NextPrevFormat.ShortMonth || nextPrevFormat == NextPrevFormat.FullMonth) {
                        int monthNo = threadCalendar.GetMonth(threadCalendar.AddMonths(visibleDate, - 1));
                        prevMonthText = GetMonthName(monthNo, (nextPrevFormat == NextPrevFormat.FullMonth));
                    }
                    else {
                        prevMonthText = PrevMonthText;
                    }
                    // Month navigation. The command starts with a "V" and the remainder is day difference from the
                    // base date.
                    DateTime prevMonthDate;

                    // VSWhidbey 366243: Some calendar's min supported date is
                    // not the first day of the month (e.g. JapaneseCalendar.
                    // So if we are setting the second supported month, the prev
                    // month link should always point to the first supported
                    // date instead of the first day of the previous month.
                    DateTime secondSupportedMonth = threadCalendar.AddMonths(minSupportedDate, 1);
                    if (IsTheSameYearMonth(secondSupportedMonth, visibleDate)) {
                        prevMonthDate = minSupportedDate;
                    }
                    else {
                        prevMonthDate = threadCalendar.AddMonths(visibleDate, -1);
                    }

                    string prevMonthKey = NAVIGATE_MONTH_COMMAND + (prevMonthDate.Subtract(baseDate)).Days.ToString(CultureInfo.InvariantCulture);

                    string previousMonthTitle = null;
                    if (useAccessibleHeader) {
                        previousMonthTitle = SR.GetString(SR.Calendar_PreviousMonthTitle);
                    }
                    RenderCalendarCell(writer, nextPrevStyle, prevMonthText, previousMonthTitle, buttonsActive, prevMonthKey);
                }
            }


            TableItemStyle cellMainStyle = new TableItemStyle();

            if (titleStyle.HorizontalAlign != HorizontalAlign.NotSet) {
                cellMainStyle.HorizontalAlign = titleStyle.HorizontalAlign;
            }
            else {
                cellMainStyle.HorizontalAlign = HorizontalAlign.Center;
            }
            cellMainStyle.Wrap = titleStyle.Wrap;
            cellMainStyle.Width = Unit.Percentage(70);

            string titleText;

            switch (TitleFormat) {
                case TitleFormat.Month:
                    titleText = visibleDate.ToString("MMMM", CultureInfo.CurrentCulture);
                    break;
                case TitleFormat.MonthYear:
                    string titlePattern = DateTimeFormatInfo.CurrentInfo.YearMonthPattern;
                    // Some cultures have a comma in their YearMonthPattern, which does not look
                    // right in a calendar. Use a fixed pattern for those.
                    if (titlePattern.IndexOf(',') >= 0) {
                        titlePattern = "MMMM yyyy";
                    }
                    titleText = visibleDate.ToString(titlePattern, CultureInfo.CurrentCulture);
                    break;
                default:
                    Debug.Assert(false, "Unknown TitleFormat value!");
                    goto case TitleFormat.MonthYear;
            }
            RenderCalendarCell(writer, cellMainStyle, titleText, null, false, null);

            if (ShowNextPrevMonth) {
                if (IsMaxSupportedYearMonth(visibleDate)) {
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    writer.RenderEndTag();
                }
                else {
                    // Style for this one is identical bar
                    nextPrevStyle.HorizontalAlign = HorizontalAlign.Right;
                    string nextMonthText;
                    if (nextPrevFormat == NextPrevFormat.ShortMonth || nextPrevFormat == NextPrevFormat.FullMonth) {
                        int monthNo = threadCalendar.GetMonth(threadCalendar.AddMonths(visibleDate, 1));
                        nextMonthText = GetMonthName(monthNo, (nextPrevFormat == NextPrevFormat.FullMonth));
                    }
                    else {
                        nextMonthText = NextMonthText;
                    }
                    // Month navigation. The command starts with a "V" and the remainder is day difference from the
                    // base date.
                    DateTime nextMonthDate = threadCalendar.AddMonths(visibleDate, 1);
                    string nextMonthKey = NAVIGATE_MONTH_COMMAND + (nextMonthDate.Subtract(baseDate)).Days.ToString(CultureInfo.InvariantCulture);

                    string nextMonthTitle = null;
                    if (useAccessibleHeader) {
                        nextMonthTitle = SR.GetString(SR.Calendar_NextMonthTitle);
                    }
                    RenderCalendarCell(writer, nextPrevStyle, nextMonthText, nextMonthTitle, buttonsActive, nextMonthKey);
                }
            }
            writer.Write(ROWENDTAG);
            titleTable.RenderEndTag(writer);
            titleCell.RenderEndTag(writer);
            writer.Write(ROWENDTAG);

        }
Example #8
0
        /// <internalonly/>
        /// <devdoc>
        /// <para>Displays the <see cref='System.Web.UI.WebControls.Calendar'/> control on the client.</para>
        /// </devdoc>
        protected internal override void Render(HtmlTextWriter writer) {
            threadCalendar = DateTimeFormatInfo.CurrentInfo.Calendar;
            minSupportedDate = threadCalendar.MinSupportedDateTime;
            maxSupportedDate = threadCalendar.MaxSupportedDateTime;
#if DEBUG
            threadCalendarInitialized = true;
#endif
            DateTime visibleDate = EffectiveVisibleDate();
            DateTime firstDay = FirstCalendarDay(visibleDate);
            CalendarSelectionMode selectionMode = SelectionMode;

            // Make sure we are in a form tag with runat=server.
            if (Page != null) {
                Page.VerifyRenderingInServerForm(this);
            }

            // We only want to display the link if we have a page, or if we are on the design surface
            // If we can stops links being active on the Autoformat dialog, then we can remove this these checks.
            Page page = Page;
            bool buttonsActive;
            if (page == null || DesignMode) {
                buttonsActive = false;
            }
            else {
                buttonsActive = IsEnabled;
            }

            defaultForeColor = ForeColor;
            if (defaultForeColor == Color.Empty) {
                defaultForeColor = DefaultForeColor;
            }
            defaultButtonColorText = ColorTranslator.ToHtml(defaultForeColor);

            Table table = new Table();

            if (ID != null) {
                table.ID = ClientID;
            }
            table.CopyBaseAttributes(this);
            if (ControlStyleCreated) {
                table.ApplyStyle(ControlStyle);
            }
            table.Width = Width;
            table.Height = Height;
            table.CellPadding = CellPadding;
            table.CellSpacing = CellSpacing;

            // default look
            if ((ControlStyleCreated == false) ||
                (ControlStyle.IsSet(System.Web.UI.WebControls.Style.PROP_BORDERWIDTH) == false) ||
                BorderWidth.Equals(Unit.Empty)) {
                table.BorderWidth = Unit.Pixel(1);
            }

            if (ShowGridLines) {
                table.GridLines = GridLines.Both;
            }
            else {
                table.GridLines = GridLines.None;
            }

            bool useAccessibleHeader = UseAccessibleHeader;
            if (useAccessibleHeader) {
                if (table.Attributes["title"] == null) {
                    table.Attributes["title"] = SR.GetString(SR.Calendar_TitleText);
                }
            }

            string caption = Caption;
            if (caption.Length > 0) {
                table.Caption = caption;
                table.CaptionAlign = CaptionAlign;
            }

            table.RenderBeginTag(writer);

            if (ShowTitle) {
                RenderTitle(writer, visibleDate, selectionMode, buttonsActive, useAccessibleHeader);
            }

            if (ShowDayHeader) {
                RenderDayHeader(writer, visibleDate, selectionMode, buttonsActive, useAccessibleHeader);
            }

            RenderDays(writer, firstDay, visibleDate, selectionMode, buttonsActive, useAccessibleHeader);

            table.RenderEndTag(writer);
        }