Ejemplo n.º 1
0
        void WriteDay(DateTime date, HtmlTextWriter writer, bool enabled)
        {
            TableItemStyle style = new TableItemStyle();
            TableCell      cell  = new TableCell();

            CalendarDay day = new CalendarDay(date,
                                              IsWeekEnd(date.DayOfWeek),
                                              date == TodaysDate, SelectedDates.Contains(date),
                                              GetGlobalCalendar().GetMonth(DisplayDate) != GetGlobalCalendar().GetMonth(date),
                                              date.Day.ToString());

            day.IsSelectable     = SelectionMode != CalendarSelectionMode.None;
            cell.HorizontalAlign = HorizontalAlign.Center;
            cell.Width           = Unit.Percentage(GetCellWidth());

            LiteralControl lit = new LiteralControl(day.DayNumberText);

            cell.Controls.Add(lit);

            OnDayRender(cell, day);

            if (dayStyle != null && !dayStyle.IsEmpty)
            {
                style.CopyFrom(dayStyle);
            }

            if (day.IsWeekend && weekendDayStyle != null && !weekendDayStyle.IsEmpty)
            {
                style.CopyFrom(weekendDayStyle);
            }

            if (day.IsToday && todayDayStyle != null && !todayDayStyle.IsEmpty)
            {
                style.CopyFrom(todayDayStyle);
            }

            if (day.IsOtherMonth && otherMonthDayStyle != null && !otherMonthDayStyle.IsEmpty)
            {
                style.CopyFrom(otherMonthDayStyle);
            }

            if (enabled && day.IsSelected)
            {
                style.BackColor = Color.Silver;
                style.ForeColor = Color.White;
                if (selectedDayStyle != null && !selectedDayStyle.IsEmpty)
                {
                    style.CopyFrom(selectedDayStyle);
                }
            }

            cell.ApplyStyle(style);

            lit.Text = BuildLink(GetDaysFromZenith(date).ToString(), day.DayNumberText,
                                 cell.ForeColor, enabled && day.IsSelectable);

            cell.RenderControl(writer);
        }
 protected override void OnDayRender(ASP.TableCell cell, ASP.CalendarDay day)
 {
     base.OnDayRender(cell, day);
     if (this.mouseOverStyle != null && !day.IsSelected)
     {
         cell.Attributes.Add("onmouseover", Utils.GetJavaScriptStyleString(this.mouseOverStyle));
         cell.Attributes.Add("onmouseout", Utils.GetJavaScriptStyleString(cell.ControlStyle));
     }
 }
Ejemplo n.º 3
0
 public RenderCalendarCellArgs(HtmlTextWriter writer, Style cellStyle, CalendarDay dayInfo, string eventArgument, string text, string title)
     : base(false)
 {
     Writer = writer;
     CellStyle = cellStyle;
     Text = text;
     Title = title;
     DayInfo = dayInfo;
     EventArgument = eventArgument;
 }
