本文整理汇总了C#中System.Web.UI.WebControls.TableCell.ApplyStyle方法的典型用法代码示例。如果您正苦于以下问题:C# TableCell.ApplyStyle方法的具体用法?C# TableCell.ApplyStyle怎么用?C# TableCell.ApplyStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.TableCell
的用法示例。
在下文中一共展示了TableCell.ApplyStyle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDayCell
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;
}
示例2: RenderErrorMessage
private void RenderErrorMessage(HtmlTextWriter writer) {
if (_displayErrorMessage) {
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
TableCell td = new TableCell();
td.ApplyStyle(ErrorStyle);
td.Text = NewConnectionErrorMessage;
td.RenderControl(writer);
writer.RenderEndTag();
}
}
示例3: CreateRow
TableRow CreateRow (Control c0, Control c1, Control c2, Style s)
{
TableRow row = new TableRow ();
TableCell cell0 = new TableCell ();
TableCell cell1 = new TableCell ();
if (c0 != null) {
cell0.Controls.Add (c0);
row.Controls.Add (cell0);
}
if (s != null)
cell0.ApplyStyle (s);
if ((c1 != null) && (c2 != null)) {
cell1.Controls.Add (c1);
cell1.Controls.Add (c2);
cell0.HorizontalAlign = HorizontalAlign.Right;
row.Controls.Add (cell1);
}
return row;
}
示例4: WriteDayHeader
//
// Private methods
//
void WriteDayHeader (HtmlTextWriter writer)
{
int i, first;
string dayName;
i = first = (int) (DisplayFirstDayOfWeek);
TableCell cell;
writer.RenderBeginTag (HtmlTextWriterTag.Tr);
if (SelectionMode == CalendarSelectionMode.DayWeek) {
cell = new TableCell();
cell.HorizontalAlign = HorizontalAlign.Center;
cell.ApplyStyle (DayHeaderStyle);
// Empty Cell
cell.RenderBeginTag (writer);
cell.RenderEndTag (writer);
} else {
if (SelectionMode == CalendarSelectionMode.DayWeekMonth) {
TableCell selector = new TableCell ();
selector.ApplyStyle (SelectorStyle);
selector.HorizontalAlign = HorizontalAlign.Center;
DateTime date = new DateTime (DisplayDate.Year, DisplayDate.Month, 1); // first date
int days = DateTime.DaysInMonth (DisplayDate.Year, DisplayDate.Month);
selector.RenderBeginTag (writer);
writer.Write (BuildLink ("R" + GetDaysFromZenith (date) + days, SelectMonthText, DayHeaderStyle.ForeColor, Enabled));
selector.RenderEndTag (writer);
}
}
DateTimeFormatInfo dti = DateInfo;
while (true) {
DayOfWeek dayOfWeek = (DayOfWeek) i;
dayName = dti.GetDayName (dayOfWeek);
#if NET_2_0
if (UseAccessibleHeader) {
writer.AddAttribute (HtmlTextWriterAttribute.Abbr, dayName);
writer.AddAttribute (HtmlTextWriterAttribute.Scope, "col", false);
cell = new TableHeaderCell();
}
else
#endif
cell = new TableCell();
cell.HorizontalAlign = HorizontalAlign.Center;
cell.ApplyStyle (DayHeaderStyle);
cell.RenderBeginTag (writer);
switch (DayNameFormat) {
case DayNameFormat.FirstLetter:
dayName = dayName.Substring (0, 1);
break;
case DayNameFormat.FirstTwoLetters:
dayName = dayName.Substring (0, 2);
break;
#if NET_2_0
case DayNameFormat.Shortest:
dayName = dti.GetShortestDayName (dayOfWeek);
break;
#endif
case DayNameFormat.Full:
break;
case DayNameFormat.Short:
default:
dayName = dti.GetAbbreviatedDayName (dayOfWeek);
break;
}
writer.Write (dayName);
cell.RenderEndTag (writer);
if (i >= daysInAWeek - 1) {
i = 0;
}
else {
i++;
}
if (i == first)
break;
}
writer.RenderEndTag ();
}
示例5: OnDayRender
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);
}
示例6: InitializeCellFooter
private void InitializeCellFooter(TableCell cell, int columnIndex)
{
cell.Text = (FooterText.Length > 0 ? FooterText : " ");
if (FooterStyleInternal != null)
cell.ApplyStyle (FooterStyleInternal);
}
示例7: WriteDays
void WriteDays (HtmlTextWriter writer)
{
DateTime date = new DateTime (DisplayDate.Year, DisplayDate.Month, 1); // first date
DateTime lastDate;
TableCell selectorCell = null;
int n;
// Goes backwards until we find the date of that is begining of the week
for (n = 0; n < daysInAWeek; n++) {
if (date.DayOfWeek == DisplayFirstDayOfWeek)
break;
date = GetGlobalCalendar().AddDays (date, -1);
}
/* if the start date is the first day of the week, we need to shift backward one more week */
if (n == 0)
date = GetGlobalCalendar().AddDays (date, -1 * daysInAWeek);
lastDate = GetGlobalCalendar().AddDays (date, 6 * daysInAWeek); // Always six weeks per months
while (true) {
writer.RenderBeginTag (HtmlTextWriterTag.Tr);
if (HasWeekSelectors (SelectionMode)) { // Week selector
if (selectorCell == null) {
selectorCell = new TableCell ();
selectorCell.ApplyStyle (SelectorStyle);
selectorCell.HorizontalAlign = HorizontalAlign.Center;
selectorCell.Width = Unit.Percentage (GetCellWidth ());
}
selectorCell.RenderBeginTag (writer);
writer.Write (BuildLink ("R" + GetDaysFromZenith (date) + "07", SelectWeekText, selectorCell.ForeColor, Enabled));
selectorCell.RenderEndTag (writer);
}
for (int i = 0; i < daysInAWeek; i++) {
WriteDay (date, writer);
date = GetGlobalCalendar().AddDays (date, 1);
}
writer.RenderEndTag ();
if (date >= lastDate)
break;
}
}
示例8: BuildMenu
/// <summary>
/// BuildMenu builds the top-level menu. It is called from the OnDataBinding method as well
/// as from <see cref="CreateChildControls"/>. It has code to check if the top-level menu should be
/// laid out horizontally or vertically.
/// </summary>
protected virtual void BuildMenu()
{
string image = string.Empty;
string mouseoverimage = string.Empty;
string mousedownimage = string.Empty;
string mouseupimage = string.Empty;
// iterate through the Items
Table menu = new Table();
menu.Attributes.Add("id", this.ClientID);
menu.MergeStyle(this.ControlStyle);
menu.CellPadding = ItemPadding;
menu.CellSpacing = ItemSpacing;
menu.GridLines = GridLines;
// Add the Menu control's STYLE properties to the TABLE
IEnumerator key = this.Style.Keys.GetEnumerator();
while(key.MoveNext())
{
string k = key.Current.ToString();
menu.Style.Add(k, this.Style[k]);
}
menu.Style.Remove("Z-INDEX"); // remove z-index added automatically by grid positioning
// set the Z-INDEX
menu.Style.Add("z-index", this.zIndex.ToString());
curzindex = this.zIndex + 2;
BuildOpacity(menu);
TableRow tr = null;
if (Layout == MenuLayout.Horizontal)
tr = new TableRow();
// Iterate through the top-level menu's menuitems, and add a <td> tag for each menuItem
for (int i = 0; i < this.items.Count; i++)
{
MenuItem mi = this.items[i];
//add by johnny start
if (this.MainSpacingWidth != 0)
{
if (i % 2 == 1)
{
TableCell tdblank = new TableCell();
tdblank.Width=this.MainSpacingWidth;
tdblank.BackColor = Color.Empty;
tr.Cells.Add(tdblank);
}
}
//end
// only render this MenuItem if it is visible and the user has permissions
if (mi.Visible && UserHasPermission(mi))
{
if (Layout == MenuLayout.Vertical)
tr = new TableRow();
TableCell td = new TableCell();
td.ApplyStyle(this.unselectedMenuItemStyle);
// The style is overwritten by anything specifically set in menuitem
if (mi.BackColor != Color.Empty)
td.BackColor = mi.BackColor;
if (mi.Font != null)
td.Font.CopyFrom(mi.Font);
if (mi.ForeColor != Color.Empty)
td.ForeColor = mi.ForeColor;
if (mi.Height != Unit.Empty)
td.Height = mi.Height;
if (mi.Width != Unit.Empty)
td.Width = mi.Width;
if (mi.CssClass != String.Empty)
td.CssClass = mi.CssClass;
else if (this.DefaultCssClass != String.Empty)
td.CssClass = this.DefaultCssClass;
if (mi.BorderColor != Color.Empty)
td.BorderColor = mi.BorderColor;
if (mi.BorderStyle != BorderStyle.NotSet)
td.BorderStyle = mi.BorderStyle;
if (mi.BorderWidth != Unit.Empty)
td.BorderWidth = mi.BorderWidth;
if (mi.HorizontalAlign != System.Web.UI.WebControls.HorizontalAlign.NotSet)
td.HorizontalAlign = mi.HorizontalAlign;
if (mi.VerticalAlign != System.Web.UI.WebControls.VerticalAlign.NotSet)
td.VerticalAlign = mi.VerticalAlign;
BuildOpacity(td);
if (mi.Text != string.Empty)
td.Text = mi.Text; // Text
else if (mi.Image != string.Empty) // Show Image
{
System.Web.UI.WebControls.Image cellimage = new System.Web.UI.WebControls.Image();
cellimage.ImageUrl = mi.Image;
//.........这里部分代码省略.........
示例9: AddMenu
/// <summary>
/// AddMenu is called recusively, doing a depth-first traversal of the menu hierarchy and building
/// up the HTML elements from the object model.
/// </summary>
/// <param name="menuID">The ID of the parent menu.</param>
/// <param name="myItems">The collection of menuitems.</param>
protected virtual void AddMenu(string menuID, MenuItemCollection myItems)
{
string image = string.Empty;
string mouseoverimage = string.Empty;
string mousedownimage = string.Empty;
string mouseupimage = string.Empty;
// iterate through the Items
Table menu = new Table();
menu.Attributes.Add("id", menuID);
menu.Attributes.Add("style", "display: none;");
// The style is overwritten by anthing specifically set in menuitem
if (this.BackColor != Color.Empty)
menu.BackColor = this.BackColor;
if (this.Font != null)
menu.Font.CopyFrom(this.Font);
if (this.ForeColor != Color.Empty)
menu.ForeColor = this.ForeColor;
if (this.SubMenuCssClass != String.Empty)
menu.CssClass = this.SubMenuCssClass;
else if (this.CssClass != String.Empty) // Use if SubMenuCssClass was blank
menu.CssClass = this.CssClass;
if (this.BorderColor != Color.Empty)
menu.BorderColor = this.BorderColor;
if (this.BorderStyle != BorderStyle.NotSet)
menu.BorderStyle = this.BorderStyle;
if (this.BorderWidth != Unit.Empty)
menu.BorderWidth = this.BorderWidth;
menu.CellPadding = ItemPadding;
menu.CellSpacing = ItemSpacing;
menu.GridLines = GridLines;
menu.Style.Add("z-index", curzindex.ToString());
curzindex += 2;
BuildOpacity(menu);
// Iterate through the menuItem's subMenu...
for (int i = 0; i < myItems.Count; i++)
{
MenuItem mi = myItems[i];
// only render this MenuItem if it is visible and the user has permissions
if (mi.Visible && UserHasPermission(mi))
{
TableRow tr = new TableRow();
TableCell td = new TableCell();
td.ApplyStyle(this.unselectedMenuItemStyle);
// The style is overwritten by anything specifically set in menuitem
if (mi.BackColor != Color.Empty)
td.BackColor = mi.BackColor;
if (mi.Font != null)
td.Font.CopyFrom(mi.Font);
if (mi.ForeColor != Color.Empty)
td.ForeColor = mi.ForeColor;
if (mi.Height != Unit.Empty)
td.Height = mi.Height;
if (mi.Width != Unit.Empty)
td.Width = mi.Width;
if (mi.CssClass != String.Empty)
td.CssClass = mi.CssClass;
else if (this.DefaultCssClass != String.Empty)
td.CssClass = this.DefaultCssClass;
if (mi.BorderColor != Color.Empty)
td.BorderColor = mi.BorderColor;
if (mi.BorderStyle != BorderStyle.NotSet)
td.BorderStyle = mi.BorderStyle;
if (mi.BorderWidth != Unit.Empty)
td.BorderWidth = mi.BorderWidth;
if (mi.HorizontalAlign != System.Web.UI.WebControls.HorizontalAlign.NotSet)
td.HorizontalAlign = mi.HorizontalAlign;
if (mi.VerticalAlign != System.Web.UI.WebControls.VerticalAlign.NotSet)
td.VerticalAlign = mi.VerticalAlign;
BuildOpacity(td);
if (mi.Text != string.Empty)
{
//add by johnny start
if (this.MarginLeftWidth != 0)
{
StringBuilder sb = new StringBuilder();
sb.Append("<span style='margin-left:");
sb.Append(this.MarginLeftWidth);
sb.Append(";'>");
sb.Append(mi.Text);
sb.Append("</span>");
td.Text = sb.ToString();
}
else
{
td.Text = mi.Text;
}
//end
}
//.........这里部分代码省略.........
示例10: RenderTitle
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)
);
}
//.........这里部分代码省略.........
示例11: RenderAllDays
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);
//.........这里部分代码省略.........
示例12: RenderHeader
/// <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>");
}
示例13: Init
public void Init(Control target, Style messageStyle)
{
UpdatePanel messageUpdatePanel = target.FindControl("messageUpdatePanel") as UpdatePanel;
if (null == messageUpdatePanel)
{
messageUpdatePanel = new UpdatePanel();
messageUpdatePanel.ID = "messageUpdatePanel";
target.Controls.Add(messageUpdatePanel);
Table messageTable = new Table();
TableRow messageRow = new TableRow();
TableCell messageCell = new TableCell();
messageCell.ApplyStyle(messageStyle);
_message = new Label();
messageCell.Controls.Add(this._message);
messageRow.Cells.Add(messageCell);
messageTable.Rows.Add(messageRow);
messageUpdatePanel.ContentTemplateContainer.Controls.Add(messageTable);
}
UpdatePanel commandersUpdatePanel = target.FindControl("commandersUpdatePanel") as UpdatePanel;
if (null == commandersUpdatePanel)
{
commandersUpdatePanel = new UpdatePanel();
commandersUpdatePanel.ID = "commandersUpdatePanel";
target.Controls.Add(commandersUpdatePanel);
}
Panel commandersWrapper = commandersUpdatePanel.FindControl("commandersWrapper") as Panel;
if (null == commandersWrapper)
{
commandersWrapper = new Panel();
commandersWrapper.ID = "commandersWrapper";
commandersWrapper.CssClass = "table-responsive";
commandersUpdatePanel.ContentTemplateContainer.Controls.Add(commandersWrapper);
}
_commandersHolder = commandersWrapper.FindControl("commandersHolder");
if (null == _commandersHolder)
{
_commandersHolder = new Table();
_commandersHolder.ID = "commandersHolder";
((Table)_commandersHolder).CssClass = "";
commandersWrapper.Controls.Add(_commandersHolder);
}
_selectorsHolder = target.FindControl("selectorsHolder");
if (null == _selectorsHolder)
{
_selectorsHolder = new Table();
_selectorsHolder.ID = "selectorsHolder";
target.Controls.Add(this._selectorsHolder);
}
UpdatePanel updatePanel = target.FindControl("containerUpdatePanel") as UpdatePanel;
if (null == updatePanel)
{
updatePanel = new UpdatePanel();
updatePanel.ID = "containerUpdatePanel";
target.Controls.Add(updatePanel);
}
Panel wrapper = updatePanel.FindControl("containerWrapper") as Panel;
if (null == wrapper)
{
wrapper = new Panel();
wrapper.ID = "containerWrapper";
wrapper.CssClass = "table-responsive";
updatePanel.ContentTemplateContainer.Controls.Add(wrapper);
}
Table innerTable = wrapper.FindControl("innerTable") as Table;
if (null == innerTable)
{
innerTable = new Table();
innerTable.ID = "innerTable";
innerTable.CssClass = "table table-striped table-hover table-condensed";
wrapper.Controls.Add(innerTable);
}
if (null == this._container)
{
_container = innerTable;
}
}
示例14: CreateDayHeader
private TableRow CreateDayHeader(DateTime firstDay, DateTime visibleDate, System.Globalization.Calendar threadCalendar)
{
TableRow row = new TableRow();
DateTimeFormatInfo dtf = DateTimeFormatInfo.CurrentInfo;
TableItemStyle dayNameStyle = new TableItemStyle();
dayNameStyle.HorizontalAlign = HorizontalAlign.Center;
dayNameStyle.CopyFrom(DayHeaderStyle);
DayNameFormat dayNameFormat = DayNameFormat;
int numericFirstDay = (int)threadCalendar.GetDayOfWeek(firstDay);
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:
System.Diagnostics.Debug.Assert(false, "Unknown DayNameFormat value!");
goto
case DayNameFormat.Short;
}
TableCell cell = new TableCell();
cell.ApplyStyle(dayNameStyle);
cell.Text = dayName;
row.Cells.Add(cell);
}
return row;
}
示例15: InitializeCell
public virtual void InitializeCell(TableCell cell, int columnIndex, ListItemType itemType)
{
switch(itemType)
{
case ListItemType.Header : InitializeCellHeader(cell, columnIndex);
break;
case ListItemType.Footer : InitializeCellFooter(cell, columnIndex);
break;
default : if (ItemStyleInternal != null)
cell.ApplyStyle (ItemStyleInternal);
return;
}
}