private void RenderDays(HtmlTextWriter writer, DateTime firstDay, DateTime visibleDate, CalendarSelectionMode selectionMode, bool buttonsActive, bool useAccessibleHeader)
 {
     Unit unit;
     DateTime time = firstDay;
     TableItemStyle style = null;
     bool flag = this.HasWeekSelectors(selectionMode);
     if (flag)
     {
         style = new TableItemStyle {
             Width = Unit.Percentage(12.0),
             HorizontalAlign = HorizontalAlign.Center
         };
         style.CopyFrom(this.SelectorStyle);
         unit = Unit.Percentage(12.0);
     }
     else
     {
         unit = Unit.Percentage(14.0);
     }
     bool flag2 = !(this.threadCalendar is HebrewCalendar);
     bool flag3 = (base.GetType() != typeof(System.Web.UI.WebControls.Calendar)) || (base.Events[EventDayRender] != null);
     TableItemStyle[] styleArray = new TableItemStyle[0x10];
     int definedStyleMask = this.GetDefinedStyleMask();
     DateTime todaysDate = this.TodaysDate;
     string selectWeekText = this.SelectWeekText;
     bool hasButton = buttonsActive && (selectionMode != CalendarSelectionMode.None);
     int month = this.threadCalendar.GetMonth(visibleDate);
     int days = firstDay.Subtract(baseDate).Days;
     bool flag5 = base.DesignMode && (this.SelectionMode != CalendarSelectionMode.None);
     int num4 = 0;
     if (this.IsMinSupportedYearMonth(visibleDate))
     {
         num4 = ((int) this.threadCalendar.GetDayOfWeek(firstDay)) - this.NumericFirstDayOfWeek();
         if (num4 < 0)
         {
             num4 += 7;
         }
     }
     bool flag6 = false;
     DateTime time3 = this.threadCalendar.AddMonths(this.maxSupportedDate, -1);
     bool flag7 = this.IsMaxSupportedYearMonth(visibleDate) || this.IsTheSameYearMonth(time3, visibleDate);
     for (int i = 0; i < 6; i++)
     {
         if (flag6)
         {
             return;
         }
         writer.Write("<tr>");
         if (flag)
         {
             int num6 = (days * 100) + 7;
             if (num4 > 0)
             {
                 num6 -= num4;
             }
             else if (flag7)
             {
                 int num7 = this.maxSupportedDate.Subtract(time).Days;
                 if (num7 < 6)
                 {
                     num6 -= 6 - num7;
                 }
             }
             string eventArgument = "R" + num6.ToString(CultureInfo.InvariantCulture);
             string title = null;
             if (useAccessibleHeader)
             {
                 int num8 = i + 1;
                 title = System.Web.SR.GetString("Calendar_SelectWeekTitle", new object[] { num8.ToString(CultureInfo.InvariantCulture) });
             }
             this.RenderCalendarCell(writer, style, selectWeekText, title, buttonsActive, eventArgument);
         }
         for (int j = 0; j < 7; j++)
         {
             string str4;
             if (num4 > 0)
             {
                 j += num4;
                 while (num4 > 0)
                 {
                     writer.RenderBeginTag(HtmlTextWriterTag.Td);
                     writer.RenderEndTag();
                     num4--;
                 }
             }
             else if (flag6)
             {
                 while (j < 7)
                 {
                     writer.RenderBeginTag(HtmlTextWriterTag.Td);
                     writer.RenderEndTag();
                     j++;
                 }
                 break;
             }
             int dayOfWeek = (int) this.threadCalendar.GetDayOfWeek(time);
             int dayOfMonth = this.threadCalendar.GetDayOfMonth(time);
             if ((dayOfMonth <= 0x1f) && flag2)
             {
                 str4 = cachedNumbers[dayOfMonth];
             }
             else
             {
                 str4 = time.ToString("dd", CultureInfo.CurrentCulture);
             }
             CalendarDay day = new CalendarDay(time, (dayOfWeek == 0) || (dayOfWeek == 6), time.Equals(todaysDate), (this.selectedDates != null) && this.selectedDates.Contains(time), this.threadCalendar.GetMonth(time) != month, str4);
             int num12 = 0x10;
             if (day.IsSelected)
             {
                 num12 |= 8;
             }
             if (day.IsOtherMonth)
             {
                 num12 |= 2;
             }
             if (day.IsToday)
             {
                 num12 |= 4;
             }
             if (day.IsWeekend)
             {
                 num12 |= 1;
             }
             int styleMask = definedStyleMask & num12;
             int index = styleMask & 15;
             TableItemStyle style2 = styleArray[index];
             if (style2 == null)
             {
                 style2 = new TableItemStyle();
                 this.SetDayStyles(style2, styleMask, unit);
                 styleArray[index] = style2;
             }
             string str5 = null;
             if (useAccessibleHeader)
             {
                 str5 = time.ToString("m", CultureInfo.CurrentCulture);
             }
             if (flag3)
             {
                 TableCell cell = new TableCell();
                 cell.ApplyStyle(style2);
                 LiteralControl child = new LiteralControl(str4);
                 cell.Controls.Add(child);
                 day.IsSelectable = hasButton;
                 this.OnDayRender(cell, day);
                 child.Text = this.GetCalendarButtonText(days.ToString(CultureInfo.InvariantCulture), str4, str5, buttonsActive && day.IsSelectable, cell.ForeColor);
                 cell.RenderControl(writer);
             }
             else
             {
                 if (flag5 && style2.ForeColor.IsEmpty)
                 {
                     style2.ForeColor = this.defaultForeColor;
                 }
                 this.RenderCalendarCell(writer, style2, str4, str5, hasButton, days.ToString(CultureInfo.InvariantCulture));
             }
             if ((flag7 && (time.Month == this.maxSupportedDate.Month)) && (time.Day == this.maxSupportedDate.Day))
             {
                 flag6 = true;
             }
             else
             {
                 time = this.threadCalendar.AddDays(time, 1);
                 days++;
             }
         }
         writer.Write("</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>");
        }
 protected bool HasWeekSelectors(CalendarSelectionMode selectionMode)
 {
     if (selectionMode != CalendarSelectionMode.DayWeek)
     {
         return (selectionMode == CalendarSelectionMode.DayWeekMonth);
     }
     return true;
 }
        private void RenderDayHeader(HtmlTextWriter writer, DateTime visibleDate, CalendarSelectionMode selectionMode, bool buttonsActive, bool useAccessibleHeader)
        {
            writer.Write("<tr>");
            DateTimeFormatInfo currentInfo = DateTimeFormatInfo.CurrentInfo;
            if (this.HasWeekSelectors(selectionMode))
            {
                TableItemStyle style = new TableItemStyle {
                    HorizontalAlign = HorizontalAlign.Center
                };
                if (selectionMode == CalendarSelectionMode.DayWeekMonth)
                {
                    int days = visibleDate.Subtract(baseDate).Days;
                    int dayOfMonth = this.threadCalendar.GetDaysInMonth(this.threadCalendar.GetYear(visibleDate), this.threadCalendar.GetMonth(visibleDate), this.threadCalendar.GetEra(visibleDate));
                    if (this.IsMinSupportedYearMonth(visibleDate))
                    {
                        dayOfMonth = (dayOfMonth - this.threadCalendar.GetDayOfMonth(visibleDate)) + 1;
                    }
                    else if (this.IsMaxSupportedYearMonth(visibleDate))
                    {
                        dayOfMonth = this.threadCalendar.GetDayOfMonth(this.maxSupportedDate);
                    }
                    string eventArgument = "R" + (((days * 100) + dayOfMonth)).ToString(CultureInfo.InvariantCulture);
                    style.CopyFrom(this.SelectorStyle);
                    string title = null;
                    if (useAccessibleHeader)
                    {
                        title = System.Web.SR.GetString("Calendar_SelectMonthTitle");
                    }
                    this.RenderCalendarCell(writer, style, this.SelectMonthText, title, buttonsActive, eventArgument);
                }
                else
                {
                    style.CopyFrom(this.DayHeaderStyle);
                    this.RenderCalendarCell(writer, style, string.Empty, null, false, null);
                }
            }
            TableItemStyle style2 = new TableItemStyle {
                HorizontalAlign = HorizontalAlign.Center
            };
            style2.CopyFrom(this.DayHeaderStyle);
            System.Web.UI.WebControls.DayNameFormat dayNameFormat = this.DayNameFormat;
            int num3 = this.NumericFirstDayOfWeek();
            for (int i = num3; i < (num3 + 7); i++)
            {
                string dayName;
                int num5 = i % 7;
                switch (dayNameFormat)
                {
                    case System.Web.UI.WebControls.DayNameFormat.Full:
                        dayName = currentInfo.GetDayName((DayOfWeek) num5);
                        break;

                    case System.Web.UI.WebControls.DayNameFormat.FirstLetter:
                        dayName = currentInfo.GetDayName((DayOfWeek) num5).Substring(0, 1);
                        break;

                    case System.Web.UI.WebControls.DayNameFormat.FirstTwoLetters:
                        dayName = currentInfo.GetDayName((DayOfWeek) num5).Substring(0, 2);
                        break;

                    case System.Web.UI.WebControls.DayNameFormat.Shortest:
                        dayName = currentInfo.GetShortestDayName((DayOfWeek) num5);
                        break;

                    default:
                        dayName = currentInfo.GetAbbreviatedDayName((DayOfWeek) num5);
                        break;
                }
                if (useAccessibleHeader)
                {
                    string abbrText = currentInfo.GetDayName((DayOfWeek) num5);
                    this.RenderCalendarHeaderCell(writer, style2, dayName, abbrText);
                }
                else
                {
                    this.RenderCalendarCell(writer, style2, dayName, null, false, null);
                }
            }
            writer.Write("</tr>");
        }
Exemplo n.º 5
0
        protected virtual void OnRenderTitle(HtmlTextWriter writer, DateTime visibleDate, CalendarSelectionMode selectionMode, bool buttonsActive)
        {
            string renderingTitle;

            writer.Write("<tr>");

            var titleCell = new TableCell
            {
                ColumnSpan = (this.HasWeekSelectors(selectionMode) ? 8 : 7),
                BackColor  = Color.Silver
            };

            var titleTable = CreateTable();

            titleTable.GridLines   = GridLines.None;
            titleTable.Width       = Unit.Percentage(100.0);
            titleTable.CellSpacing = 0;

            var titleStyle = this.TitleStyle;

            this.ApplyTitleStyle(titleCell, titleTable, titleStyle);
            titleCell.RenderBeginTag(writer);
            titleTable.RenderBeginTag(writer);
            writer.Write("<tr>");

            if (this.ShowNextPrevMonth)
            {
                RenderPreviousMonthNav(writer, visibleDate, buttonsActive);
            }

            RenderMonthTitle(writer, titleStyle, visibleDate);

            if (this.ShowNextPrevMonth)
            {
                RenderNextMonthNav(writer, visibleDate, buttonsActive);
            }

            writer.Write("</tr>");
            titleTable.RenderEndTag(writer);
            titleCell.RenderEndTag(writer);
            writer.Write("</tr>");
        }
Exemplo n.º 6
0
        /// <devdoc>
        /// </devdoc>
        private void RenderDayHeader(HtmlTextWriter writer, DateTime visibleDate, CalendarSelectionMode selectionMode, bool buttonsActive, bool useAccessibleHeader) {

            writer.Write(ROWBEGINTAG);

            DateTimeFormatInfo dtf = DateTimeFormatInfo.CurrentInfo;

            if (HasWeekSelectors(selectionMode)) {
                TableItemStyle monthSelectorStyle = new TableItemStyle();
                monthSelectorStyle.HorizontalAlign = HorizontalAlign.Center;
                // add the month selector button if required;
                if (selectionMode == CalendarSelectionMode.DayWeekMonth) {

                    // Range selection. The command starts with an "R". The remainder is an integer. When divided by 100
                    // the result is the day difference from the base date of the first day, and the remainder is the
                    // number of days to select.
                    int startOffset = visibleDate.Subtract(baseDate).Days;
                    int monthLength = threadCalendar.GetDaysInMonth(threadCalendar.GetYear(visibleDate), threadCalendar.GetMonth(visibleDate), threadCalendar.GetEra(visibleDate));
                    if (IsMinSupportedYearMonth(visibleDate)) {
                        // The first supported month might not start with day 1
                        // (e.g. Sept 8 is the first supported date of JapaneseCalendar)
                        monthLength = monthLength - threadCalendar.GetDayOfMonth(visibleDate) + 1;
                    }
                    else if (IsMaxSupportedYearMonth(visibleDate)) {
                        // The last supported month might not have all days supported in that calendar month
                        // (e.g. April 3 is the last supported date of HijriCalendar)
                        monthLength = threadCalendar.GetDayOfMonth(maxSupportedDate);
                    }

                    string monthSelectKey = SELECT_RANGE_COMMAND + ((startOffset * 100) + monthLength).ToString(CultureInfo.InvariantCulture);
                    monthSelectorStyle.CopyFrom(SelectorStyle);

                    string selectMonthTitle = null;
                    if (useAccessibleHeader) {
                        selectMonthTitle = SR.GetString(SR.Calendar_SelectMonthTitle);
                    }
                    RenderCalendarCell(writer, monthSelectorStyle, SelectMonthText, selectMonthTitle, buttonsActive, monthSelectKey);
                }
                else {
                    // otherwise make it look like the header row
                    monthSelectorStyle.CopyFrom(DayHeaderStyle);
                    RenderCalendarCell(writer, monthSelectorStyle, string.Empty, null, false, null);
                }
            }

            TableItemStyle dayNameStyle = new TableItemStyle();
            dayNameStyle.HorizontalAlign = HorizontalAlign.Center;
            dayNameStyle.CopyFrom(DayHeaderStyle);
            DayNameFormat dayNameFormat = DayNameFormat;

            int numericFirstDay = NumericFirstDayOfWeek();
            for (int i = numericFirstDay; i < numericFirstDay + 7; i++) {
                string dayName;
                int dayOfWeek = i % 7;
                switch (dayNameFormat) {
                    case DayNameFormat.FirstLetter:
                        dayName = dtf.GetDayName((DayOfWeek)dayOfWeek).Substring(0, 1);
                        break;
                    case DayNameFormat.FirstTwoLetters:
                        dayName = dtf.GetDayName((DayOfWeek)dayOfWeek).Substring(0, 2);
                        break;
                    case DayNameFormat.Full:
                        dayName = dtf.GetDayName((DayOfWeek)dayOfWeek);
                        break;
                    case DayNameFormat.Short:
                        dayName = dtf.GetAbbreviatedDayName((DayOfWeek)dayOfWeek);
                        break;
                    case DayNameFormat.Shortest:
                        dayName = dtf.GetShortestDayName((DayOfWeek)dayOfWeek);
                        break;
                    default:
                        Debug.Assert(false, "Unknown DayNameFormat value!");
                        goto case DayNameFormat.Short;
                }

                if (useAccessibleHeader) {
                    string fullDayName = dtf.GetDayName((DayOfWeek)dayOfWeek);
                    RenderCalendarHeaderCell(writer, dayNameStyle, dayName, fullDayName);
                }
                else {
                    RenderCalendarCell(writer, dayNameStyle, dayName, null, false, null);
                }
            }
            writer.Write(ROWENDTAG);
        }
Exemplo n.º 7
0
		/// <remarks>
		/// Refers to the second line of the calendar, that contains a link
		/// to select whole month, and weekdays as defined by DayNameFormat
		/// </remarks>
		private void RenderHeader (HtmlTextWriter writer,
					   DateTime firstDay,
					   CalendarSelectionMode mode,
					   bool isActive,
					   bool isDownLevel)
		{
			writer.Write("<tr>");
			bool isWeekMode = (mode == CalendarSelectionMode.DayWeek ||
					   mode == CalendarSelectionMode.DayWeekMonth);

			TableCell headerCell = new TableCell ();
			headerCell.HorizontalAlign = HorizontalAlign.Center;
			string selMthText = String.Empty;
			if (isWeekMode) {
				if (mode == CalendarSelectionMode.DayWeekMonth) {
					DateTime visDate = GetEffectiveVisibleDate ();
					DateTime sel_month = new DateTime (visDate.Year, visDate.Month, 1);
					int month_offset = (int) (sel_month - begin_date).TotalDays;
					headerCell.ApplyStyle (SelectorStyle);
					selMthText = GetCalendarLinkText ("R" + month_offset +
							globCal.GetDaysInMonth (sel_month.Year,
									sel_month.Month).ToString ("d2"), // maybe there are calendars with less then 10 days in a month
									  SelectMonthText,
									  "Select the whole month",
									  SelectorStyle.ForeColor,
									  isActive);
				} else {
					headerCell.ApplyStyle (DayHeaderStyle);
					selMthText = String.Empty;
				}
				RenderCalendarCell (writer, headerCell, selMthText);
			}

			TableCell dayHeaderCell = new TableCell ();
			dayHeaderCell.HorizontalAlign = HorizontalAlign.Center;
			dayHeaderCell.ApplyStyle (dayHeaderStyle);

			int dayOfWeek = (int) globCal.GetDayOfWeek (firstDay);
			DateTimeFormatInfo currDTInfo = DateTimeFormatInfo.CurrentInfo;
			for(int currDay = dayOfWeek; currDay < dayOfWeek + 7; currDay++) {
				DayOfWeek effDay = (DayOfWeek) Enum.ToObject (typeof (DayOfWeek), currDay % 7);
				string currDayContent;
				switch(DayNameFormat) {
				case DayNameFormat.Full:
					currDayContent = currDTInfo.GetDayName (effDay);
					break;
				case DayNameFormat.FirstLetter:
					currDayContent = currDTInfo.GetDayName (effDay).Substring (0,1);
					break;
				case DayNameFormat.FirstTwoLetters:
					currDayContent = currDTInfo.GetDayName (effDay).Substring (0,2);
					break;
				case DayNameFormat.Short:
					goto default;
				default:
					currDayContent = currDTInfo.GetAbbreviatedDayName (effDay);
					break;
				}

				RenderCalendarHeaderCell (writer, dayHeaderCell, currDayContent, currDTInfo.GetDayName (effDay));
			}
			writer.Write ("</tr>");
		}
 public static T SelectionMode <T>(this T source, CalendarSelectionMode value) where T : Calendar
 {
     source.SelectionMode = value;
     return(source);
 }
 protected bool HasWeekSelectors(CalendarSelectionMode selectionMode)
 {
   return default(bool);
 }
Exemplo n.º 10
0
        public DateNavigatorViewModel()
        {
            InitializeCultures();

            SelectionMode = CalendarSelectionMode.Single;
        }
 protected bool HasWeekSelectors(CalendarSelectionMode selectionMode)
 {
     return(default(bool));
 }
Exemplo n.º 12
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);

        }
