예제 #1
0
        // Creates the children based on the data
        //private int CreateDataBoundChildren(System.Data.DataView dv, Table table, DateTime todaysDate, DateTime visibleDate, System.Globalization.Calendar topicCalendar)
        //{
        //    DateTime firstDay = FirstCalendarDay(this.VisibleDate);

        //    int dayoffset = 0;

        //    for (int iRow = 0; iRow < 6; iRow++)
        //    {
        //        TableRow row = new TableRow();
        //        table.Rows.Add(row);

        //        for (int iDay = 0; iDay < 7; iDay++)
        //        {
        //            DateTime d = firstDay.AddDays(dayoffset);

        //            //Initialize the cell
        //            CalendarDay day = getDay(d, TodaysDate, visibleDate, topicCalendar);
        //            TableCell cell = CreateDayCell(day);
        //            row.Cells.Add(cell);

        //            //Process real data for this day
        //            dv.RowFilter = string.Format("{0}>= #{1}# AND {0} < #{2}#", this.DayField, d.ToString("MM/dd/yyyy"), d.AddDays(1).ToString("MM/dd/yyyy"));
        //            if (dv.Count > 0 && this.DayEventTemplate != null)
        //            {
        //                foreach (System.Data.DataRowView drv in dv)
        //                {
        //                    DataBoundCalendarItem dataitem = new DataBoundCalendarItem(drv, day);
        //                    DayEventTemplate.InstantiateIn(dataitem);
        //                    //add the controls to both collections
        //                    cell.Controls.Add(dataitem);
        //                    //databind the data item
        //                    dataitem.DataBind();
        //                }
        //            }
        //            else if (this.DayEmptyTemplate != null)
        //            {
        //                DataBoundCalendarItem dataitem = new DataBoundCalendarItem(null, day);
        //               DayEmptyTemplate.InstantiateIn(dataitem);
        //                //add the controls to both collections
        //                cell.Controls.Add(dataitem);

        //            }
        //            dayoffset++;

        //        }

        //    }
        //    return 1;
        //}

        private int CreateDataBoundChildren(System.Data.DataView dv, Table table, DateTime todaysDate, DateTime visibleDate, System.Globalization.Calendar topicCalendar)
        {
            DateTime firstDay = FirstCalendarDay(this.VisibleDate);

            dv.Table.Locale = new CultureInfo("en-US");

            int    dayoffset   = 0;
            string dayField    = this.DayField;
            string endDayField = this.EndDayField;

            for (int iRow = 0; iRow < 6; iRow++)
            {
                TableRow row = new TableRow();
                table.Rows.Add(row);

                for (int iDay = 0; iDay < 7; iDay++)
                {
                    DateTime d = firstDay.AddDays(dayoffset);

                    //Initialize the cell
                    CalendarDay day  = getDay(d, TodaysDate, visibleDate, topicCalendar);
                    TableCell   cell = CreateDayCell(day);
                    row.Cells.Add(cell);

                    //Process real data for this day
                    dv.RowFilter = string.Format("IsNull({1},{0}) >= #{2}# AND {0}<#{3}#", dayField, endDayField, d.ToString("MM/dd/yyyy"), d.AddDays(1).ToString("MM/dd/yyyy"));

                    if (dv.Count > 0 && this.DayEventTemplate != null)
                    {
                        foreach (System.Data.DataRowView drv in dv)
                        {
                            DataBoundCalendarItem dataitem = new DataBoundCalendarItem(drv, day);
                            DayEventTemplate.InstantiateIn(dataitem);
                            //add the controls to both collections
                            cell.Controls.Add(dataitem);
                            //databind the data item
                            dataitem.DataBind();
                        }
                    }
                    else if (this.DayEmptyTemplate != null)
                    {
                        DataBoundCalendarItem dataitem = new DataBoundCalendarItem(null, day);
                        DayEmptyTemplate.InstantiateIn(dataitem);
                        //add the controls to both collections
                        cell.Controls.Add(dataitem);
                    }
                    dayoffset++;
                }
            }
            return(1);
        }
예제 #2
0
        //Creates the control hierarchy based on the counts of data in viewstate
        //To be smart, we don't databind on postback. We rely on creating the same number of controls as the
        //initial population, the values for the controls then come from viewstate.
        private int createChildrenFromViewstate(Table table, DateTime todaysDate, DateTime visibleDate, System.Globalization.Calendar topicCalendar)
        {
            System.Collections.Generic.Dictionary <DateTime, int> ctrlcount;
            ctrlcount = (System.Collections.Generic.Dictionary <DateTime, int>)ViewState[ViewStateDataKey];

            DateTime firstDay  = FirstCalendarDay(this.VisibleDate);
            int      dayoffset = 0;

            for (int iRow = 0; iRow < 6; iRow++)
            {
                TableRow row = new TableRow();
                table.Rows.Add(row);

                for (int iDay = 0; iDay < 7; iDay++)
                {
                    DateTime d = firstDay.AddDays(dayoffset);

                    //Initialize the cell
                    CalendarDay day  = getDay(d, TodaysDate, visibleDate, topicCalendar);
                    TableCell   cell = CreateDayCell(day);
                    row.Cells.Add(cell);

                    if (ctrlcount != null)
                    {
                        if (this.DayEventTemplate != null && ctrlcount.ContainsKey(d))
                        {
                            int nControlsForDay = ctrlcount[d];

                            for (int count = 0; count < nControlsForDay; count++)
                            {
                                DataBoundCalendarItem dataitem = new DataBoundCalendarItem(null, day);
                                DayEventTemplate.InstantiateIn(dataitem);
                                cell.Controls.Add(dataitem);
                                //Note we don't databind these new controls.
                            }
                        }
                        else if (this.DayEmptyTemplate != null)
                        {
                            DataBoundCalendarItem dataitem = new DataBoundCalendarItem(null, day);
                            DayEmptyTemplate.InstantiateIn(dataitem);
                            cell.Controls.Add(dataitem);
                        }
                    }
                    dayoffset++;
                }
            }
            return(1);
        }
예제 #3
0
 public DayNumberDiv(CalendarDay d, string linkFormat)
     : base(HtmlTextWriterTag.Div)
 {
     if ((linkFormat != null) && (linkFormat.Length > 0))
     {
         link             = new HyperLink();
         link.Text        = d.DayNumberText;
         link.NavigateUrl = string.Format(CultureInfo.InvariantCulture,
                                          linkFormat, d.Date.ToString("s"));
         link.ToolTip = string.Empty;
     }
     else
     {
         m_innerText = d.DayNumberText;
     }
 }
예제 #4
0
 public DataBoundCalendarItem(object di, CalendarDay day)
 {
     _dataItem = di;
     _day      = day;
 }
예제 #5
0
        private TableCell CreateDayCell(CalendarDay day)
        {
            //initialize the cellstyles
            if (_cellStyles == null)
            {
                _cellStyles = new TableItemStyle[16];
            }

            //initialize style mask
            if (_definedStyleMask == 0)
            {
                _definedStyleMask = GetDefinedStyleMask();
            }

            int styleMask = STYLEMASK_DAY;

            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, Unit.Percentage(14));
                _cellStyles[dayStyleID] = cellStyle;
            }

            TableCell cell = new TableCell();

            cell.ApplyStyle(cellStyle);


            DayNumberDiv div;

            if (dayLinkFormat.Length > 0)
            {
                div = new DayNumberDiv(day, dayLinkFormat);
            }
            else
            {
                div = new DayNumberDiv(day.DayNumberText);
            }
            div.ApplyStyle(DayNumberStyle);
            cell.Controls.Add(div);

            return(cell);
        }