Ejemplo n.º 4
0
        protected virtual void OnDayRender(TableCell cell, CalendarDay day)
        {
            DayRenderEventHandler eh = (DayRenderEventHandler)(Events [DayRenderEvent]);

            if (eh != null)
#if NET_2_0
            { if (Page != null)
              {
                  eh(this, new DayRenderEventArgs(cell, day, Page.ClientScript.GetPostBackClientHyperlink(this, GetDaysFromZenith(day.Date).ToString(), true)));
              }
              else
#endif
            { eh(this, new DayRenderEventArgs(cell, day)); }
        }
Ejemplo n.º 5
0
		protected override void OnDayRender(TableCell cell,
			CalendarDay day)
		{
			if (day.IsWeekend && !AllowWeekendSelection)
			{
				day.IsSelectable = false;
			}
			else if (NonSelectableDates.Contains(day.Date))
			{
				day.IsSelectable = false;
			}

			// Let the base class raise this event.
			base.OnDayRender(cell, day);
		}
Ejemplo n.º 6
0
 protected override void OnDayRender(TableCell cell, CalendarDay day)
 {
     cell.Attributes["onmouseover"] = "javasript:this.className='cellDayHightLight';";
     cell.Attributes["onmouseout"] = "javasript:this.className='cellDay';";
     cell.Attributes["RelatedDate"] = day.Date.ToString("yyyy-M-d");
     if (HighLightDayList == null)
         throw new Exception("HighLightDayList can't be null.");
     if (HighLightDayList.Contains(day.Date.ToString(HighLightDayListType)))
     {
         cell.ForeColor = Color.Black;
         cell.Font.Bold = true;
     }
     else
         cell.ForeColor = Color.FromArgb(102,102,102);
     base.OnDayRender(cell, day);
 }
Ejemplo n.º 7
0
        protected override void OnDayRender(TableCell cell, CalendarDay day)
        {
            if (day.IsToday)
            {
                cell.Attributes["id"] += "today";
            }

            List<Post> list = Post.GetPostsByDate(day.Date, day.Date);
            if (list.Count > 0)
            {
                cell.Controls.Clear();
                if (ShowPostTitles)
                {
                    cell.Controls.Add(new LiteralControl(day.DayNumberText));
                    foreach (Post post in list)
                    {
                        if (post.IsVisible)
                        {
                            HtmlAnchor a = new HtmlAnchor();
                            a.InnerHtml = "<br /><br />" + post.Title;
                            a.HRef = post.RelativeLink.ToString();
                            cell.Controls.Add(a);
                        }
                    }
                }
                else
                {
                    if (list[0].IsVisible)
                    {
                        HtmlAnchor a = new HtmlAnchor();
                        a.InnerHtml = day.DayNumberText;
                        a.HRef = Utils.RelativeWebRoot + day.Date.Year + "/" + day.Date.ToString("MM") + "/" + day.Date.ToString("dd") + "/default" + BlogSettings.Instance.FileExtension;
                        a.Attributes["class"] = "exist";
                        cell.Controls.Add(a);
                    }
                    else
                    {
                        cell.Text = day.DayNumberText;
                    }
                }
            }
            else
            {
                cell.Controls.Clear();
                cell.Text = day.DayNumberText;
            }
        }
Ejemplo n.º 8
0
        private static string GetDayFilter(System.Web.UI.WebControls.CalendarDay day, string dayField)
        {
            //0.0041
            //return dayField
            //    + " >= #" + day.Date.ToString("MM/dd/yyyy") + "# and "
            //    + dayField + " < #" + day.Date.AddDays(1).ToString("MM/dd/yyyy") + "#";

            // changed to use invariant culture 2008-09-02 to fix error that would happen if
            // browser language is Persian
            return(dayField
                   + " >= #" + day.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture) + "# and "
                   + dayField + " < #" + day.Date.AddDays(1).ToString("MM/dd/yyyy", CultureInfo.InvariantCulture) + "#");


            //0.0057
            //return string.Format(
            //        "{0} >= #{1}# and {0} < #{2}#",
            //        dayField,
            //        day.Date.ToString("MM/dd/yyyy"),
            //        day.Date.AddDays(1).ToString("MM/dd/yyyy")
            //        );
        }
 public DayRenderEventArgs(TableCell cell, CalendarDay day)
 {
     this.day  = day;
     this.cell = cell;
 }
 public DayRenderEventArgs(TableCell cell, CalendarDay day, string selectUrl)
 {
     this.day       = day;
     this.cell      = cell;
     this.selectUrl = selectUrl;
 }
 public DayRenderEventArgs(TableCell cell, CalendarDay day)
 {
 }
 public DayRenderEventArgs(TableCell cell, CalendarDay day, string selectUrl)
 {
 }
 protected virtual new void OnDayRender(TableCell cell, CalendarDay day)
 {
 }