Exemplo n.º 13
0
        /// <devdoc>
        /// </devdoc>
        private void RenderDays(HtmlTextWriter writer, DateTime firstDay, DateTime visibleDate, CalendarSelectionMode selectionMode, bool buttonsActive, bool useAccessibleHeader) {
            // Now add the rows for the actual days

            DateTime d = firstDay;
            TableItemStyle weekSelectorStyle = null;
            Unit defaultWidth;
            bool hasWeekSelectors = HasWeekSelectors(selectionMode);
            if (hasWeekSelectors) {
                weekSelectorStyle = new TableItemStyle();
                weekSelectorStyle.Width = Unit.Percentage(12);
                weekSelectorStyle.HorizontalAlign = HorizontalAlign.Center;
                weekSelectorStyle.CopyFrom(SelectorStyle);
                defaultWidth = Unit.Percentage(12);
            }
            else {
                defaultWidth = Unit.Percentage(14);
            }

            // This determines whether we need to call DateTime.ToString for each day. The only culture/calendar
            // that requires this for now is the HebrewCalendar.
            bool usesStandardDayDigits = !(threadCalendar is HebrewCalendar);

            // This determines whether we can write out cells directly, or whether we have to create whole
            // TableCell objects for each day.
            bool hasRenderEvent = (this.GetType() != typeof(Calendar)
                                   || Events[EventDayRender] != null);

            TableItemStyle [] cellStyles = new TableItemStyle[16];
            int definedStyleMask = GetDefinedStyleMask();
            DateTime todaysDate = TodaysDate;
            string selectWeekText = SelectWeekText;
            bool daysSelectable = buttonsActive && (selectionMode != CalendarSelectionMode.None);
            int visibleDateMonth = threadCalendar.GetMonth(visibleDate);
            int absoluteDay = firstDay.Subtract(baseDate).Days;

            // VSWhidbey 480155: flag to indicate if forecolor needs to be set
            // explicitly in design mode to mimic runtime rendering with the
            // limitation of not supporting CSS class color setting.
            bool inDesignSelectionMode = (DesignMode && SelectionMode != CalendarSelectionMode.None);

            //------------------------------------------------------------------
            // VSWhidbey 366243: The following variables are for boundary cases
            // such as the current visible month is the first or the last
            // supported month.  They are used in the 'for' loops below.

            // For the first supported month, calculate how many days to
            // skip at the beginning of the first month.  E.g. JapaneseCalendar
            // starts at Sept 8.
            int numOfFirstDaysToSkip = 0;
            if (IsMinSupportedYearMonth(visibleDate)) {
                numOfFirstDaysToSkip = (int)threadCalendar.GetDayOfWeek(firstDay) - NumericFirstDayOfWeek();
                // If negative, it simply means the the index of the starting
                // day name is greater than the day name of the first supported
                // date.  We add back 7 to get the number of days to skip.
                if (numOfFirstDaysToSkip < 0) {
                    numOfFirstDaysToSkip += 7;
                }
            }
            Debug.Assert(numOfFirstDaysToSkip < 7);

            // For the last or second last supported month, initialize variables
            // to identify the last supported date of the current calendar.
            // e.g. The last supported date of HijriCalendar is April 3.  When
            // the second last monthh is shown, it can be the case that not all
            // cells will be filled up.
            bool passedLastSupportedDate = false;
            DateTime secondLastMonth = threadCalendar.AddMonths(maxSupportedDate, -1);
            bool lastOrSecondLastMonth = (IsMaxSupportedYearMonth(visibleDate) ||
                                IsTheSameYearMonth(secondLastMonth, visibleDate));
            //------------------------------------------------------------------

            for (int iRow = 0; iRow < 6; iRow++) {
                if (passedLastSupportedDate) {
                    break;
                }

                writer.Write(ROWBEGINTAG);

                // add week selector column and button if required
                if (hasWeekSelectors) {
                    // Range selection. The command starts with an "R". The remainder is an integer. When divided by 100
                    // the result is the day difference from the base date of the first day, and the remainder is the
                    // number of days to select.
                    int dayDiffParameter = (absoluteDay * 100) + 7;

                    // Adjust the dayDiff for the first or the last supported month
                    if (numOfFirstDaysToSkip > 0) {
                        dayDiffParameter -= numOfFirstDaysToSkip;
                    }
                    else if (lastOrSecondLastMonth) {
                        int daysFromLastDate = maxSupportedDate.Subtract(d).Days;
                        if (daysFromLastDate < 6) {
                            dayDiffParameter -= (6 - daysFromLastDate);
                        }
                    }
                    string weekSelectKey = SELECT_RANGE_COMMAND + dayDiffParameter.ToString(CultureInfo.InvariantCulture);

                    string selectWeekTitle = null;
                    if (useAccessibleHeader) {
                        int weekOfMonth = iRow + 1;
                        selectWeekTitle = SR.GetString(SR.Calendar_SelectWeekTitle, weekOfMonth.ToString(CultureInfo.InvariantCulture));
                    }
                    RenderCalendarCell(writer, weekSelectorStyle, selectWeekText, selectWeekTitle, buttonsActive, weekSelectKey);
                }

                for (int iDay = 0; iDay < 7; iDay++) {

                    // Render empty cells for special cases to handle the first
                    // or last supported month.
                    if (numOfFirstDaysToSkip > 0) {
                        iDay += numOfFirstDaysToSkip;
                        for ( ; numOfFirstDaysToSkip > 0; numOfFirstDaysToSkip--) {
                            writer.RenderBeginTag(HtmlTextWriterTag.Td);
                            writer.RenderEndTag();
                        }
                    }
                    else if (passedLastSupportedDate) {
                        for ( ; iDay < 7; iDay++) {
                            writer.RenderBeginTag(HtmlTextWriterTag.Td);
                            writer.RenderEndTag();
                        }
                        break;
                    }

                    int dayOfWeek = (int)threadCalendar.GetDayOfWeek(d);
                    int dayOfMonth = threadCalendar.GetDayOfMonth(d);
                    string dayNumberText;
                    if ((dayOfMonth <= cachedNumberMax) && usesStandardDayDigits) {
                        dayNumberText = cachedNumbers[dayOfMonth];
                    }
                    else {
                        dayNumberText = d.ToString("dd", CultureInfo.CurrentCulture);
                    }

                    CalendarDay day = new CalendarDay(d,
                                                      (dayOfWeek == 0 || dayOfWeek == 6), // IsWeekend
                                                      d.Equals(todaysDate), // IsToday
                                                      (selectedDates != null) && selectedDates.Contains(d), // IsSelected
                                                      threadCalendar.GetMonth(d) != visibleDateMonth, // IsOtherMonth
                                                      dayNumberText // Number Text
                                                      );

                    int styleMask = STYLEMASK_DAY;
                    if (day.IsSelected)
                        styleMask |= STYLEMASK_SELECTED;
                    if (day.IsOtherMonth)
                        styleMask |= STYLEMASK_OTHERMONTH;
                    if (day.IsToday)
                        styleMask |= STYLEMASK_TODAY;
                    if (day.IsWeekend)
                        styleMask |= STYLEMASK_WEEKEND;
                    int dayStyleMask = definedStyleMask  & styleMask;
                    // determine the unique portion of the mask for the current calendar,
                    // which will strip out the day style bit
                    int dayStyleID = dayStyleMask & STYLEMASK_UNIQUE;

                    TableItemStyle cellStyle = cellStyles[dayStyleID];
                    if (cellStyle == null) {
                        cellStyle = new TableItemStyle();
                        SetDayStyles(cellStyle, dayStyleMask, defaultWidth);
                        cellStyles[dayStyleID] = cellStyle;
                    }


                    string dayTitle = null;
                    if (useAccessibleHeader) {
                        dayTitle = d.ToString("m", CultureInfo.CurrentCulture);
                    }

                    if (hasRenderEvent) {

                        TableCell cdc = new TableCell();
                        cdc.ApplyStyle(cellStyle);

                        LiteralControl dayContent = new LiteralControl(dayNumberText);
                        cdc.Controls.Add(dayContent);

                        day.IsSelectable = daysSelectable;

                        OnDayRender(cdc, day);

                        // refresh the day content
                        dayContent.Text = GetCalendarButtonText(absoluteDay.ToString(CultureInfo.InvariantCulture),
                                                                dayNumberText,
                                                                dayTitle,
                                                                buttonsActive && day.IsSelectable,
                                                                cdc.ForeColor);
                        cdc.RenderControl(writer);

                    }
                    else {
                        // VSWhidbey 480155: In design mode we render days as
                        // texts instead of links so CSS class color setting is
                        // supported.  But this differs in runtime rendering
                        // where CSS class color setting is not supported.  To
                        // correctly mimic the forecolor of runtime rendering in
                        // design time, the default color, which is used in
                        // runtime rendering, is explicitly set in this case.
                        if (inDesignSelectionMode && cellStyle.ForeColor.IsEmpty) {
                            cellStyle.ForeColor = defaultForeColor;
                        }

                        RenderCalendarCell(writer, cellStyle, dayNumberText, dayTitle, daysSelectable, absoluteDay.ToString(CultureInfo.InvariantCulture));
                    }

                    Debug.Assert(!passedLastSupportedDate);
                    if (lastOrSecondLastMonth && d.Month == maxSupportedDate.Month && d.Day == maxSupportedDate.Day) {
                        passedLastSupportedDate = true;
                    }
                    else {
                        d = threadCalendar.AddDays(d, 1);
                        absoluteDay++;
                    }
                }
                writer.Write(ROWENDTAG);
            }
        }
