/// <include file='doc\HtmlTextBoxAdapter.uex' path='docs/doc[@for="HtmlTextBoxAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { writer.EnterLayout(Style); writer.WriteBeginTag("input"); writer.WriteAttribute("name", GetRenderName()); if ((Control.Text == null || Control.Text.Length > 0) && !Control.Password) { writer.Write(" value=\""); writer.WriteText(Control.Text, true); writer.Write("\""); } if (Control.Size > 0) { writer.WriteAttribute("size", Control.Size.ToString(CultureInfo.InvariantCulture)); } if (Control.MaxLength > 0) { writer.WriteAttribute("maxlength", Control.MaxLength.ToString(CultureInfo.InvariantCulture)); } if (Control.Password) { writer.WriteAttribute("type", "password"); } AddAttributes(writer); writer.Write("/>"); writer.ExitLayout(Style, Control.BreakAfter); writer.InputWritten = true; }
/// <include file='doc\HtmlTextBoxAdapter.uex' path='docs/doc[@for="HtmlTextBoxAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { writer.EnterLayout(Style); writer.WriteBeginTag("input"); writer.WriteAttribute("name", GetRenderName()); if ((Control.Text == null || Control.Text.Length > 0) && !Control.Password) { writer.Write(" value=\""); writer.WriteText(Control.Text, true); writer.Write("\""); } if (Control.Size > 0) { writer.WriteAttribute("size", Control.Size.ToString(CultureInfo.InvariantCulture)); } if (Control.MaxLength > 0) { writer.WriteAttribute("maxlength", Control.MaxLength.ToString(CultureInfo.InvariantCulture)); } if (Control.Password) { writer.WriteAttribute("type", "password"); } AddAttributes(writer); writer.Write("/>"); writer.ExitLayout(Style, Control.BreakAfter); writer.InputWritten = true; }
/// <include file='doc\ChtmlFormAdapter.uex' path='docs/doc[@for="ChtmlFormAdapter.RenderExtraHeadElements"]/*' /> protected override bool RenderExtraHeadElements(HtmlMobileTextWriter writer) { bool result = false; String metaTagName = Device.RequiredMetaTagNameValue; if (metaTagName != null) { if (writer != null) { writer.Write("<meta NAME=\"" + metaTagName + "\" CONTENT=\"True\">\r\n"); } result = true; } String charset = Page.Response.Charset; if (Device.RequiresContentTypeMetaTag && charset != null && charset.Length > 0) { if (writer != null) { writer.Write(String.Format(CultureInfo.InvariantCulture, _contentTypeMetaTag, Device.PreferredRenderingMime, charset)); } result = true; } return(result); }
private void RenderRule(HtmlMobileTextWriter writer, Color foreColor, int columnSpan) { writer.Write("<tr><td colspan="); writer.Write(columnSpan.ToString()); writer.Write(" bgcolor=\""); writer.Write((foreColor == Color.Empty) ? "#000000" : ColorTranslator.ToHtml(foreColor)); writer.Write("\"></td></tr>"); }
private void RenderRule(HtmlMobileTextWriter writer, Color foreColor, int columnSpan) { writer.Write("<tr><td colspan="); writer.Write(columnSpan.ToString(CultureInfo.InvariantCulture)); writer.Write(" bgcolor=\""); writer.Write((foreColor != Color.Empty) ? ColorTranslator.ToHtml(foreColor) : "#000000"); writer.Write("\"></td></tr>"); }
// Return true if actually wrote any head elements. If called with // null, this returns whether head elements would be written if called // with a real writer. /// <include file='doc\HtmlFormAdapter.uex' path='docs/doc[@for="HtmlFormAdapter.RenderExtraHeadElements"]/*' /> protected virtual bool RenderExtraHeadElements(HtmlMobileTextWriter writer) { bool result = false; String metaTagName = Device.RequiredMetaTagNameValue; if (metaTagName != null) { if (writer != null) { writer.Write("<meta NAME=\"" + metaTagName + "\" CONTENT=\"True\">\r\n"); } result = true; } String charset = Page.Response.Charset; if (Device.RequiresContentTypeMetaTag && charset != null && charset.Length > 0) { if (writer != null) { writer.Write(String.Format(CultureInfo.InvariantCulture, _contentTypeMetaTag, Device.PreferredRenderingMime, charset)); } result = true; } Form form = this.Control as Form; if (writer == null) { if ((form != null) && (form.Script != null)) { result = true; } } else if ((form != null) && (form.Script != null)) { foreach (Control childControl in form.Script.Controls) { LiteralControl lc = childControl as LiteralControl; if (lc != null) { writer.Write(lc.Text); } else { DataBoundLiteralControl dlc = childControl as DataBoundLiteralControl; if (dlc != null) { writer.Write(dlc.Text); } } } result = true; } return(result); }
public virtual void RenderPostBackEvent(HtmlMobileTextWriter writer, String target, String argument) { writer.Write("javascript:__doPostBack('"); writer.Write(target); writer.Write("','"); writer.Write(argument); writer.Write("')"); }
public override void Render(HtmlMobileTextWriter writer) { String additionalStyle; Alignment alignment = (Alignment)Style[Style.AlignmentKey, true]; Wrapping wrapping = (Wrapping)Style[Style.WrappingKey, true]; bool wrap = (wrapping == Wrapping.Wrap || wrapping == Wrapping.NotSet); String width = DesignerAdapterUtil.GetWidth(Control); ((DesignerTextWriter)writer).EnterZeroFontSizeTag(); writer.EnterLayout(Style); writer.WriteBeginTag("div"); if (!wrap) { byte templateStatus; int maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus); if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT) { width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px"; } additionalStyle = "overflow-x:hidden;width:" + width + ";"; } else { additionalStyle = "word-wrap:break-word;width:" + width + ";"; } ((DesignerTextWriter)writer).WriteStyleAttribute(Style, additionalStyle); if (alignment != Alignment.NotSet) { writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); } writer.Write(">"); writer.WriteText(Control.HeaderText, true); writer.WriteFullBeginTag("ul"); for (int i = 1; i <= 2; i++) { writer.WriteFullBeginTag("li"); writer.Write(SR.GetString(SR.ValidationSummary_ErrorMessage, i.ToString(CultureInfo.InvariantCulture))); writer.WriteEndTag("li"); } writer.WriteEndTag("ul"); writer.WriteBeginTag("a"); writer.WriteAttribute("href", "NavigationUrl"); writer.Write(">"); writer.WriteText(String.IsNullOrEmpty(Control.BackLabel) ? GetDefaultLabel(BackLabel) : Control.BackLabel, true); writer.WriteEndTag("a"); writer.WriteEndTag("div"); writer.ExitLayout(Style); ((DesignerTextWriter)writer).ExitZeroFontSizeTag(); }
protected void RenderPostBackEventAsAttribute( HtmlMobileTextWriter writer, String attributeName, String argument) { writer.Write(" "); writer.Write(attributeName); writer.Write("=\""); RenderPostBackEventReference(writer, argument); writer.Write("\" "); }
/// <include file='doc\HtmlPhoneCallAdapter.uex' path='docs/doc[@for="HtmlPhoneCallAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { writer.EnterStyle(Style); if (Device.CanInitiateVoiceCall) { String text = Control.Text; String phoneNumber = Control.PhoneNumber; if (String.IsNullOrEmpty(text)) { text = phoneNumber; } writer.WriteBeginTag("a"); writer.Write(" href=\"tel:"); foreach (char ch in phoneNumber) { if (ch >= '0' && ch <= '9' || ch == '#' || ch=='+') { writer.Write(ch); } } writer.Write("\""); AddAttributes(writer); writer.Write(">"); writer.WriteText(text, true); writer.WriteEndTag("a"); } else { // Format the text string based on properties String text = String.Format(CultureInfo.CurrentCulture, Control.AlternateFormat, Control.Text, Control.PhoneNumber); String url = Control.AlternateUrl; // If URI specified, create a link. Otherwise, only text is displayed. if (!String.IsNullOrEmpty(url)) { RenderBeginLink(writer, url); writer.WriteText(text, true); RenderEndLink(writer); } else { writer.WriteText(text, true); } } writer.ExitStyle(Style, Control.BreakAfter); }
/// <include file='doc\HtmlPhoneCallAdapter.uex' path='docs/doc[@for="HtmlPhoneCallAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { writer.EnterStyle(Style); if (Device.CanInitiateVoiceCall) { String text = Control.Text; String phoneNumber = Control.PhoneNumber; if (String.IsNullOrEmpty(text)) { text = phoneNumber; } writer.WriteBeginTag("a"); writer.Write(" href=\"tel:"); foreach (char ch in phoneNumber) { if (ch >= '0' && ch <= '9' || ch == '#' || ch == '+') { writer.Write(ch); } } writer.Write("\""); AddAttributes(writer); writer.Write(">"); writer.WriteText(text, true); writer.WriteEndTag("a"); } else { // Format the text string based on properties String text = String.Format(CultureInfo.CurrentCulture, Control.AlternateFormat, Control.Text, Control.PhoneNumber); String url = Control.AlternateUrl; // If URI specified, create a link. Otherwise, only text is displayed. if (!String.IsNullOrEmpty(url)) { RenderBeginLink(writer, url); writer.WriteText(text, true); RenderEndLink(writer); } else { writer.WriteText(text, true); } } writer.ExitStyle(Style, Control.BreakAfter); }
public override void Render(HtmlMobileTextWriter writer) { writer.WriteBeginTag("div"); String width = DesignerAdapterUtil.GetWidth(Control); writer.WriteAttribute("style", "cellpadding=2px;width:" + width); Alignment alignment = (Alignment)Style[Style.AlignmentKey, true]; if (alignment != Alignment.NotSet) { writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); } writer.Write("/>"); ((DesignerTextWriter)writer).EnterZeroFontSizeTag(); //Note: Although this is an internal method of runtime, but it is still // pretty easy to achieve the same goal without using this method. Style.ApplyTo(Control.WebCalendar); base.Render(writer); ((DesignerTextWriter)writer).ExitZeroFontSizeTag(); writer.WriteEndTag("div"); }
public override void Render(HtmlMobileTextWriter writer) { Alignment alignment = (Alignment)Style[Style.AlignmentKey, true]; byte templateStatus; int maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus); String width = DesignerAdapterUtil.GetWidth(Control); if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT) { width = maxWidth.ToString() + "px"; } writer.WriteBeginTag("div"); if (alignment == Alignment.Center) { writer.WriteAttribute("align", "center"); } writer.WriteAttribute("style", "overflow-x:hidden;width:" + width); writer.Write(">"); String source = Control.ImageUrl; writer.WriteBeginTag("img"); ((DesignerTextWriter)writer).WriteStyleAttribute(Style); if (source != "") { writer.WriteAttribute("src", source, true); } if (Control.AlternateText != "") { writer.Write(" alt=\""); writer.WriteText(Control.AlternateText, true); writer.Write("\""); } // center alignment not part of HTML for images. if (alignment == Alignment.Right || alignment == Alignment.Left) { writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); } writer.WriteAttribute("border", "0"); writer.Write(">"); writer.WriteEndTag("div"); }
/// <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\ChtmlImageAdapter.uex' path='docs/doc[@for="ChtmlImageAdapter.RenderImage"]/*' /> protected internal override void RenderImage(HtmlMobileTextWriter writer) { String source = Control.ImageUrl; if (source.StartsWith(Constants.SymbolProtocol, StringComparison.Ordinal) && (Device.SupportsIModeSymbols || Device.SupportsJPhoneSymbols)) { if (Device.SupportsIModeSymbols) { writer.Write("&#"); writer.Write( source.Substring(Constants.SymbolProtocol.Length)); writer.Write(";"); } else { // The ImageUrl should be in the format "symbol:xyyy", // where x is group picture character (either G, E or F), // and yyy (length can vary) is the picture's character // code (in decimal). String symbolChars = source.Substring( Constants.SymbolProtocol.Length); char code = DecimalStringToChar(symbolChars.Substring(1)); writer.Write("\u001B$"); writer.Write(Char.ToUpper(symbolChars[0], CultureInfo.InvariantCulture)); writer.Write(code); writer.Write('\u000F'); } } else { base.RenderImage(writer); } }
private void RenderPostBackEventAsAnchor(HtmlMobileTextWriter writer, string argument, string linkText, Style style) { writer.EnterFormat(style); writer.WriteBeginTag("a"); base.RenderPostBackEventAsAttribute(writer, "href", argument); writer.Write(">"); writer.WriteText(linkText, true); writer.WriteEndTag("a"); writer.ExitFormat(style); }
public override void Render(HtmlMobileTextWriter writer) { writer.WriteBeginTag("div"); ((DesignerTextWriter)writer).WriteDesignerStyleAttributes(Control, Style); writer.Write("\">"); base.Render(writer); writer.WriteEndTag("div"); }
public override void Render(HtmlMobileTextWriter writer) { Alignment alignment = (Alignment)Style[Style.AlignmentKey, true]; String width = DesignerAdapterUtil.GetWidth(Control); byte templateStatus; int maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus); if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT) { width = maxWidth.ToString() + "px"; } writer.WriteBeginTag("div"); if (alignment == Alignment.Center) { writer.WriteAttribute("align", "center"); } writer.WriteAttribute("style", "padding=2px;overflow-x:hidden;width:" + width); writer.Write(">"); ((DesignerTextWriter)writer).EnterZeroFontSizeTag(); writer.WriteBeginTag("img"); writer.WriteAttribute("alt", Control.ID); ((DesignerTextWriter)writer).WriteStyleAttribute(Style); // center alignment not part of HTML for images. if (alignment == Alignment.Right || alignment == Alignment.Left) { writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); } writer.WriteAttribute("height", "40"); writer.WriteAttribute("width", "250"); writer.WriteAttribute("border", "0"); writer.Write(">"); ((DesignerTextWriter)writer).ExitZeroFontSizeTag(); writer.WriteEndTag("div"); }
public override void Render(HtmlMobileTextWriter writer) { Alignment alignment = (Alignment)Style[Style.AlignmentKey, true]; Wrapping wrapping = (Wrapping)Style[Style.WrappingKey, true]; bool wrap = (wrapping == Wrapping.Wrap || wrapping == Wrapping.NotSet); ((DesignerTextWriter)writer).EnterZeroFontSizeTag(); writer.WriteBeginTag("div"); String width = DesignerAdapterUtil.GetWidth(Control); if (!wrap) { byte templateStatus; int maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus); if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT) { width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px"; } writer.WriteAttribute("style", "overflow-x:hidden;width:" + width); } else { writer.WriteAttribute("style", "word-wrap:break-word;width:" + width); } if (alignment != Alignment.NotSet) { writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); } writer.Write(">"); writer.WriteBeginTag("a"); writer.WriteAttribute("href", "NavigationUrl"); writer.Write(">"); ((DesignerTextWriter)writer).WriteCssStyleText(Style, null, Control.Text, true); writer.WriteEndTag("a"); writer.WriteEndTag("div"); ((DesignerTextWriter)writer).ExitZeroFontSizeTag(); }
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); }
public virtual void RenderForm(HtmlMobileTextWriter writer, Form form) { writer.BeginFile(GetFormUrl(form), "text/html", Page.Response.Charset); writer.WriteFullBeginTag("html"); form.RenderControl(writer); if (Device.RequiresDBCSCharacter) { // Insert a comment with a space writer.Write("<!--\u3000-->"); } writer.WriteEndTag("html"); writer.EndFile(); }
private void RenderHiddenVariablesInUrl(HtmlMobileTextWriter writer) { if (Page.HasHiddenVariables()) { String hiddenVariablePrefix = MobilePage.HiddenVariablePrefix; foreach (DictionaryEntry entry in Page.HiddenVariables) { writer.Write("&"); writer.WriteUrlParameter(hiddenVariablePrefix + (String)entry.Key, (String)entry.Value); } } }
public override void Render(HtmlMobileTextWriter writer) { Alignment alignment = (Alignment)Style[Style.AlignmentKey, true]; Wrapping wrapping = (Wrapping)Style[Style.WrappingKey, true]; bool wrap = (wrapping == Wrapping.Wrap || wrapping == Wrapping.NotSet); String width = DesignerAdapterUtil.GetWidth(Control); ((DesignerTextWriter)writer).EnterZeroFontSizeTag(); writer.WriteBeginTag("div"); if (!wrap) { byte templateStatus; int maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus); if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT) { width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px"; } writer.WriteAttribute("style", "overflow-x:hidden;width:" + width); } else { writer.WriteAttribute("style", "word-wrap:break-word;width:" + width); } if (alignment != Alignment.NotSet) { writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); } writer.Write(">"); MSHTMLHostUtil.ApplyStyle(null, null, null); String filteredText = FilterTags(Control.Text.Trim()); int uniqueLineHeight = MSHTMLHostUtil.GetHtmlFragmentHeight("a"); int requiredHeight = MSHTMLHostUtil.GetHtmlFragmentHeight(filteredText); int requiredWidth = MSHTMLHostUtil.GetHtmlFragmentWidth(filteredText); ((DesignerTextWriter)writer).WriteCssStyleText(Style, null, (requiredHeight > uniqueLineHeight || requiredWidth > 1) ? filteredText : " ", false); writer.WriteEndTag("div"); ((DesignerTextWriter)writer).ExitZeroFontSizeTag(); }
/// <include file='doc\HtmlImageAdapter.uex' path='docs/doc[@for="HtmlImageAdapter.RenderImage"]/*' /> protected internal virtual void RenderImage(HtmlMobileTextWriter writer) { String source = Control.ImageUrl; writer.WriteBeginTag("img"); if (!String.IsNullOrEmpty(source)) { // AUI 3652 source = Control.ResolveUrl(source); writer.WriteAttribute("src", source, true /*encode*/); writer.AddResource(source); } if (!String.IsNullOrEmpty(Control.AlternateText)) { writer.WriteAttribute("alt", Control.AlternateText, true); } writer.WriteAttribute("border", "0"); writer.Write(" />"); }
public virtual void RenderUrlPostBackEvent(HtmlMobileTextWriter writer, String target, String argument) { writer.WriteEncodedUrl(Page.RelativeFilePath); writer.Write("?"); // Encode ViewStateID=.....&__ET=controlid&__EA=value in URL // Note: the encoding needs to be agreed with the page // adapter which handles the post back info String pageState = Page.ClientViewState; if (pageState != null) { writer.WriteUrlParameter(MobilePage.ViewStateID, pageState); writer.Write("&"); } writer.WriteUrlParameter(EventSourceKey, target); writer.Write("&"); writer.WriteUrlParameter(EventArgumentKey, argument); RenderHiddenVariablesInUrl(writer); // Unique file path suffix is used for identify if query // string text is present. Corresponding code needs to agree // on this. Even if the query string is empty, we still need // to output the suffix to indicate this. (this corresponds // to the code that handles the postback) writer.Write('&'); writer.Write(Constants.UniqueFilePathSuffixVariable); String queryStringText = Page.QueryStringText; if (queryStringText != null && queryStringText.Length > 0) { writer.Write('&'); writer.Write(queryStringText); } }
public override void Render(HtmlMobileTextWriter writer) { // write out the HTML tag writer.Write("<input name=\"" + Control.UniqueID + "\" "); writer.Write("value=\"" + Control.Text + "\" "); if (Control.Password) { writer.Write("type=\"password\" "); } if (Control.Size != 0) { writer.Write("size=\"" + Control.Size + "\" "); } writer.Write("/>"); if (Control.BreakAfter) { writer.Write("<br>"); } }
/// <include file='doc\ChtmlFormAdapter.uex' path='docs/doc[@for="ChtmlFormAdapter.RenderPagerTag"]/*' /> protected internal override void RenderPagerTag( HtmlMobileTextWriter writer, int pageToNavigate, String text) { writer.EnterLayout(Style); writer.EnterFormat(Style); writer.WriteBeginTag("input"); // Specially encode the page number with the control id. // The corresponding code that handles postback should know how // to extract the page number correctly. writer.Write(" name=\""); writer.Write(Control.UniqueID); writer.Write(Constants.PagePrefix); writer.Write(pageToNavigate.ToString(CultureInfo.InvariantCulture)); writer.Write("\""); writer.WriteAttribute("type", "submit"); writer.WriteAttribute("value", text, true); writer.Write("/>"); writer.ExitFormat(Style); writer.ExitLayout(Style); }
/// <include file='doc\HtmlListAdapter.uex' path='docs/doc[@for="HtmlListAdapter.RenderList"]/*' /> protected virtual void RenderList(HtmlMobileTextWriter writer) { MobileListItemCollection items = Control.Items; Wrapping wrap = Style.Wrapping; // used for tables, no decoration case. if (items.Count == 0) { return; } int pageStart = Control.FirstVisibleItemIndex; int pageSize = Control.VisibleItemCount; // Determine what markup to use. String listSuffix, itemPrefix, itemSuffix; ListDecoration decoration = Control.Decoration; bool insideStyle = true; // We know that for table tag, outer style doesn't carry over // into inside tags so style state needs to be reset. // For other cases, we enter the style here once and exit at the // end once. if (decoration != ListDecoration.None || !Device.Tables) { writer.EnterStyle(Style); insideStyle = false; } switch (decoration) { case ListDecoration.Bulleted: writer.WriteLine("<ul>"); listSuffix = "</ul>"; itemPrefix = "<li>"; itemSuffix = "</li>"; if (!Device.RendersBreaksAfterHtmlLists) { listSuffix += "<br>"; } break; case ListDecoration.Numbered: if (pageStart == 0) { writer.WriteLine("<ol>"); } else { writer.Write("<ol start=\""); writer.Write(pageStart + 1); writer.WriteLine("\">"); } listSuffix = "</ol>"; itemPrefix = "<li>"; itemSuffix = "</li>"; if (!Device.RendersBreaksAfterHtmlLists) { listSuffix += "<br>"; } break; default: if (Device.Tables) { listSuffix = "</table>"; Style.Wrapping = Wrapping.NotSet; writer.EnterLayout(Style); writer.WriteLine("<table>"); if (wrap == Wrapping.NoWrap) { itemPrefix = "<tr nowrap><td>"; } else { itemPrefix = "<tr><td>"; } itemSuffix = "</td></tr>"; } else { listSuffix = String.Empty; itemPrefix = String.Empty; itemSuffix = "<br>"; } break; } bool hasCmdHandler = Control.HasItemCommandHandler; for (int i = 0; i < pageSize; i++) { MobileListItem item = items[pageStart + i]; writer.Write(itemPrefix); if (insideStyle) { writer.BeginStyleContext(); writer.EnterFormat(Style); } if (Control.ItemsAsLinks) { RenderBeginLink(writer, item.Value); } else if (hasCmdHandler) { writer.WriteBeginTag("a"); RenderPostBackEventAsAttribute(writer, "href", item.Index.ToString(CultureInfo.InvariantCulture)); writer.Write(">"); } writer.WriteEncodedText(item.Text); if (hasCmdHandler || Control.ItemsAsLinks) { RenderEndLink(writer); } if (insideStyle) { writer.ExitFormat(Style); writer.EndStyleContext(); } writer.WriteLine(itemSuffix); } if (listSuffix == null || listSuffix.Length > 0) { writer.WriteLine(listSuffix); } if (decoration != ListDecoration.None || !Device.Tables) { writer.ExitStyle(Style); } else { writer.ExitLayout(Style); Style.Wrapping = wrap; } }
/// <include file='doc\ChtmlSelectionListAdapter.uex' path='docs/doc[@for="ChtmlSelectionListAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { ListSelectType selectType = Control.SelectType; if (selectType == ListSelectType.MultiSelectListBox && Device.SupportsSelectMultiple == false) { // Render occurs after SaveViewState. Here we make a temp // change which is not persisted to the view state. Control.SelectType = selectType = ListSelectType.CheckBox; } if (!Device.RequiresUniqueHtmlCheckboxNames || selectType != ListSelectType.CheckBox) { base.Render(writer); } else { MobileListItemCollection items = Control.Items; if (items.Count == 0) { return; } writer.EnterStyle(Style); bool writeBreak = false; foreach (MobileListItem item in items) { int index = items.IndexOf(item); if(writeBreak) { writer.WriteBreak(); } writer.Write("<input type=\"checkbox\" name=\""); if(Device.RequiresAttributeColonSubstitution) { writer.Write(Control.UniqueID.Replace(':', ',')); } else { writer.Write(Control.UniqueID); } writer.Write(Constants.SelectionListSpecialCharacter); writer.Write(index); writer.Write("\" value=\""); if (!String.IsNullOrEmpty(Control.Form.Action)) { writer.WriteEncodedText(item.Value); } else { writer.Write(item.Index.ToString(CultureInfo.InvariantCulture)); } if (item.Selected && Device.SupportsUncheck) { writer.Write("\" checked>"); } else { writer.Write("\">"); } writer.WriteText(item.Text, true); writeBreak = true; } writer.ExitStyle(Style, Control.BreakAfter); } }
public override void Render(HtmlMobileTextWriter writer) { writer.EnterStyle(Style); IPanelPane activePane = Control.ActivePane; writer.Write("[ "); int index = 0; foreach (IPanelPane child in Control.Controls) { if (!((Control) child).Visible) { index++; continue; } if (index > 0) { writer.Write(" | "); } if (child == activePane) { writer.Write("<b>"); writer.WriteText(child.Title, true); writer.Write("</b>"); } else { writer.WriteBeginTag("a"); RenderPostBackEventAsAttribute(writer, "href", index.ToString()); writer.Write(">"); writer.WriteText(child.Title, true); writer.WriteEndTag("a"); } index++; } writer.Write(" ]"); writer.WriteBreak(); ((Control) activePane).RenderControl(writer); writer.ExitStyle(Style); }
//********************************************************************* // // HtmlTabbedPanelAdapter.Render Method // // Renders the control. The TabbedPanel is rendered as one or more // rows of tabs that the user can click on to move between tabs. // //********************************************************************* public override void Render(HtmlMobileTextWriter writer) { IPanelPane activePane = Control.ActivePane; int tabsPerRow = Control.TabsPerRow; PanelPaneCollection panes = Control.Panes; int paneCount = panes.Count; // Figure out the number of visible panes. int[] visiblePanes = new int[paneCount]; int visiblePaneCount = 0; for (int i = 0; i < paneCount; i++) { if (((Control) panes[i]).Visible) { visiblePanes[visiblePaneCount++] = i; } } // Calculate how many rows are necessary. int rows = (visiblePaneCount + tabsPerRow - 1)/tabsPerRow; // make sure tabsPerRow doesn't exceed the number of visible panes tabsPerRow = (Control.TabsPerRow > visiblePaneCount) ? visiblePaneCount : Control.TabsPerRow; // Open the table. writer.WriteBeginTag("table"); writer.WriteAttribute("cellspacing", "0"); writer.WriteAttribute("cellpadding", "2"); writer.WriteAttribute("border", "0"); writer.WriteLine(">"); for (int row = rows - 1; row >= 0; row--) { writer.WriteFullBeginTag("tr"); writer.WriteLine(); for (int col = 0; col < tabsPerRow; col++) { writer.WriteBeginTag("td"); writer.WriteAttribute("width", "0"); writer.Write(">"); writer.WriteEndTag("td"); int i = row*tabsPerRow + col; if (row > 0 && i >= visiblePaneCount) { writer.WriteFullBeginTag("td"); writer.WriteEndTag("td"); continue; } int index = visiblePanes[i]; IPanelPane child = panes[index]; if (child == activePane) { writer.WriteBeginTag("td"); writer.WriteAttribute("bgcolor", GetColorString(Control.ActiveTabColor, "#333333")); writer.Write(">"); writer.WriteBeginTag("font"); writer.WriteAttribute("face", "Verdana"); writer.WriteAttribute("size", "-2"); writer.WriteAttribute("color", GetColorString(Control.ActiveTabTextColor, "#000000")); writer.Write(">"); writer.WriteFullBeginTag("b"); writer.Write(" "); writer.WriteText(child.Title, true); writer.Write(" "); writer.WriteEndTag("b"); writer.WriteEndTag("font"); writer.WriteEndTag("td"); writer.WriteLine(); } else { writer.WriteBeginTag("td"); writer.WriteAttribute("bgcolor", GetColorString(Control.TabColor, "#cccccc")); writer.Write(">"); writer.WriteBeginTag("font"); writer.WriteAttribute("face", "Verdana"); writer.WriteAttribute("size", "-2"); writer.WriteAttribute("color", GetColorString(Control.TabTextColor, "#000000")); writer.Write(">"); writer.Write(" "); writer.WriteBeginTag("a"); RenderPostBackEventAsAttribute(writer, "href", index.ToString()); writer.Write(">"); writer.WriteText(child.Title, true); writer.WriteEndTag("a"); writer.Write(" "); writer.WriteEndTag("font"); writer.WriteEndTag("td"); writer.WriteLine(); } } writer.WriteEndTag("tr"); writer.WriteLine(); if (row > 0) { writer.WriteFullBeginTag("tr"); writer.WriteBeginTag("td"); writer.WriteAttribute("height", "1"); writer.Write(">"); writer.WriteEndTag("td"); writer.WriteEndTag("tr"); writer.WriteLine(); } } writer.WriteEndTag("table"); writer.WriteLine(); writer.WriteBeginTag("table"); writer.WriteAttribute("width", "100%"); writer.WriteAttribute("height", "2"); writer.WriteAttribute("border", "0"); writer.WriteAttribute("cellspacing", "0"); writer.WriteAttribute("bgcolor", "#000000"); writer.Write(">"); writer.WriteFullBeginTag("tr"); writer.WriteFullBeginTag("td"); writer.WriteEndTag("td"); writer.WriteEndTag("tr"); writer.WriteEndTag("table"); writer.WriteBreak(); ((Control) activePane).RenderControl(writer); }
// Private overload for use with subcommands. // Style, Enter/ExitFormat included only for completeness because style // is already set for subcommands. private void RenderPostBackEventAsAnchor( HtmlMobileTextWriter writer, String argument, String linkText, Style style) { writer.EnterFormat(style); writer.WriteBeginTag("a"); RenderPostBackEventAsAttribute(writer, "href", argument); writer.Write(">"); writer.WriteText(linkText, true); writer.WriteEndTag("a"); writer.ExitFormat(style); }
private void RenderItemDetailsWithoutTableTags(HtmlMobileTextWriter writer, ObjectListItem item) { Style style = this.Style; Style labelStyle = Control.LabelStyle; Style subCommandStyle = Control.CommandStyle; writer.EnterStyle(labelStyle); writer.WriteText(item[Control.LabelFieldIndex], true); writer.ExitStyle(labelStyle, true); IObjectListFieldCollection fields = Control.AllFields; int fieldIndex = 0; bool boldInStyle = (style.Font.Bold == BooleanOption.True) ? true : false; writer.EnterStyle(style); foreach (ObjectListField field in fields) { if (field.Visible) { if (!boldInStyle) { writer.Write("<b>"); } writer.WriteText(field.Title + ":", true); if (!boldInStyle) { writer.Write("</b>"); } writer.Write(" "); writer.WriteText(item[fieldIndex], true); writer.WriteBreak(); } fieldIndex++; } writer.ExitStyle(style); BooleanOption cachedItalic = subCommandStyle.Font.Italic; subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterStyle(subCommandStyle); writer.Write("[ "); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; writer.EnterStyle(subCommandStyle); ObjectListCommandCollection commands = Control.Commands; foreach (ObjectListCommand command in commands) { RenderPostBackEventAsAnchor(writer, command.Name, command.Text, subCommandStyle); writer.Write(" | "); } String backCommandText = Control.BackCommandText.Length == 0 ? GetDefaultLabel(BackLabel) : Control.BackCommandText; RenderPostBackEventAsAnchor(writer, BackToList, backCommandText, subCommandStyle); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterStyle(subCommandStyle); writer.Write(" ]"); writer.ExitStyle(subCommandStyle, Control.BreakAfter); subCommandStyle.Font.Italic = cachedItalic; }
private void RenderItemsListWithoutTableTags(HtmlMobileTextWriter writer) { int startIndex = Control.FirstVisibleItemIndex; int pageSize = Control.VisibleItemCount; ObjectListItemCollection items = Control.Items; IObjectListFieldCollection allFields = Control.AllFields; int count = allFields.Count; int nextStartIndex = startIndex + pageSize; int labelFieldIndex = Control.LabelFieldIndex; Style style = this.Style; Style labelStyle = Control.LabelStyle; writer.EnterStyle(labelStyle); writer.WriteText(Control.AllFields[labelFieldIndex].Title, true); writer.ExitStyle(labelStyle, true); bool hasDefaultCommand = HasDefaultCommand(); bool onlyHasDefaultCommand = OnlyHasDefaultCommand(); bool requiresDetailsScreen = !onlyHasDefaultCommand && HasCommands(); // if there is > 1 visible field, need a details screen for (int visibleFields = 0, i = 0; !requiresDetailsScreen && i < count; i++) { visibleFields += allFields[i].Visible ? 1 : 0; requiresDetailsScreen = requiresDetailsScreen || visibleFields > 1; } bool itemRequiresHyperlink = requiresDetailsScreen || hasDefaultCommand; bool itemRequiresMoreButton = requiresDetailsScreen && hasDefaultCommand; Style subCommandStyle = Control.CommandStyle; subCommandStyle.Alignment = style.Alignment; subCommandStyle.Wrapping = style.Wrapping; writer.EnterStyle(style); for (int i = startIndex; i < nextStartIndex; i++) { ObjectListItem item = items[i]; if (itemRequiresHyperlink) { RenderPostBackEventAsAnchor(writer, hasDefaultCommand ? item.Index.ToString(CultureInfo.InvariantCulture) : String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index), item[labelFieldIndex]); } else { writer.WriteText(item[labelFieldIndex], true); } if (itemRequiresMoreButton) { BooleanOption cachedItalic = subCommandStyle.Font.Italic; subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterFormat(subCommandStyle); writer.Write(" ["); writer.ExitFormat(subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; writer.EnterFormat(subCommandStyle); String moreText = Control.MoreText.Length == 0 ? GetDefaultLabel(MoreLabel) : Control.MoreText; writer.WriteBeginTag("a"); RenderPostBackEventAsAttribute(writer, "href", String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index)); writer.Write(">"); writer.WriteText(moreText, true); writer.WriteEndTag("a"); writer.ExitFormat(subCommandStyle); subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterFormat(subCommandStyle); writer.Write("]"); writer.ExitFormat(subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; } if (i < (nextStartIndex - 1)) { writer.WriteBreak(); } } writer.ExitStyle(style, Control.BreakAfter); }
/// <include file='doc\ChtmlFormAdapter.uex' path='docs/doc[@for="ChtmlFormAdapter.RenderExtraHeadElements"]/*' /> protected override bool RenderExtraHeadElements(HtmlMobileTextWriter writer) { bool result = false; String metaTagName = Device.RequiredMetaTagNameValue; if (metaTagName != null) { if (writer != null) { writer.Write("<meta NAME=\"" + metaTagName + "\" CONTENT=\"True\">\r\n"); } result = true; } String charset = Page.Response.Charset; if (Device.RequiresContentTypeMetaTag && charset != null && charset.Length > 0) { if (writer != null) { writer.Write(String.Format(CultureInfo.InvariantCulture, _contentTypeMetaTag, Device.PreferredRenderingMime, charset)); } result = true; } return result; }
/// <include file='doc\ChtmlFormAdapter.uex' path='docs/doc[@for="ChtmlFormAdapter.RenderPagerTag"]/*' /> protected internal override void RenderPagerTag( HtmlMobileTextWriter writer, int pageToNavigate, String text) { writer.EnterLayout(Style); writer.EnterFormat(Style); writer.WriteBeginTag("input"); // Specially encode the page number with the control id. // The corresponding code that handles postback should know how // to extract the page number correctly. writer.Write(" name=\""); writer.Write(Control.UniqueID); writer.Write(Constants.PagePrefix); writer.Write(pageToNavigate.ToString(CultureInfo.InvariantCulture)); writer.Write("\""); writer.WriteAttribute("type", "submit"); writer.WriteAttribute("value", text, true); writer.Write("/>"); writer.ExitFormat(Style); writer.ExitLayout(Style); }
/// <include file='doc\HtmlCommandAdapter.uex' path='docs/doc[@for="HtmlCommandAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { bool renderLink = false; bool renderImage = false; // If image is defined and renderable, just do it. Otherwise, // render as a link if specified. if (!String.IsNullOrEmpty(Control.ImageUrl) && Device.SupportsImageSubmit) { renderImage = true; } else if (Control.Format == CommandFormat.Link && Device.JavaScript) { renderLink = true; } if (renderLink) { writer.EnterStyle(Style); Form form = Control.Form; if (form.Action.Length > 0) { writer.Write("<a href=\"javascript:document."); writer.Write(form.ClientID); writer.Write(".submit()\""); AddAttributes(writer); writer.Write(">"); writer.WriteText(Control.Text, true); writer.WriteEndTag("a"); } else { RenderBeginLink(writer, Constants.FormIDPrefix + form.UniqueID); writer.WriteText(Control.Text, true); RenderEndLink(writer); } writer.ExitStyle(Style, Control.BreakAfter); } else { writer.EnterLayout(Style); writer.WriteBeginTag("input"); writer.WriteAttribute("name", Control.UniqueID); if (renderImage) { writer.WriteAttribute("type", "image"); writer.WriteAttribute("src", Control.ResolveUrl(Control.ImageUrl), true); writer.WriteAttribute("alt", Control.Text, true); } else { writer.WriteAttribute("type", "submit"); writer.Write(" value=\""); writer.WriteText(Control.Text, true); writer.Write("\""); } AddAttributes(writer); writer.Write("/>"); writer.ExitLayout(Style, Control.BreakAfter); } }
private void RenderItemsListWithTableTags(HtmlMobileTextWriter writer) { int pageStart = Control.FirstVisibleItemIndex; int pageSize = Control.VisibleItemCount; ObjectListItemCollection items = Control.Items; // Determine how to render. bool shouldRenderAsTable = ShouldRenderAsTable(); bool hasDefaultCommand = HasDefaultCommand(); bool onlyHasDefaultCommand = OnlyHasDefaultCommand(); bool requiresDetailsScreen = HasItemDetails() || (!onlyHasDefaultCommand && HasCommands()); bool itemRequiresHyperlink = requiresDetailsScreen || hasDefaultCommand; bool itemRequiresMoreButton = requiresDetailsScreen && hasDefaultCommand; int fieldCount; int[] fieldIndices = new int[]{}; if (shouldRenderAsTable) { fieldIndices = Control.TableFieldIndices; } Debug.Assert(fieldIndices != null, "fieldIndices is null"); fieldCount = fieldIndices.Length; if(fieldCount == 0) { fieldIndices = new int[1]; fieldIndices[0] = Control.LabelFieldIndex; fieldCount = 1; } Style style = this.Style; Style subCommandStyle = Control.CommandStyle; Style labelStyle = Control.LabelStyle; Color foreColor = (Color)style[Style.ForeColorKey, true]; writer.BeginStyleContext(); writer.WriteLine("<table border=0 width=\"100%\">\r\n<tr>"); for (int field = 0; field < fieldCount; field++) { writer.Write("<td>"); writer.BeginStyleContext(); writer.EnterStyle(labelStyle); writer.WriteText(Control.AllFields[fieldIndices[field]].Title, true); writer.ExitStyle(labelStyle); writer.EndStyleContext(); writer.Write("</td>"); } if (itemRequiresMoreButton) { writer.WriteLine("<td/>"); } writer.WriteLine("\r\n</tr>"); RenderRule(writer, foreColor, fieldCount + 1); for (int i = 0; i < pageSize; i++) { ObjectListItem item = items[pageStart + i]; writer.WriteLine("<tr>"); for (int field = 0; field < fieldCount; field++) { writer.Write("<td>"); if (field == 0 && itemRequiresHyperlink) { writer.BeginStyleContext(); writer.EnterStyle(style); String eventArgument = hasDefaultCommand ? item.Index.ToString(CultureInfo.InvariantCulture) : String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index.ToString(CultureInfo.InvariantCulture)); RenderPostBackEventAsAnchor(writer, eventArgument, item[fieldIndices[0]]); writer.ExitStyle(style); writer.EndStyleContext(); } else { writer.BeginStyleContext(); writer.EnterStyle(style); writer.WriteText(item[fieldIndices[field]], true); writer.ExitStyle(style); writer.EndStyleContext(); } writer.WriteLine("</td>"); } if (itemRequiresMoreButton) { writer.Write("<td align=right>"); writer.BeginStyleContext(); writer.EnterFormat(subCommandStyle); String moreText = Control.MoreText.Length == 0 ? GetDefaultLabel(MoreLabel) : Control.MoreText; RenderPostBackEventAsAnchor(writer, String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index), moreText, subCommandStyle); writer.ExitFormat(subCommandStyle); writer.EndStyleContext(); writer.Write("</td>\r\n"); } writer.WriteLine("</tr>"); } RenderRule(writer, foreColor, fieldCount + 1); writer.Write("</table>\r\n"); writer.EndStyleContext(); }
private void RenderItemDetailsWithTableTags(HtmlMobileTextWriter writer, ObjectListItem item) { Style style = this.Style; Style labelStyle = Control.LabelStyle; Style subCommandStyle = Control.CommandStyle; Color foreColor = (Color)style[Style.ForeColorKey, true]; writer.Write("<table border=0 width=\"100%\">\r\n<tr><td colspan=2>"); writer.BeginStyleContext(); writer.EnterStyle(labelStyle); writer.WriteText(item[Control.LabelFieldIndex], true); writer.ExitStyle(labelStyle); writer.EndStyleContext(); writer.Write("</td></tr>\r\n<tr>"); RenderRule(writer, foreColor, 2); IObjectListFieldCollection fields = Control.AllFields; int fieldIndex = 0; foreach (ObjectListField field in fields) { if (field.Visible) { writer.Write("<tr><td>"); writer.BeginStyleContext(); writer.EnterStyle(Style); writer.WriteText(field.Title, true); writer.ExitStyle(Style); writer.EndStyleContext(); writer.Write("</td><td>"); writer.BeginStyleContext(); writer.EnterStyle(style); writer.WriteText(item[fieldIndex], true); writer.ExitStyle(style); writer.EndStyleContext(); writer.Write("</td></tr>\r\n"); } fieldIndex++; } RenderRule(writer, foreColor, 2); writer.Write("<tr><td colspan=2>"); writer.BeginStyleContext(); BooleanOption cachedItalic = subCommandStyle.Font.Italic; subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterStyle(subCommandStyle); writer.Write("[ "); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; writer.EnterStyle(subCommandStyle); ObjectListCommandCollection commands = Control.Commands; foreach (ObjectListCommand command in commands) { RenderPostBackEventAsAnchor(writer, command.Name, command.Text, subCommandStyle); writer.Write(" | "); } String backCommandText = Control.BackCommandText.Length == 0 ? GetDefaultLabel(BackLabel) : Control.BackCommandText; RenderPostBackEventAsAnchor(writer, BackToList, backCommandText, subCommandStyle); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterStyle(subCommandStyle); writer.Write(" ]"); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; writer.EndStyleContext(); writer.Write("</td></tr></table>"); }
private void RenderRule(HtmlMobileTextWriter writer, Color foreColor, int columnSpan) { writer.Write("<tr><td colspan="); writer.Write(columnSpan.ToString(CultureInfo.InvariantCulture)); writer.Write(" bgcolor=\""); writer.Write((foreColor != Color.Empty) ? ColorTranslator.ToHtml(foreColor) : "#000000"); writer.Write("\"></td></tr>"); }
/// <include file='doc\HtmlImageAdapter.uex' path='docs/doc[@for="HtmlImageAdapter.RenderImage"]/*' /> protected internal virtual void RenderImage(HtmlMobileTextWriter writer) { String source = Control.ImageUrl; writer.WriteBeginTag("img"); if (!String.IsNullOrEmpty(source)) { // AUI 3652 source = Control.ResolveUrl(source); writer.WriteAttribute("src", source, true /*encode*/); writer.AddResource(source); } if (!String.IsNullOrEmpty(Control.AlternateText)) { writer.WriteAttribute("alt", Control.AlternateText, true); } writer.WriteAttribute("border", "0"); writer.Write(" />"); }
/// <include file='doc\HtmlCalendarAdapter.uex' path='docs/doc[@for="HtmlCalendarAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { System.Web.UI.WebControls.WebControl webCalendar = Control.WebCalendar; Style.ApplyTo(webCalendar); // Delegate the rendering effort to the child Web Calendar // control for HTML browser webCalendar.Visible = true; // There is no explicit property for alignment on WebForms // Calendar, so we need some special code to set it. writer.EnterLayout(Style); writer.EnsureStyle(); Alignment align = (Alignment) Style[Style.AlignmentKey, true]; if (!Device.SupportsDivAlign) { webCalendar.Attributes["align"] = align.ToString(); } if (Device.SupportsCss) { // Target device supports CSS - simply delegate the rendering // to the underlying Web Calendar control webCalendar.RenderControl(writer); } else { // Insert bgcolor attributes in cells that correspond to selected dates StringWriter sw = new StringWriter(CultureInfo.InvariantCulture); HtmlTextWriter tmpWriter = new HtmlTextWriter(sw); webCalendar.RenderControl(tmpWriter); String webCalendarHtml = sw.ToString(); int index = 0, indexLastTable = 0; // Search for offset of last <table> tag in the Web Calendar HTML. // That table contains the various days. do { index = webCalendarHtml.IndexOf(_selectedDateSearchTableTag, index, StringComparison.Ordinal); if (index >= 0) { indexLastTable = index; index += 5; } } while (index >= 0); index = LocateNextSelectedDate(webCalendarHtml, indexLastTable); if (index >= 0) { // Determine the background color of the containing Form control HtmlControlAdapter formAdapter = (HtmlControlAdapter) Control.Form.Adapter; Color backColor = (Color)formAdapter.Style[Style.BackColorKey, true]; int deltaR = System.Math.Abs(backColor.R - 0xC0); int deltaG = System.Math.Abs(backColor.G - 0xC0); int deltaB = System.Math.Abs(backColor.B - 0xC0); // Determine the distance between Silver and the Form's background color int bgColorDistance = deltaR * deltaR + deltaG * deltaG + deltaB * deltaB; // Choose Silver or White depending on that distance String selectedDateBGColor = String.Format(CultureInfo.CurrentCulture, "bgcolor=\"{0}\" ", bgColorDistance < _bgColorDistanceTreshold ? "White" : "Silver"); while (index >= 0) { // Insert the bgcolor attribute for each selected date cell webCalendarHtml = webCalendarHtml.Insert(index + _bgColorInsertionPointInPattern, selectedDateBGColor); index = LocateNextSelectedDate(webCalendarHtml, index + _bgColorInsertionPointInPattern); } } // Use the HTML after insertions writer.Write(webCalendarHtml); } if(Control.BreakAfter) { writer.WriteBreak(); } writer.ExitLayout(Style); }
private void RenderItemsListWithTableTags(HtmlMobileTextWriter writer) { int pageStart = Control.FirstVisibleItemIndex; int pageSize = Control.VisibleItemCount; ObjectListItemCollection items = Control.Items; // Determine how to render. bool shouldRenderAsTable = ShouldRenderAsTable(); bool hasDefaultCommand = HasDefaultCommand(); bool onlyHasDefaultCommand = OnlyHasDefaultCommand(); bool requiresDetailsScreen = HasItemDetails() || (!onlyHasDefaultCommand && HasCommands()); bool itemRequiresHyperlink = requiresDetailsScreen || hasDefaultCommand; bool itemRequiresMoreButton = requiresDetailsScreen && hasDefaultCommand; int fieldCount; int[] fieldIndices = new int[] {}; if (shouldRenderAsTable) { fieldIndices = Control.TableFieldIndices; } Debug.Assert(fieldIndices != null, "fieldIndices is null"); fieldCount = fieldIndices.Length; if (fieldCount == 0) { fieldIndices = new int[1]; fieldIndices[0] = Control.LabelFieldIndex; fieldCount = 1; } Style style = this.Style; Style subCommandStyle = Control.CommandStyle; Style labelStyle = Control.LabelStyle; Color foreColor = (Color)style[Style.ForeColorKey, true]; writer.BeginStyleContext(); writer.WriteLine("<table border=0 width=\"100%\">\r\n<tr>"); for (int field = 0; field < fieldCount; field++) { writer.Write("<td>"); writer.BeginStyleContext(); writer.EnterStyle(labelStyle); writer.WriteText(Control.AllFields[fieldIndices[field]].Title, true); writer.ExitStyle(labelStyle); writer.EndStyleContext(); writer.Write("</td>"); } if (itemRequiresMoreButton) { writer.WriteLine("<td/>"); } writer.WriteLine("\r\n</tr>"); RenderRule(writer, foreColor, fieldCount + 1); for (int i = 0; i < pageSize; i++) { ObjectListItem item = items[pageStart + i]; writer.WriteLine("<tr>"); for (int field = 0; field < fieldCount; field++) { writer.Write("<td>"); if (field == 0 && itemRequiresHyperlink) { writer.BeginStyleContext(); writer.EnterStyle(style); String eventArgument = hasDefaultCommand ? item.Index.ToString(CultureInfo.InvariantCulture) : String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index.ToString(CultureInfo.InvariantCulture)); RenderPostBackEventAsAnchor(writer, eventArgument, item[fieldIndices[0]]); writer.ExitStyle(style); writer.EndStyleContext(); } else { writer.BeginStyleContext(); writer.EnterStyle(style); writer.WriteText(item[fieldIndices[field]], true); writer.ExitStyle(style); writer.EndStyleContext(); } writer.WriteLine("</td>"); } if (itemRequiresMoreButton) { writer.Write("<td align=right>"); writer.BeginStyleContext(); writer.EnterFormat(subCommandStyle); String moreText = Control.MoreText.Length == 0 ? GetDefaultLabel(MoreLabel) : Control.MoreText; RenderPostBackEventAsAnchor(writer, String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index), moreText, subCommandStyle); writer.ExitFormat(subCommandStyle); writer.EndStyleContext(); writer.Write("</td>\r\n"); } writer.WriteLine("</tr>"); } RenderRule(writer, foreColor, fieldCount + 1); writer.Write("</table>\r\n"); writer.EndStyleContext(); }
/// <include file='doc\HtmlListAdapter.uex' path='docs/doc[@for="HtmlListAdapter.RenderList"]/*' /> protected virtual void RenderList(HtmlMobileTextWriter writer) { MobileListItemCollection items = Control.Items; Wrapping wrap = Style.Wrapping; // used for tables, no decoration case. if (items.Count == 0) { return; } int pageStart = Control.FirstVisibleItemIndex; int pageSize = Control.VisibleItemCount; // Determine what markup to use. String listSuffix, itemPrefix, itemSuffix; ListDecoration decoration = Control.Decoration; bool insideStyle = true; // We know that for table tag, outer style doesn't carry over // into inside tags so style state needs to be reset. // For other cases, we enter the style here once and exit at the // end once. if (decoration != ListDecoration.None || !Device.Tables) { writer.EnterStyle(Style); insideStyle = false; } switch (decoration) { case ListDecoration.Bulleted: writer.WriteLine("<ul>"); listSuffix = "</ul>"; itemPrefix = "<li>"; itemSuffix = "</li>"; if (!Device.RendersBreaksAfterHtmlLists) { listSuffix += "<br>"; } break; case ListDecoration.Numbered: if (pageStart == 0) { writer.WriteLine("<ol>"); } else { writer.Write("<ol start=\""); writer.Write(pageStart + 1); writer.WriteLine("\">"); } listSuffix = "</ol>"; itemPrefix = "<li>"; itemSuffix = "</li>"; if (!Device.RendersBreaksAfterHtmlLists) { listSuffix += "<br>"; } break; default: if (Device.Tables) { listSuffix = "</table>"; Style.Wrapping = Wrapping.NotSet; writer.EnterLayout(Style); writer.WriteLine("<table>"); if(wrap == Wrapping.NoWrap) { itemPrefix = "<tr nowrap><td>"; } else { itemPrefix = "<tr><td>"; } itemSuffix = "</td></tr>"; } else { listSuffix = String.Empty; itemPrefix = String.Empty; itemSuffix = "<br>"; } break; } bool hasCmdHandler = Control.HasItemCommandHandler; for (int i = 0; i < pageSize; i++) { MobileListItem item = items[pageStart + i]; writer.Write(itemPrefix); if(insideStyle) { writer.BeginStyleContext(); writer.EnterFormat(Style); } if(Control.ItemsAsLinks) { RenderBeginLink(writer, item.Value); } else if(hasCmdHandler) { writer.WriteBeginTag("a"); RenderPostBackEventAsAttribute(writer, "href", item.Index.ToString(CultureInfo.InvariantCulture)); writer.Write(">"); } writer.WriteEncodedText(item.Text); if (hasCmdHandler || Control.ItemsAsLinks) { RenderEndLink(writer); } if(insideStyle) { writer.ExitFormat(Style); writer.EndStyleContext(); } writer.WriteLine(itemSuffix); } if (listSuffix == null || listSuffix.Length > 0) { writer.WriteLine(listSuffix); } if (decoration != ListDecoration.None || !Device.Tables) { writer.ExitStyle(Style); } else { writer.ExitLayout(Style); Style.Wrapping = wrap; } }
private void RenderItemDetailsWithTableTags(HtmlMobileTextWriter writer, ObjectListItem item) { Style style = this.Style; Style labelStyle = Control.LabelStyle; Style subCommandStyle = Control.CommandStyle; Color foreColor = (Color)style[Style.ForeColorKey, true]; writer.Write("<table border=0 width=\"100%\">\r\n<tr><td colspan=2>"); writer.BeginStyleContext(); writer.EnterStyle(labelStyle); writer.WriteText(item[Control.LabelFieldIndex], true); writer.ExitStyle(labelStyle); writer.EndStyleContext(); writer.Write("</td></tr>\r\n<tr>"); RenderRule(writer, foreColor, 2); IObjectListFieldCollection fields = Control.AllFields; int fieldIndex = 0; foreach (ObjectListField field in fields) { if (field.Visible) { writer.Write("<tr><td>"); writer.BeginStyleContext(); writer.EnterStyle(Style); writer.WriteText(field.Title, true); writer.ExitStyle(Style); writer.EndStyleContext(); writer.Write("</td><td>"); writer.BeginStyleContext(); writer.EnterStyle(style); writer.WriteText(item[fieldIndex], true); writer.ExitStyle(style); writer.EndStyleContext(); writer.Write("</td></tr>\r\n"); } fieldIndex++; } RenderRule(writer, foreColor, 2); writer.Write("<tr><td colspan=2>"); writer.BeginStyleContext(); BooleanOption cachedItalic = subCommandStyle.Font.Italic; subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterStyle(subCommandStyle); writer.Write("[ "); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; writer.EnterStyle(subCommandStyle); ObjectListCommandCollection commands = Control.Commands; foreach (ObjectListCommand command in commands) { RenderPostBackEventAsAnchor(writer, command.Name, command.Text, subCommandStyle); writer.Write(" | "); } String backCommandText = Control.BackCommandText.Length == 0 ? GetDefaultLabel(BackLabel) : Control.BackCommandText; RenderPostBackEventAsAnchor(writer, BackToList, backCommandText, subCommandStyle); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterStyle(subCommandStyle); writer.Write(" ]"); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; writer.EndStyleContext(); writer.Write("</td></tr></table>"); }
/// <include file='doc\HtmlSelectionListAdapter.uex' path='docs/doc[@for="HtmlSelectionListAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { MobileListItemCollection items = Control.Items; ListSelectType selectType = Control.SelectType; if (items.Count == 0 && selectType != ListSelectType.ListBox && selectType != ListSelectType.MultiSelectListBox) { return; } int selectedIndex = Control.SelectedIndex; String renderName; if(Device.RequiresAttributeColonSubstitution) { renderName = Control.UniqueID.Replace(':', ','); } else { renderName = Control.UniqueID; } switch(selectType) { case ListSelectType.DropDown: case ListSelectType.ListBox: case ListSelectType.MultiSelectListBox: if (items.Count == 0 && !Device.CanRenderEmptySelects) { break; } writer.EnterLayout(Style); writer.WriteBeginTag("select"); if (selectType == ListSelectType.MultiSelectListBox) { writer.Write(" multiple"); } if (selectType == ListSelectType.ListBox || selectType == ListSelectType.MultiSelectListBox) { writer.WriteAttribute("size", Control.Rows.ToString(CultureInfo.InvariantCulture)); } writer.WriteAttribute("name", renderName); writer.Write(">"); for(int itemIndex = 0; itemIndex < items.Count; itemIndex++) { MobileListItem item = items[itemIndex]; writer.WriteBeginTag("option"); WriteItemValueAttribute(writer, itemIndex, item.Value); if (item.Selected && (Control.IsMultiSelect || itemIndex == selectedIndex)) { writer.Write(" selected>"); } else { writer.Write(">"); } writer.WriteEncodedText(item.Text); writer.WriteLine(""); } writer.Write("</select>"); if(Device.HidesRightAlignedMultiselectScrollbars && selectType == ListSelectType.MultiSelectListBox) { // nested if for perf if((Alignment)Style[Style.AlignmentKey, true] == Alignment.Right) { writer.Write(" "); } } writer.WriteLine(""); if (!Page.DesignMode) { writer.ExitLayout(Style, Control.BreakAfter); } else { writer.ExitLayout(Style, false); } break; case ListSelectType.Radio: case ListSelectType.CheckBox: String selectTypeString = (selectType == ListSelectType.Radio) ? "radio" : "checkbox"; Alignment alignment = (Alignment)Style[Style.AlignmentKey, true]; if(!Device.Tables || alignment == Alignment.Left || alignment == Alignment.NotSet) { writer.EnterStyle(Style); bool breakAfter = false; for(int itemIndex = 0; itemIndex < items.Count; itemIndex++) { if(breakAfter) { writer.WriteBreak(); } MobileListItem item = items[itemIndex]; writer.WriteBeginTag("input"); writer.WriteAttribute("type", selectTypeString); writer.WriteAttribute("name", renderName); WriteItemValueAttribute(writer, itemIndex, item.Value); if (item.Selected && (Control.IsMultiSelect || itemIndex == selectedIndex) && Device.SupportsUncheck) { writer.Write(" checked>"); } else { writer.Write(">"); } writer.WriteEncodedText(item.Text); breakAfter = true; } writer.ExitStyle(Style, Control.BreakAfter); } else // Device supports tables and alignment is non default. { Wrapping wrapping = (Wrapping) Style[Style.WrappingKey , true]; bool nowrap = (wrapping == Wrapping.NoWrap); writer.EnterLayout(Style); writer.WriteFullBeginTag("table"); writer.BeginStyleContext(); for(int itemIndex = 0; itemIndex < items.Count; itemIndex++) { MobileListItem item = items[itemIndex]; writer.WriteFullBeginTag("tr"); writer.WriteBeginTag("td"); if(nowrap) { writer.WriteAttribute("nowrap","true"); } writer.Write(">"); writer.WriteBeginTag("input"); writer.WriteAttribute("type", selectTypeString); writer.WriteAttribute("name", renderName); WriteItemValueAttribute(writer, itemIndex, item.Value); if (item.Selected && (Control.IsMultiSelect || itemIndex == selectedIndex) && Device.SupportsUncheck) { writer.Write(" checked>"); } else { writer.Write(">"); } writer.MarkStyleContext(); writer.EnterFormat(Style); writer.WriteEncodedText(item.Text); writer.ExitFormat(Style); writer.UnMarkStyleContext(); writer.WriteEndTag("td"); writer.WriteEndTag("tr"); } writer.WriteEndTag("table"); writer.EndStyleContext(); writer.ExitFormat(Style, Control.BreakAfter); } break; } }
private void RenderItemsListWithoutTableTags(HtmlMobileTextWriter writer) { int startIndex = Control.FirstVisibleItemIndex; int pageSize = Control.VisibleItemCount; ObjectListItemCollection items = Control.Items; IObjectListFieldCollection allFields = Control.AllFields; int count = allFields.Count; int nextStartIndex = startIndex + pageSize; int labelFieldIndex = Control.LabelFieldIndex; Style style = this.Style; Style labelStyle = Control.LabelStyle; writer.EnterStyle(labelStyle); writer.WriteText(Control.AllFields[labelFieldIndex].Title, true); writer.ExitStyle(labelStyle, true); bool hasDefaultCommand = HasDefaultCommand(); bool onlyHasDefaultCommand = OnlyHasDefaultCommand(); bool requiresDetailsScreen = !onlyHasDefaultCommand && HasCommands(); // if there is > 1 visible field, need a details screen for (int visibleFields = 0, i = 0; !requiresDetailsScreen && i < count; i++) { visibleFields += allFields[i].Visible ? 1 : 0; requiresDetailsScreen = requiresDetailsScreen || visibleFields > 1; } bool itemRequiresHyperlink = requiresDetailsScreen || hasDefaultCommand; bool itemRequiresMoreButton = requiresDetailsScreen && hasDefaultCommand; Style subCommandStyle = Control.CommandStyle; subCommandStyle.Alignment = style.Alignment; subCommandStyle.Wrapping = style.Wrapping; writer.EnterStyle(style); for (int i = startIndex; i < nextStartIndex; i++) { ObjectListItem item = items[i]; if (itemRequiresHyperlink) { RenderPostBackEventAsAnchor(writer, hasDefaultCommand ? item.Index.ToString(CultureInfo.InvariantCulture) : String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index), item[labelFieldIndex]); } else { writer.WriteText(item[labelFieldIndex], true); } if (itemRequiresMoreButton) { BooleanOption cachedItalic = subCommandStyle.Font.Italic; subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterFormat(subCommandStyle); writer.Write(" ["); writer.ExitFormat(subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; writer.EnterFormat(subCommandStyle); String moreText = Control.MoreText.Length == 0 ? GetDefaultLabel(MoreLabel) : Control.MoreText; writer.WriteBeginTag("a"); RenderPostBackEventAsAttribute(writer, "href", String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index)); writer.Write(">"); writer.WriteText(moreText, true); writer.WriteEndTag("a"); writer.ExitFormat(subCommandStyle); subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterFormat(subCommandStyle); writer.Write("]"); writer.ExitFormat(subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; } if(i < (nextStartIndex - 1)) { writer.WriteBreak(); } } writer.ExitStyle(style, Control.BreakAfter); }
private void RenderItemDetailsWithoutTableTags(HtmlMobileTextWriter writer, ObjectListItem item) { Style style = this.Style; Style labelStyle = Control.LabelStyle; Style subCommandStyle = Control.CommandStyle; writer.EnterStyle(labelStyle); writer.WriteText(item[Control.LabelFieldIndex], true); writer.ExitStyle(labelStyle, true); IObjectListFieldCollection fields = Control.AllFields; int fieldIndex = 0; bool boldInStyle = (style.Font.Bold == BooleanOption.True) ? true : false; writer.EnterStyle(style); foreach (ObjectListField field in fields) { if (field.Visible) { if (!boldInStyle) { writer.Write("<b>"); } writer.WriteText(field.Title + ":", true); if (!boldInStyle) { writer.Write("</b>"); } writer.Write(" "); writer.WriteText(item[fieldIndex], true); writer.WriteBreak(); } fieldIndex++; } writer.ExitStyle(style); BooleanOption cachedItalic = subCommandStyle.Font.Italic; subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterStyle(subCommandStyle); writer.Write("[ "); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; writer.EnterStyle(subCommandStyle); ObjectListCommandCollection commands = Control.Commands; foreach (ObjectListCommand command in commands) { RenderPostBackEventAsAnchor(writer, command.Name, command.Text, subCommandStyle); writer.Write(" | "); } String backCommandText = Control.BackCommandText.Length == 0 ? GetDefaultLabel(BackLabel) : Control.BackCommandText; RenderPostBackEventAsAnchor(writer, BackToList, backCommandText, subCommandStyle); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterStyle(subCommandStyle); writer.Write(" ]"); writer.ExitStyle(subCommandStyle, Control.BreakAfter); subCommandStyle.Font.Italic = cachedItalic; }