Ejemplo n.º 14
0
        protected override void OnDayRender(TableCell cell, CalendarDay day)
        {
            cell.Controls.Clear();
            string strDateText;

            if (this.ListView == "ListView")
            {
                TableCell cellListView = new TableCell();
                cell.Controls.Add(cellListView);
                strDateText = GetDayNameAbbrev(day.Date.DayOfWeek.ToString()) + " " + GetMonthNameOrAbbrev(day.Date.Month, true) + ", " + day.DayNumberText + " " + day.Date.Year;
            }
            else
            {
                strDateText = day.DayNumberText;
            }

            DivCtrl div = new DivCtrl(strDateText);
            div.ApplyStyle(DayNumberStyle);
            div.Attributes.Add("onmouseover", "Tip('Click to add event<br>appointment or meeting<br>on - <b>" + GetMonthNameOrAbbrev(day.Date.Month, true) + ", " + day.DayNumberText + " " + day.Date.Year + "</b>', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
            div.Attributes.Add("onmouseout", "UnTip()");
            div.Attributes.Add("onclick", "AddEventCalendar('" + day.Date.ToShortDateString() + "')");
            cell.Controls.Add(div);

            // _dtSource was already set by the Render method
            if (_dtSource != null)
            {
                // We have the data source as a DataTable now;
                // filter the records in the DataTable for the given day;
                // force the date format to be MM/dd/yyyy
                // to ensure compatibility with RowFilter
                // date expression syntax (#date#).
                // Also, take the possibility of time
                // values into account by specifying
                // a date range, to include the full day
                DataView dv = new DataView(_dtSource);
                dv.RowFilter = string.Format(
                   "{0} >= #{1}# and {0} < #{2}#",
                   this.DayField,
                   day.Date.ToString("MM/dd/yyyy"),
                   day.Date.AddDays(1).ToString("MM/dd/yyyy")
                );

                string eventType = string.Empty;
                DateTime eDate;

                // are there events on this day?
                if (dv.Count > 0)
                {
                    // there are events on this day; if indicated,
                    // apply the DayWithEventsStyle to the table cell
                    if (this.DayWithEventsStyle != null)
                        cell.ApplyStyle(this.DayWithEventsStyle);

                    // for each event on this day apply the
                    // ItemTemplate, with data bound to the item's row
                    // from the data source
                    if (this.ItemTemplate != null)
                        foreach (DataRowView drv in dv)
                        {
                            USHolidayCellStyle(cell, drv);
                            SetupCalendarItem(cell, drv.Row, this.ItemTemplate);
                        }
                }
                else
                {
                    // no events this day;
                    if (this.NoEventsTemplate != null)
                    {
                        SetupCalendarItem(cell, null, this.NoEventsTemplate);
                    }
                }
            }

            // call the base render method too
            base.OnDayRender(cell, day);
        }
Ejemplo n.º 15
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);
            }
        }
Ejemplo n.º 16
0
		protected virtual void OnDayRender(TableCell cell, CalendarDay day)
		{
			if(Events!=null)
			{
				DayRenderEventHandler dreh = (DayRenderEventHandler)(Events[DayRenderEvent]);
				if(dreh!=null)
					dreh(this, new DayRenderEventArgs(cell, day));
			}
		}
Ejemplo n.º 17
0
        protected override void OnDayRender(TableCell cell, CalendarDay day)
        {
            // _dtSource was already set by the Render method            
            if (_dtSource != null)
            {

                // We have the data source as a DataTable now;                
                // filter the records in the DataTable for the given day;
                // force the date format to be MM/dd/yyyy
                // to ensure compatibility with RowFilter
                // date expression syntax (#date#).
                // Also, take the possibility of time
                // values into account by specifying
                // a date range, to include the full day
                DataView dv = new DataView(_dtSource);
                dv.RowFilter = string.Format(
                   "{0} >= #{1}# and {0} < #{2}#",
                   this.DayField,
                   day.Date.ToString("MM/dd/yyyy"),
                   day.Date.AddDays(1).ToString("MM/dd/yyyy")
                );

                // are there events on this day?
                if (dv.Count > 0)
                {
                    // there are events on this day; if indicated, 
                    // apply the DayWithEventsStyle to the table cell
                    if (this.DayWithEventsStyle != null)
                        cell.ApplyStyle(this.DayWithEventsStyle);

                    // for each event on this day apply the
                    // ItemTemplate, with data bound to the item's row
                    // from the data source
                    if (this.ItemTemplate != null)
                        for (int i = 0; i < dv.Count; i++)
                        {
                            SetupCalendarItem(cell, dv[i].Row, this.ItemTemplate);
                        }

                }
                else
                {
                    // no events this day;
                    if (this.NoEventsTemplate != null)
                        SetupCalendarItem(cell, null, this.NoEventsTemplate);

                }

            }

            // call the base render method too
            base.OnDayRender(cell, day);

        }