Exemplo n.º 14
0
 public SelectionModeItem(string text, CalendarSelectionMode calendarMode)
 {
     this.Text = text;
     this.CalendarSelectionMode = calendarMode;
 }
Exemplo n.º 15
0
		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>");
		}
Exemplo n.º 16
0
		protected bool HasWeekSelectors (CalendarSelectionMode selectionMode)
		{
			if (selectionMode == CalendarSelectionMode.DayWeek || selectionMode == CalendarSelectionMode.DayWeekMonth)
				return true;

			return false;
		}
Exemplo n.º 17
0
		protected bool HasWeekSelectors (CalendarSelectionMode selectionMode)
		{
			return selectionMode == CalendarSelectionMode.DayWeek ||
				selectionMode == CalendarSelectionMode.DayWeekMonth;
		}
Exemplo n.º 18
0
        protected override void Render(HtmlTextWriter writer)
        {
            //Do not call te base render functionality
            //which has wrong rendering for Persian Calendar
            //base.Render(writer);


            bool isEnabled;

            this.threadCalendar   = GetDefaultCalendar();
            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 || DesignMode)
            {
                isEnabled = false;
            }
            else
            {
                isEnabled = IsEnabled;
            }

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

            Table table = CreateTable();

            if (ControlStyleCreated)
            {
                table.ApplyStyle(ControlStyle);
            }

            table.Width       = Width;
            table.Height      = Height;
            table.CellPadding = CellPadding;
            table.CellSpacing = CellSpacing;

            if (!ControlStyleCreated || this.BorderWidth.Equals(Unit.Empty))
            {
                table.BorderWidth = Unit.Pixel(1);
            }

            table.GridLines = this.ShowGridLines ? GridLines.Both : GridLines.None;
            string caption = this.Caption;

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

            table.RenderBeginTag(writer);
            if (this.ShowTitle)
            {
                OnRenderTitle(writer, visibleDate, selectionMode, isEnabled);
            }

            if (this.ShowDayHeader)
            {
                OnRenderDayHeader(writer, visibleDate, selectionMode, isEnabled);
            }

            this.OnRenderDays(writer, firstDay, visibleDate, selectionMode, isEnabled);
            table.RenderEndTag(writer);
        }
