/// <include file='doc\ChtmlCalendarAdapter.uex' path='docs/doc[@for="ChtmlCalendarAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { ArrayList arr; DateTime tempDate; DateTimeFormatInfo currentDateTimeInfo = DateTimeFormatInfo.CurrentInfo; String abbreviatedMonthDayPattern = AbbreviateMonthPattern(currentDateTimeInfo.MonthDayPattern); _threadCalendar = currentDateTimeInfo.Calendar; bool breakAfter = false; writer.EnterStyle(Style); Debug.Assert(NotSecondaryUI == NotSecondaryUIInit); switch (SecondaryUIMode) { case FirstPrompt: String promptText = Control.CalendarEntryText; if (String.IsNullOrEmpty(promptText)) { promptText = SR.GetString(SR.CalendarAdapterFirstPrompt); } // Link to input option selection screen RenderPostBackEventAsAnchor(writer, OptionPrompt.ToString(CultureInfo.InvariantCulture), promptText); // We should honor BreakAfter property here as the first // UI is shown with other controls on the same form. // For other secondary UI, it is not necessary. if (Control.BreakAfter) { breakAfter = true; } break; // Render the first secondary page that provides differnt // options to select a date. case OptionPrompt: writer.Write(SR.GetString(SR.CalendarAdapterOptionPrompt)); writer.WriteBreak(); arr = new ArrayList(); // Option to select the default date arr.Add(Control.VisibleDate.ToString( currentDateTimeInfo.ShortDatePattern, CultureInfo.CurrentCulture)); // Option to another page that can enter a date by typing arr.Add(SR.GetString(SR.CalendarAdapterOptionType)); // Options to a set of pages for selecting a date, a week // or a month by picking month/year, week and day // accordingly. Available options are determined by // SelectionMode. arr.Add(SR.GetString(SR.CalendarAdapterOptionChooseDate)); if (Control.SelectionMode == CalendarSelectionMode.DayWeek || Control.SelectionMode == CalendarSelectionMode.DayWeekMonth) { arr.Add(SR.GetString(SR.CalendarAdapterOptionChooseWeek)); if (Control.SelectionMode == CalendarSelectionMode.DayWeekMonth) { arr.Add(SR.GetString(SR.CalendarAdapterOptionChooseMonth)); } } DataBindAndRender(writer, _optionList, arr); break; // Render a title and textbox to capture a date entered by user case TypeDate: if (_textBoxErrorMessage != null) { writer.Write(_textBoxErrorMessage); writer.WriteBreak(); } if (_selectList.Visible) { writer.Write(SR.GetString(SR.CalendarAdapterOptionEra)); writer.WriteBreak(); _selectList.RenderControl(writer); } String numericDateFormat = GetNumericDateFormat(); writer.Write(SR.GetString(SR.CalendarAdapterOptionType)); writer.Write(":"); writer.WriteBreak(); writer.Write("("); writer.Write(numericDateFormat.ToUpper(CultureInfo.InvariantCulture)); writer.Write(")"); if (!_selectList.Visible) { writer.Write(GetEra(Control.VisibleDate)); } writer.WriteBreak(); _textBox.Numeric = true; _textBox.Size = numericDateFormat.Length; _textBox.MaxLength = numericDateFormat.Length; _textBox.Text = Control.VisibleDate.ToString(numericDateFormat, CultureInfo.InvariantCulture); _textBox.Visible = true; _textBox.RenderControl(writer); // Command button for sending the textbox value back to the server _command.Text = GetDefaultLabel(OKLabel); _command.Visible = true; _command.RenderControl(writer); break; // Render a paged list for choosing a month case ChooseMonth: writer.Write(SR.GetString(SR.CalendarAdapterOptionChooseMonth)); writer.Write(":"); writer.WriteBreak(); tempDate = Control.VisibleDate; String abbreviatedYearMonthPattern = AbbreviateMonthPattern(currentDateTimeInfo.YearMonthPattern); // This is to be consistent with ASP.NET Calendar control // on handling YearMonthPattern: // Some cultures have a comma in their YearMonthPattern, // which does not look right in a calendar. Here we // strip the comma off. int indexComma = abbreviatedYearMonthPattern.IndexOf(','); if (indexComma >= 0) { abbreviatedYearMonthPattern = abbreviatedYearMonthPattern.Remove(indexComma, 1); } arr = new ArrayList(); for (int i = 0; i < _monthsToDisplay; i++) { arr.Add(tempDate.ToString(abbreviatedYearMonthPattern, CultureInfo.CurrentCulture)); tempDate = _threadCalendar.AddMonths(tempDate, 1); } arr.Add(GetDefaultLabel(NextLabel)); arr.Add(GetDefaultLabel(PreviousLabel)); DataBindAndRender(writer, _monthList, arr); break; // Based on the month selected in case ChooseMonth above, render a list of // availabe weeks of the month. case ChooseWeek: String monthFormat = (GetNumericDateFormat()[0] == 'y') ? "yyyy/M" : "M/yyyy"; writer.Write(SR.GetString(SR.CalendarAdapterOptionChooseWeek)); writer.Write(" ("); writer.Write(Control.VisibleDate.ToString(monthFormat, CultureInfo.CurrentCulture)); writer.Write("):"); writer.WriteBreak(); // List weeks of days of the selected month. May include // days from the previous and the next month to fill out // all six week choices. This is consistent with the // ASP.NET Calendar control. // Note that the event handling code of this list control // should be implemented according to the index content // generated here. tempDate = FirstCalendarDay(Control.VisibleDate); arr = new ArrayList(); String weekDisplay; for (int i = 0; i < 6; i++) { weekDisplay = tempDate.ToString(abbreviatedMonthDayPattern, CultureInfo.CurrentCulture); weekDisplay += DaySeparator; tempDate = _threadCalendar.AddDays(tempDate, 6); weekDisplay += tempDate.ToString(abbreviatedMonthDayPattern, CultureInfo.CurrentCulture); arr.Add(weekDisplay); tempDate = _threadCalendar.AddDays(tempDate, 1); } DataBindAndRender(writer, _weekList, arr); break; // Based on the month and week selected in case ChooseMonth and ChooseWeek above, // render a list of the dates in the week. case ChooseDay: writer.Write(SR.GetString(SR.CalendarAdapterOptionChooseDate)); writer.Write(":"); writer.WriteBreak(); tempDate = Control.VisibleDate; arr = new ArrayList(); String date; String dayName; StringBuilder dayDisplay = new StringBuilder(); bool dayNameFirst = (GetNumericDateFormat()[0] != 'y'); for (int i = 0; i < 7; i++) { date = tempDate.ToString(abbreviatedMonthDayPattern, CultureInfo.CurrentCulture); if (Control.ShowDayHeader) { // Use the short format for displaying day name dayName = GetAbbreviatedDayName(tempDate); dayDisplay.Length = 0; if (dayNameFirst) { dayDisplay.Append(dayName); dayDisplay.Append(Space); dayDisplay.Append(date); } else { dayDisplay.Append(date); dayDisplay.Append(Space); dayDisplay.Append(dayName); } arr.Add(dayDisplay.ToString()); } else { arr.Add(date); } tempDate = _threadCalendar.AddDays(tempDate, 1); } DataBindAndRender(writer, _dayList, arr); break; default: Debug.Assert(false, "Unexpected Secondary UI Mode"); break; } writer.ExitStyle(Style, breakAfter); }
/// <include file='doc\HtmlFormAdapter.uex' path='docs/doc[@for="HtmlFormAdapter.RenderPager"]/*' /> protected virtual void RenderPager(HtmlMobileTextWriter writer) { if(!_renderPager) { return; } PagerStyle pagerStyle = Control.PagerStyle; int pageCount = Control.PageCount; if (pageCount <= 1) { return; } int page = Control.CurrentPage; String text = pagerStyle.GetPageLabelText(page, pageCount); if((page > 1) || (text.Length > 0) || (page < pageCount)) { writer.EnterStyle(pagerStyle); } if (page > 1) { RenderPagerTag(writer, page - 1, pagerStyle.GetPreviousPageText(page)); writer.Write(" "); } if (text.Length > 0) { writer.WriteEncodedText(text); writer.Write(" "); } if (page < pageCount) { RenderPagerTag(writer, page + 1, pagerStyle.GetNextPageText(page)); } if((page > 1) || (text.Length > 0) || (page < pageCount)) { writer.ExitStyle(pagerStyle, true); } }
/// <include file='doc\HtmlFormAdapter.uex' path='docs/doc[@for="HtmlFormAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { Color backColor = (Color)Style[Style.BackColorKey, true]; String title = Control.Title; bool isTitleEmpty = String.IsNullOrEmpty(title); bool willWriteHeadElements = !isTitleEmpty || RenderExtraHeadElements(null); if (willWriteHeadElements) { writer.Write("\r\n"); writer.WriteFullBeginTag("head"); } if (!isTitleEmpty) { writer.Write("\r\n"); writer.WriteFullBeginTag("title"); writer.Write(title); writer.WriteEndTag("title"); writer.Write("\r\n"); } _renderPager = true; RenderExtraHeadElements(writer); if (willWriteHeadElements) { writer.WriteEndTag("head"); writer.Write("\r\n"); } IDictionary bodyAttributes = new ListDictionary(); if ((backColor != Color.Empty) && (writer.RenderBodyColor)) { bodyAttributes.Add("bgcolor", ColorTranslator.ToHtml(backColor)); } RenderBodyTag(writer, bodyAttributes); bool formTagRequired = ShouldRenderFormTag(); if (formTagRequired) { writer.WriteBeginTag("form"); writer.WriteAttribute("id", Control.ClientID); writer.WriteAttribute("name", Control.ClientID); writer.WriteAttribute("method", Control.Method.ToString().ToLower(CultureInfo.InvariantCulture)); writer.Write(" action=\""); if (Control.Action.Length > 0) { // AUI 3652 String url = Control.ResolveUrl(Control.Action); if (!Device.SupportsQueryStringInFormAction) { // If query string is not supported, we don't write // it here, and the query string will be added as // hidden variables later. int i = url.IndexOf('?'); if (i != -1) { url = url.Substring(0, i); } } writer.Write(url); } else { writer.WriteEncodedUrl(Page.RelativeFilePath); if (Device.SupportsQueryStringInFormAction) { writer.Write("?"); writer.Write(Page.UniqueFilePathSuffix); if (Control.Method != FormMethod.Get) { String queryStringText = Page.QueryStringText; if (queryStringText != null && queryStringText.Length > 0) { writer.Write('&'); writer.Write(queryStringText); } } } } writer.Write("\""); writer.Write(">\r\n"); PageAdapter.RenderPostBackHeader(writer, Control); // Renders hidden variables for IPostBackDataHandlers which are // not displayed due to pagination or secondary UI. RenderOffPageVariables(writer, Control, Control.CurrentPage); } writer.EnterStyle(Style); writer.BeforeFirstControlWritten = true; MobileControl secondaryUIControl = SecondaryUIControl as MobileControl; if (secondaryUIControl != null && secondaryUIControl.Form == Control) { bool secondaryUIInHeaderOrFooter = IsControlInFormHeader(secondaryUIControl) || IsControlInFormFooter(secondaryUIControl); SetControlPageRecursive(secondaryUIControl, -1); if(Control.Header != null && !secondaryUIInHeaderOrFooter) { Control.Header.RenderControl(writer); } secondaryUIControl.RenderControl(writer); if(Control.Footer != null && !secondaryUIInHeaderOrFooter) { Control.Footer.RenderControl(writer); } } else { bool pagerRendered = false; if(Control.HasControls()) { foreach(Control child in Control.Controls) { if(Control.Footer == child) { RenderPager(writer); pagerRendered = true; } child.RenderControl(writer); } } if(!pagerRendered) { RenderPager(writer); } } writer.ExitStyle(Style, false); if (formTagRequired) { if (!Device.SupportsQueryStringInFormAction) { // Add query string parameters at the end of the form if // there are any RenderQueryParametersAsHiddenFields(writer); } writer.WriteEndTag("form"); } writer.WriteEndTag("body"); }
/// <include file='doc\HtmlControlAdapter.uex' path='docs/doc[@for="HtmlControlAdapter.RenderPostBackEventAsAnchor"]/*' /> protected void RenderPostBackEventAsAnchor( HtmlMobileTextWriter writer, String argument, String linkText) { writer.EnterStyle(Style); writer.WriteBeginTag("a"); RenderPostBackEventAsAttribute(writer, "href", argument); writer.Write(">"); writer.WriteText(linkText, true); writer.WriteEndTag("a"); writer.ExitStyle(Style); }