Ejemplo n.º 18
0
        protected override void OnDayRender(TableCell cell, System.Web.UI.WebControls.CalendarDay day)
        {
            // _dtSource was already set by the Render method
            //if (_dtSource != null)
            if (dv != null)
            {
                // We have the data source as a DataTable now;
                // filter the records in the DataTable for the given day;
                // force the date format to be MM/dd/yyyy
                // to ensure compatibility with RowFilter
                // date expression syntax (#date#).
                // Also, take the possibility of time
                // values into account by specifying
                // a date range, to include the full day
                //DataView dv = new DataView(_dtSource);

                // ANTS profiler says this takes a long time and is called 42 times in rendering
                // 0.148
                //dv.RowFilter = string.Format(
                //    "{0} >= #{1}# and {0} < #{2}#",
                //    this.DayField,
                //    day.Date.ToString("MM/dd/yyyy"),
                //    day.Date.AddDays(1).ToString("MM/dd/yyyy")
                //    );


                if (_dtSource.Rows.Count > 0)
                {
                    // 0.0343
                    dv.RowFilter = GetDayFilter(day, DayField);

                    // are there events on this day?
                    if (dv.Count > 0)
                    {
                        // there are events on this day; if indicated,
                        // apply the DayWithEventsStyle to the table cell
                        if (day.Date == this.SelectedDate)
                        {
                            if (this._currentDayStyle != null)
                            {
                                cell.ApplyStyle(this._currentDayStyle);
                            }
                        }
                        else
                        {
                            if (this.DayWithEventsStyle != null)
                            {
                                cell.ApplyStyle(this.DayWithEventsStyle);
                            }
                        }

                        // for each event on this day apply the
                        // ItemTemplate, with data bound to the item's row
                        // from the data source
                        if (this.ItemTemplate != null)
                        {
                            for (int i = 0; i < dv.Count; i++)
                            {
                                SetupCalendarItem(cell, dv[i].Row, this.ItemTemplate);
                            }
                        }
                    }
                    else
                    {
                        // no events this day;
                        if (day.Date == this.SelectedDate)
                        {
                            if (this._currentDayStyle != null)
                            {
                                cell.ApplyStyle(this._currentDayStyle);
                            }
                        }
                        else
                        {
                            if (this.NoEventsTemplate != null)
                            {
                                SetupCalendarItem(cell, null, this.NoEventsTemplate);
                            }
                        }
                    }
                }
                else
                {
                    // no events
                    if (day.Date == this.SelectedDate)
                    {
                        if (this._currentDayStyle != null)
                        {
                            cell.ApplyStyle(this._currentDayStyle);
                        }
                    }
                    else
                    {
                        if (this.NoEventsTemplate != null)
                        {
                            SetupCalendarItem(cell, null, this.NoEventsTemplate);
                        }
                    }
                }
            }

            // call the base render method too
            // under windows commenting this has no effect on result
            base.OnDayRender(cell, day);
        }
 public DayRenderEventArgs(TableCell cell, CalendarDay day)
 {
     this.day = day;
     this.cell = cell;
 }
 protected virtual new void OnDayRender(TableCell cell, CalendarDay day)
 {
 }
Ejemplo n.º 21
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>");
			}
		}
Ejemplo n.º 22
0
		void WriteDay (DateTime date, HtmlTextWriter writer)
		{			
			TableItemStyle style = new TableItemStyle ();
			TableCell cell = new TableCell ();

			CalendarDay day = new CalendarDay (date,
				IsWeekEnd (date.DayOfWeek),
				date == TodaysDate, SelectedDates.Contains (date),
				GetGlobalCalendar ().GetMonth (DisplayDate) != GetGlobalCalendar ().GetMonth (date),
				date.Day.ToString ());

			day.IsSelectable = SelectionMode != CalendarSelectionMode.None;
			cell.HorizontalAlign = HorizontalAlign.Center;
			cell.Width = Unit.Percentage (GetCellWidth ());

			LiteralControl lit = new LiteralControl (day.DayNumberText);
			cell.Controls.Add (lit);

			OnDayRender (cell, day);
					
			if (dayStyle != null && !dayStyle.IsEmpty) {
				style.CopyFrom (dayStyle);
			}

			if (day.IsWeekend && weekendDayStyle != null && !weekendDayStyle.IsEmpty) {
				style.CopyFrom (weekendDayStyle);
			}

			if (day.IsToday && todayDayStyle != null && !todayDayStyle.IsEmpty) {
				style.CopyFrom (todayDayStyle);
			}

			if (day.IsOtherMonth && otherMonthDayStyle != null && !otherMonthDayStyle.IsEmpty) {
				style.CopyFrom (otherMonthDayStyle);
			}

			if (day.IsSelected && Enabled) {
				style.BackColor = Color.Silver;
				style.ForeColor = Color.White;
				if (selectedDayStyle != null && !selectedDayStyle.IsEmpty) {
					style.CopyFrom (selectedDayStyle);
				}
			}

			cell.ApplyStyle (style);

			lit.Text = BuildLink (GetDaysFromZenith (date).ToString (), day.DayNumberText,
					      cell.ForeColor, day.IsSelectable && Enabled);

			cell.RenderControl (writer);
		}
 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>");
     }
 }
Ejemplo n.º 24
0
		protected virtual void OnDayRender (TableCell cell, CalendarDay day)
		{
			DayRenderEventHandler eh = (DayRenderEventHandler) (Events [DayRenderEvent]);
			if (eh != null)
#if NET_2_0
				if (Page != null)
					eh (this, new DayRenderEventArgs (cell, day, Page.ClientScript.GetPostBackClientHyperlink (this, GetDaysFromZenith (day.Date).ToString (), true)));
				else
#endif
				eh (this, new DayRenderEventArgs (cell, day));
		}