Exemplo n.º 19
0
		private void RenderAllDays (HtmlTextWriter writer,
					    DateTime firstDay,
					    DateTime activeDate,
					    CalendarSelectionMode mode,
					    bool isActive,
					    bool isDownLevel)
		{
			TableItemStyle weeksStyle = null;
			TableCell weeksCell = new TableCell ();
			TableItemStyle weekendStyle = WeekendDayStyle;
			TableItemStyle otherMonthStyle = OtherMonthDayStyle;
			Unit size;
			bool isWeekMode = (mode == CalendarSelectionMode.DayWeek ||
					   mode == CalendarSelectionMode.DayWeekMonth);

			if (isWeekMode) {
				weeksStyle = new TableItemStyle ();
				weeksStyle.Width = Unit.Percentage (12);
				weeksStyle.HorizontalAlign = HorizontalAlign.Center;
				weeksStyle.CopyFrom (SelectorStyle);
				size = Unit.Percentage (12);
			} else {
				size = Unit.Percentage (14);
			}

			TableItemStyle [] styles = new TableItemStyle [32];
			int definedStyles = MASK_SELECTED;
			if (weekendStyle != null && !weekendStyle.IsEmpty)
				definedStyles |= MASK_WEEKEND;
			if (otherMonthStyle != null && !otherMonthStyle.IsEmpty)
				definedStyles |= MASK_OMONTH;
			if (todayDayStyle != null && !todayDayStyle.IsEmpty)
				definedStyles |= MASK_TODAY;
			if (dayStyle != null && !dayStyle.IsEmpty)
				definedStyles |= MASK_DAY;

			int month = globCal.GetMonth (activeDate);
			DateTime currentDay = firstDay;
			int begin = (int) (firstDay - begin_date).TotalDays;
			for (int crr = 0; crr < 6; crr++) {
				writer.Write ("<tr>");
				if (isWeekMode) {
					int week_offset = begin + crr * 7;
					string cellText = GetCalendarLinkText (
								"R" + week_offset + "07",
								SelectWeekText, 
								"Select week " + (crr + 1),
								weeksCell.ForeColor,
								isActive);

					weeksCell.Text = cellText;
					weeksCell.ApplyStyle (weeksStyle);
					RenderCalendarCell (writer, weeksCell, cellText);
				}

				for (int weekDay = 0; weekDay < 7; weekDay++) {
					string dayString = currentDay.Day.ToString ();
					DayOfWeek dow = currentDay.DayOfWeek;
					CalendarDay calDay =
						new CalendarDay (
								currentDay,
								dow == DayOfWeek.Sunday ||
								dow == DayOfWeek.Saturday,
								currentDay == TodaysDate, 
								SelectedDates.Contains (currentDay),
								globCal.GetMonth (currentDay) != month,
								dayString
								);


					int dayStyles = GetMask (calDay) & definedStyles;
					TableItemStyle currentDayStyle = styles [dayStyles];
					if (currentDayStyle == null) {
						currentDayStyle = new TableItemStyle ();
						if ((dayStyles & MASK_DAY) != 0)
							currentDayStyle.CopyFrom (DayStyle);

						if ((dayStyles & MASK_WEEKEND) != 0)
							currentDayStyle.CopyFrom (WeekendDayStyle);

						if ((dayStyles & MASK_TODAY) != 0)
							currentDayStyle.CopyFrom (TodayDayStyle);

						if ((dayStyles & MASK_OMONTH) != 0)
							currentDayStyle.CopyFrom (OtherMonthDayStyle);

						if ((dayStyles & MASK_SELECTED) != 0) {
							currentDayStyle.ForeColor = Color.White;
							currentDayStyle.BackColor = Color.Silver;
							currentDayStyle.CopyFrom (SelectedDayStyle);
						}

						currentDayStyle.Width = size;
						currentDayStyle.HorizontalAlign = HorizontalAlign.Center;
					}

					TableCell dayCell = new TableCell ();
					dayCell.ApplyStyle (currentDayStyle);
					LiteralControl number = new LiteralControl (dayString);
					dayCell.Controls.Add (number);
					calDay.IsSelectable = isActive;
					OnDayRender (dayCell, calDay);
					if (calDay.IsSelectable)
						number.Text = GetCalendarLinkText ((begin + (crr * 7 + weekDay)).ToString (),
									dayString,
									currentDay.ToShortDateString (),
									dayCell.ForeColor,
									isActive);

					dayCell.RenderControl (writer);
					currentDay = globCal.AddDays (currentDay, 1);
				}
				writer.Write("</tr>");
			}
		}
Exemplo n.º 20
0
        protected virtual void OnRenderDayHeader(HtmlTextWriter writer, DateTime visibleDate, CalendarSelectionMode selectionMode, bool buttonsActive)
        {
            writer.Write("<tr>");
            DateTimeFormatInfo currentInfo = GetDateTimeFormatter();

            if (this.HasWeekSelectors(selectionMode))
            {
                TableItemStyle style = new TableItemStyle();
                style.HorizontalAlign = HorizontalAlign.Center;
                if (selectionMode == CalendarSelectionMode.DayWeekMonth)
                {
                    int days       = visibleDate.Subtract(baseDate).Days;
                    int dayOfMonth = this.threadCalendar.GetDaysInMonth(this.threadCalendar.GetYear(visibleDate), this.threadCalendar.GetMonth(visibleDate), this.threadCalendar.GetEra(visibleDate));
                    if (this.IsMinSupportedYearMonth(visibleDate))
                    {
                        dayOfMonth = (dayOfMonth - this.threadCalendar.GetDayOfMonth(visibleDate)) + 1;
                    }
                    else if (this.IsMaxSupportedYearMonth(visibleDate))
                    {
                        dayOfMonth = this.threadCalendar.GetDayOfMonth(this.maxSupportedDate);
                    }
                    string eventArgument = "R" + (((days * 100) + dayOfMonth)).ToString(CultureInfo.InvariantCulture);
                    style.CopyFrom(this.SelectorStyle);
                    string title = null;

                    this.OnRenderCalendarCell(writer, style, this.SelectMonthText, title, buttonsActive, eventArgument);
                }
                else
                {
                    style.CopyFrom(this.DayHeaderStyle);
                    this.OnRenderCalendarCell(writer, style, string.Empty, null, false, null);
                }
            }

            TableItemStyle weekdayStyle = new TableItemStyle();

            weekdayStyle.HorizontalAlign = HorizontalAlign.Center;
            weekdayStyle.CopyFrom(this.DayHeaderStyle);

            DayNameFormat dayNameFormat = this.DayNameFormat;
            int           firstDay      = this.NumericFirstDayOfWeek();

            for (int i = firstDay; i < (firstDay + 7); i++)
            {
                string dayName;
                int    dayOfWeekNumber = i % 7;

                switch (dayNameFormat)
                {
                case DayNameFormat.Full:
                    dayName = currentInfo.GetDayName((DayOfWeek)dayOfWeekNumber);
                    break;

                case DayNameFormat.FirstLetter:
                    dayName = currentInfo.GetDayName((DayOfWeek)dayOfWeekNumber).Substring(0, 1);
                    break;

                case DayNameFormat.FirstTwoLetters:
                    dayName = currentInfo.GetDayName((DayOfWeek)dayOfWeekNumber).Substring(0, 2);
                    break;

                case DayNameFormat.Shortest:
                    dayName = currentInfo.GetShortestDayName((DayOfWeek)dayOfWeekNumber);
                    break;

                default:
                    dayName = currentInfo.GetAbbreviatedDayName((DayOfWeek)dayOfWeekNumber);
                    break;
                }

                this.OnRenderCalendarCell(writer, weekdayStyle, dayName, null, false, null);
            }
            writer.Write("</tr>");
        }