Ejemplo n.º 25
0
		private int GetMask (CalendarDay day)
		{
			int retVal = MASK_DAY;
			if(day.IsSelected)
				retVal |= MASK_SELECTED;
			if(day.IsToday)
				retVal |= MASK_TODAY;
			if(day.IsOtherMonth)
				retVal |= MASK_OMONTH;
			if(day.IsWeekend)
				retVal |= MASK_WEEKEND;
			return retVal;
		}
 public DayRenderEventArgs(TableCell cell, CalendarDay day, string selectUrl)
 {
     this.day = day;
     this.cell = cell;
     this.selectUrl = selectUrl;
 }
 public DayRenderEventArgs(TableCell cell, CalendarDay day)
 {
 }
 public DayRenderEventArgs(TableCell cell, CalendarDay day, string selectUrl)
 {
 }
 protected virtual void OnDayRender(TableCell cell, CalendarDay day)
 {
     DayRenderEventHandler handler = (DayRenderEventHandler) base.Events[EventDayRender];
     if (handler != null)
     {
         int days = day.Date.Subtract(baseDate).Days;
         string selectUrl = null;
         if (this.Page != null)
         {
             string argument = days.ToString(CultureInfo.InvariantCulture);
             selectUrl = this.Page.ClientScript.GetPostBackClientHyperlink(this, argument, true);
         }
         handler(this, new DayRenderEventArgs(cell, day, selectUrl));
     }
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.WebControls.Calendar.DayRender"/> event of the <see cref="T:System.Web.UI.WebControls.Calendar"/> control and allows you to provide a custom handler for the <see cref="E:System.Web.UI.WebControls.Calendar.DayRender"/> event.
        /// </summary>
        /// <param name="cell">A <see cref="T:System.Web.UI.WebControls.TableCell"/> that contains information about the cell to render.</param>
        /// <param name="day">A <see cref="T:System.Web.UI.WebControls.CalendarDay"/> that contains information about the day to render.</param>
        protected override void OnDayRender(TableCell cell, CalendarDay day)
        {
            if (day.IsToday)
            {
                cell.Attributes["id"] += "today";
            }

            var list = Post.GetPostsByDate(day.Date, day.Date);
            if (list.Count > 0)
            {
                cell.Controls.Clear();
                if (this.ShowPostTitles)
                {
                    cell.Controls.Add(new LiteralControl(day.DayNumberText));
                    foreach (var a in
                        list.Where(post => post.IsVisible).Select(post => new HtmlAnchor { InnerHtml = string.Format("<br /><br />{0}", post.Title), HRef = post.RelativeLink }))
                    {
                        cell.Controls.Add(a);
                    }
                }
                else
                {
                    if (list[0].IsVisible)
                    {
                        var a = new HtmlAnchor
                            {
                                InnerHtml = day.DayNumberText,
                                HRef =
                                    string.Format("{0}{1}/{2}/{3}/default{4}", Utils.RelativeWebRoot, day.Date.Year, day.Date.ToString("MM"), day.Date.ToString("dd"), BlogConfig.FileExtension)
                            };
                        a.Attributes["class"] = "exist";
                        cell.Controls.Add(a);
                    }
                    else
                    {
                        cell.Text = day.DayNumberText;
                    }
                }
            }
            else
            {
                cell.Controls.Clear();
                cell.Text = day.DayNumberText;
            }
        }
Ejemplo n.º 31
0
        /// <devdoc>
        /// <para>Raises the <see langword='DayRender '/>event for a <see cref='System.Web.UI.WebControls.Calendar'/>.</para>
        /// </devdoc>
        protected virtual void OnDayRender(TableCell cell, CalendarDay day) {
            DayRenderEventHandler handler = (DayRenderEventHandler)Events[EventDayRender];
            if (handler != null) {
                int absoluteDay = day.Date.Subtract(baseDate).Days;

                // VSWhidbey 215383: We return null for selectUrl if a control is not in
                // the page control tree.
                string selectUrl = null;
                Page page = Page;
                if (page != null) {
                    string eventArgument = absoluteDay.ToString(CultureInfo.InvariantCulture);
                    selectUrl = Page.ClientScript.GetPostBackClientHyperlink(this, eventArgument, true);
                }
                handler(this, new DayRenderEventArgs(cell, day, selectUrl));
            }
        }