Exemplo n.º 21
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            Area day = PointerOnDay(e.Location);
            if (e.Location.X < 200) // the pointer is on the month calendar area
            {
                for (int i = 0; i < 4; i++)
                {
                    if (PointerOnArea(e.Location, _selectionButtons[i].Bounds))
                    {
                        _selectionMode = (CalendarSelectionMode)i;
                        if (_lastDaySelected != null)
                            ChangeSelection(_lastDaySelected);
                    }
                }
                if (day != null)
                {
                    _lastDaySelected = day;
                    ChangeSelection(day);
                }

                for (int i = 0; i < Months.Length; i++)
                {
                    if (Months[i].NextButton.Bounds.Contains(e.Location))
                    {
                        GoForward();
                    }
                    if (Months[i].PreviousButton.Bounds.Contains(e.Location))
                    {
                        GoBackward();
                    }

                }
                if (_selectionMode == CalendarSelectionMode.Manual || _selectionMode == CalendarSelectionMode.OneDay) _selectedDay = day;
                _mouseDown = true;
            }
            else
            {
                if (day != null)
                {
                    _selectedItem = null;
                    foreach (TrainingItem item in _items)
                    {
                        if (ItemInSelection(item) && PointerOnArea(e.Location, item.Bounds))
                        {
                            _selectedItem = item;
                            if (ItemClick != null)
                                ItemClick(this, new CalendarEventArgs(_selectedItem));
                            if (item.Type != TrainingEvent.TrainingNote)
                            {
                                Invalidate();
                                return;
                            }
                        }
                    }
                    _selectedDay = day;
                    Invalidate();
                }

                if (_trainingButtons != null)
                {
                    for (int i = 0; i < _trainingButtons.Length; i++)
                    {

                        if (PointerOnArea(e.Location, _trainingButtons[i].Bounds))
                        {
                            _selectedButton = i;
                            Invalidate();
                            if (_selectedItem != null)
                            {
                                switch (i)
                                {
                                    case 0: onTrainingItemEdit(_selectedItem); break;
                                    case 1: onTrainingItemDelete(_selectedItem); break;
                                    case 2: if (ReportButtonClick != null) ReportButtonClick(this, new CalendarEventArgs(_selectedItem)); break;
                                    case 3: ChangeColor(); break;
                                }
                                if (i == _trainingButtons.Length - 1) if (ChartsClick != null) ChartsClick(this, new EventArgs());
                                return;
                            }
                            else if (_selectedDay != null)
                            {
                                object[] additionalInfo = (object[])_trainingButtons[i].Tag;
                                if (additionalInfo != null) TrainingItemCreate(additionalInfo);
                            }
                            if (i == _trainingButtons.Length - 1) if (ChartsClick != null) ChartsClick(this, new EventArgs());
                        }

                    }
                }
            }
        }