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(); }
/// <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); }
/// <include file='doc\HtmlImageAdapter.uex' path='docs/doc[@for="HtmlImageAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { String target = Control.NavigateUrl; writer.EnterLayout(Style); if (!String.IsNullOrEmpty(target)) { RenderBeginLink(writer, target); } if (String.IsNullOrEmpty(Control.ImageUrl)) { // Just write the alternate as text writer.EnsureStyle(); writer.MarkStyleContext(); writer.EnterFormat(Style); writer.WriteText(Control.AlternateText, true); writer.ExitFormat(Style); writer.UnMarkStyleContext(); } else { RenderImage(writer); } if (!String.IsNullOrEmpty(target)) { RenderEndLink(writer); } writer.ExitLayout(Style, Control.BreakAfter); }
/// <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\HtmlValidatorAdapter.uex' path='docs/doc[@for="HtmlValidatorAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { if (!Control.IsValid && Control.Display != ValidatorDisplay.None) { writer.EnterStyle(Style); if (!String.IsNullOrEmpty(Control.Text)) { writer.WriteText(Control.Text, true); } else if (!String.IsNullOrEmpty(Control.ErrorMessage)) { writer.WriteText(Control.ErrorMessage, true); } writer.ExitStyle(Style, Control.BreakAfter); } }
public override void Render(HtmlMobileTextWriter writer) { if (!Control.IsValid && Control.Display != ValidatorDisplay.None) { writer.EnterStyle(Style); if (Control.Text != String.Empty) { writer.WriteText(Control.Text, true); } else if (Control.ErrorMessage != String.Empty) { writer.WriteText(Control.ErrorMessage, true); } writer.ExitStyle(Style, Control.BreakAfter); } }
// calls the more specific render methods /// <include file='doc\HtmlLiteralTextAdapter.uex' path='docs/doc[@for="HtmlLiteralTextAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { String text = Control.PagedText; writer.EnterStyle(Style); writer.WriteText(text, true); writer.ExitStyle(Style, Control.BreakAfter); }
public override void Render(HtmlMobileTextWriter writer) { writer.EnterStyle(Style); RenderBeginLink(writer, Control.NavigateUrl); writer.WriteText((Control.Text == String.Empty) ? Control.NavigateUrl : Control.Text, true); RenderEndLink(writer); writer.ExitStyle(Style, Control.BreakAfter); }
/// <include file='doc\HtmlLinkAdapter.uex' path='docs/doc[@for="HtmlLinkAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { writer.EnterStyle(Style); String navigateUrl = Control.NavigateUrl; RenderBeginLink(writer, navigateUrl); writer.WriteText(String.IsNullOrEmpty(Control.Text) ? navigateUrl : Control.Text, true); RenderEndLink(writer); writer.ExitStyle(Style, Control.BreakAfter); }
private void RenderElement(HtmlMobileTextWriter writer, int index, int begin, int end) { TextViewElement element = Control.GetElement(index); if (end == -1) { end = element.Text.Length; } String text = element.Text; if (begin > 0 || end < text.Length) { text = text.Substring(begin, end - begin); } BooleanOption previousBold = Style.Font.Bold; BooleanOption previousItalic = Style.Font.Italic; if (element.IsBold) { Style.Font.Bold = BooleanOption.True; } if (element.IsItalic) { Style.Font.Italic = BooleanOption.True; } writer.EnterStyle(Style); if (element.Url != null) { RenderBeginLink(writer, element.Url); writer.WriteText(text, true); RenderEndLink(writer); } else { writer.WriteText(text, true); } writer.ExitStyle(Style, element.BreakAfter); Style.Font.Bold = previousBold; Style.Font.Italic = previousItalic; }
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); }
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); }
/// <include file='doc\HtmlLabelAdapter.uex' path='docs/doc[@for="HtmlLabelAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { writer.EnterStyle(Style); if( (writer.BeforeFirstControlWritten) && (Device.RequiresLeadingPageBreak) && (String.IsNullOrEmpty(Control.Text) || WhiteSpace(Control.Text) ) ) { writer.WriteBreak(); } else { writer.WriteText(Control.Text, true); } writer.ExitStyle(Style, Control.BreakAfter); }
public override void Render(HtmlMobileTextWriter writer) { writer.EnterStyle(Style); if ((writer.BeforeFirstControlWritten) && (Device.RequiresLeadingPageBreak) && ((Control.Text == String.Empty) || WhiteSpace(Control.Text))) { writer.WriteBreak(); } else { writer.WriteText(Control.Text, true); } writer.ExitStyle(Style, Control.BreakAfter); }
/// <include file='doc\HtmlValidationSummaryAdapter.uex' path='docs/doc[@for="HtmlValidationSummaryAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { String[] errorMessages = null; if (Control.Visible) { errorMessages = Control.GetErrorMessages(); } if (errorMessages != null) { writer.EnterStyle(Style); if (Control.HeaderText.Length > 0) { writer.WriteText(Control.HeaderText, true); } ArrayList arr = new ArrayList(); foreach (String errorMessage in errorMessages) { Debug.Assert(errorMessage != null && errorMessage.Length > 0, "Bad Error Messages"); arr.Add(errorMessage); } _list.Decoration = ListDecoration.Bulleted; _list.DataSource = arr; _list.DataBind(); if (String.Compare(Control.FormToValidate, Control.Form.UniqueID, StringComparison.OrdinalIgnoreCase) != 0) { _link.NavigateUrl = Constants.FormIDPrefix + Control.FormToValidate; _link.Text = String.IsNullOrEmpty(Control.BackLabel) ? GetDefaultLabel(BackLabel) : Control.BackLabel; // Summary writes its own break so last control should write one. _link.BreakAfter = false; } else { _link.Visible = false; // Summary writes its own break so last control should write one. _list.BreakAfter = false; } // Render the child controls to display error message list and a // link for going back to the Form that is having error RenderChildren(writer); writer.ExitStyle(Style, Control.BreakAfter); } }
public override void Render(HtmlMobileTextWriter writer) { String[] errorMessages = null; if (Control.Visible) { errorMessages = Control.GetErrorMessages(); } if (errorMessages != null) { writer.EnterStyle(Style); if (Control.HeaderText.Length > 0) { writer.WriteText(Control.HeaderText, true); } ArrayList arr = new ArrayList(); foreach (String errorMessage in errorMessages) { Debug.Assert(errorMessage != null && errorMessage.Length > 0, "Bad Error Messages"); arr.Add(errorMessage); } _list.Decoration = ListDecoration.Bulleted; _list.DataSource = arr; _list.DataBind(); if (String.Compare(Control.FormToValidate, Control.Form.UniqueID, true, CultureInfo.InvariantCulture) != 0) { _link.NavigateUrl = Constants.FormIDPrefix + Control.FormToValidate; _link.Text = Control.BackLabel == String.Empty? GetDefaultLabel(BackLabel) : Control.BackLabel; // Summary writes its own break so last control should write one. _link.BreakAfter = false; } else { _link.Visible = false; // Summary writes its own break so last control should write one. _list.BreakAfter = false; } // Render the child controls to display error message list and a // link for going back to the Form that is having error RenderChildren(writer); writer.ExitStyle(Style, Control.BreakAfter); } }
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"); }
public override void Render(HtmlMobileTextWriter writer) { // Invalid text writers are not supported in this Adapter. if (!(writer is DesignerTextWriter)) { return; } Alignment alignment = (Alignment)Style[Style.AlignmentKey, true]; byte templateStatus; int maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus); String width = DesignerAdapterUtil.GetWidth(Control); if (Control.ImageUrl.Length == 0) { if (Control.Format == CommandFormat.Button) { if (maxWidth == 0 && templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_NONEDIT) { maxWidth = DesignerAdapterUtil.CONTROL_MAX_WIDTH_IN_TEMPLATE; } if (maxWidth == 0 && DesignerAdapterUtil.InMobileUserControl(Control)) { maxWidth = Constants.ControlMaxsizeAtToplevel; } if (maxWidth == 0) { // Render will be called a second time for which maxWidth != 0 return; } String additionalStyle = null; String controlText = Control.Text; String commandCaption; int requiredWidth = 0; DesignerTextWriter twTmp; twTmp = new DesignerTextWriter(); twTmp.WriteBeginTag("input"); twTmp.WriteStyleAttribute(Style, null); twTmp.WriteAttribute("type", "submit"); twTmp.Write(" value=\""); twTmp.WriteText(controlText, true); twTmp.Write("\"/>"); String htmlFragment = twTmp.ToString(); MSHTMLHostUtil.ApplyStyle(String.Empty, String.Empty, null); requiredWidth = MSHTMLHostUtil.GetHtmlFragmentWidth(htmlFragment); ((DesignerTextWriter)writer).EnterZeroFontSizeTag(); writer.WriteBeginTag("div"); if (requiredWidth + SAFETY_MARGIN > maxWidth) { if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT) { int tmpRequiredWidth, allowedLength; int captionLength = controlText.Length; twTmp = new DesignerTextWriter(); twTmp.WriteBeginTag("input"); twTmp.WriteStyleAttribute(Style, null); twTmp.WriteAttribute("type", "submit"); twTmp.WriteAttribute("value", "{0}"); twTmp.Write("/>"); htmlFragment = twTmp.ToString(); // At least 10 characters can fit into the caption of the command for (allowedLength = (captionLength < 10 ? captionLength : 10); allowedLength <= captionLength; allowedLength++) { tmpRequiredWidth = MSHTMLHostUtil.GetHtmlFragmentWidth(String.Format(CultureInfo.CurrentCulture, htmlFragment, HttpUtility.HtmlEncode(controlText.Substring(0, allowedLength)))); if (tmpRequiredWidth + SAFETY_MARGIN > maxWidth) { break; } } commandCaption = controlText.Substring(0, allowedLength - 1); } else { commandCaption = controlText; } } else { writer.WriteAttribute("style", "width:" + width); commandCaption = controlText; } if (alignment != Alignment.NotSet) { writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); } writer.Write(">"); writer.EnterLayout(Style); writer.WriteBeginTag("input"); if (requiredWidth + SAFETY_MARGIN > maxWidth) { additionalStyle = String.Format(CultureInfo.CurrentCulture, "width:{0};", width); } ((DesignerTextWriter)writer).WriteStyleAttribute(Style, additionalStyle); writer.WriteAttribute("type", "submit"); writer.Write(" value=\""); writer.WriteText(commandCaption, true); writer.Write("\"/>"); writer.ExitLayout(Style); } else { Wrapping wrapping = (Wrapping)Style[Style.WrappingKey, true]; bool wrap = (wrapping == Wrapping.Wrap || wrapping == Wrapping.NotSet); ((DesignerTextWriter)writer).EnterZeroFontSizeTag(); writer.WriteBeginTag("div"); if (!wrap) { 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(); } else { if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT) { width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px"; } writer.WriteBeginTag("div"); if (alignment == Alignment.Center) { writer.WriteAttribute("align", "center"); } writer.WriteAttribute("style", "overflow-x:hidden;width:" + width); writer.Write(">"); writer.WriteBeginTag("img"); ((DesignerTextWriter)writer).WriteStyleAttribute(Style); writer.WriteAttribute("src", Control.ImageUrl, true); // 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\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); } }
/// <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); }
// 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 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 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); }
public override void Render(HtmlMobileTextWriter writer) { // Invalid text writers are not supported in this Adapter. if (!(writer is DesignerTextWriter)) { return; } byte templateStatus; bool pwd = Control.Password; int size = Control.Size; int fittingSize; int maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus); if (maxWidth == 0) { if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_NONEDIT) { maxWidth = DesignerAdapterUtil.CONTROL_MAX_WIDTH_IN_TEMPLATE; } else if (DesignerAdapterUtil.InMobileUserControl(Control)) { maxWidth = Constants.ControlMaxsizeAtToplevel; } } if (maxWidth == 0) { return; } bool restoreEmptyFontName = false; if ((String)Style[Style.FontNameKey, true] == String.Empty) { // MSHTMLHostUtil is using another font by default. // Setting the font name to the one that is actually // used by default for the desig-time rendering // assures that the requiredWidth returned by // MSHTMLHostUtil.GetHtmlFragmentWidth is accurate. Style[Style.FontNameKey] = "Arial"; restoreEmptyFontName = true; } int requiredWidth = 0; DesignerTextWriter tw; tw = new DesignerTextWriter(false); tw.EnterLayout(Style); String enterLayout = tw.ToString(); tw = new DesignerTextWriter(false); tw.ExitLayout(Style); String exitLayout = tw.ToString(); tw = new DesignerTextWriter(false); tw.WriteBeginTag("input"); tw.WriteStyleAttribute(Style, null); if (size > 0) { tw.WriteAttribute("size", "{0}"); } tw.Write("/>"); String htmlFragment = tw.ToString(); MSHTMLHostUtil.ApplyStyle(enterLayout, exitLayout, null); if (size < LARGESIZE_THRESHOLD) { requiredWidth = MSHTMLHostUtil.GetHtmlFragmentWidth(size > 0 ? String.Format(htmlFragment, size.ToString()) : htmlFragment); } if (requiredWidth + SAFETY_MARGIN > maxWidth || size >= LARGESIZE_THRESHOLD) { if (size == 0) { tw = new DesignerTextWriter(false); tw.WriteBeginTag("input"); tw.WriteStyleAttribute(Style, null); tw.WriteAttribute("size", "{0}"); tw.Write("/>"); htmlFragment = tw.ToString(); } fittingSize = 0; do { fittingSize++; requiredWidth = MSHTMLHostUtil.GetHtmlFragmentWidth(String.Format(htmlFragment, fittingSize.ToString())); }while (requiredWidth + SAFETY_MARGIN <= maxWidth); if (fittingSize > 1) { fittingSize--; } } else { fittingSize = size; } if (restoreEmptyFontName) { Style[Style.FontNameKey] = String.Empty; } Alignment alignment = (Alignment)Style[Style.AlignmentKey, true]; String width = DesignerAdapterUtil.GetWidth(Control); writer.Write("<div style='width:" + width); if (alignment != Alignment.NotSet) { writer.Write(";text-align:" + Enum.GetName(typeof(Alignment), alignment)); } writer.Write("'>"); ((DesignerTextWriter)writer).EnterZeroFontSizeTag(); writer.EnterLayout(Style); writer.WriteBeginTag("input"); ((DesignerTextWriter)writer).WriteStyleAttribute(Style, null); if (Control.Text != String.Empty) { writer.Write(" value=\""); writer.WriteText(Control.Text, true); writer.Write("\" "); } if (fittingSize > 0) { writer.WriteAttribute("size", fittingSize.ToString()); } if (pwd) { writer.WriteAttribute("type", "password"); } writer.Write("/>"); writer.ExitLayout(Style); ((DesignerTextWriter)writer).ExitZeroFontSizeTag(); writer.Write("</div>"); }
//********************************************************************* // // 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 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\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); } }
private void RenderItemDetailsWithTableTags(HtmlMobileTextWriter writer, ObjectListItem item) { Style style1 = base.Style; Style style2 = Control.LabelStyle; Style style3 = Control.CommandStyle; Color color = (Color)style1[Style.ForeColorKey, true]; writer.Write("<table border=0 width=\"100%\">\r\n<tr><td colspan=2>"); writer.BeginStyleContext(); writer.EnterStyle(style2); writer.WriteText(item[Control.LabelFieldIndex], true); writer.ExitStyle(style2); writer.EndStyleContext(); writer.Write("</td></tr>\r\n<tr>"); RenderRule(writer, color, 2); IObjectListFieldCollection iObjectListFieldCollection = Control.AllFields; int i = 0; IEnumerator iEnumerator = iObjectListFieldCollection.GetEnumerator(); while (iEnumerator.MoveNext()) { ObjectListField objectListField = (ObjectListField)iEnumerator.Current; if (objectListField.Visible) { writer.Write("<tr><td>"); writer.BeginStyleContext(); writer.EnterStyle(base.Style); writer.WriteText(objectListField.Title, true); writer.ExitStyle(base.Style); writer.EndStyleContext(); writer.Write("</td><td>"); writer.BeginStyleContext(); writer.EnterStyle(style1); if (objectListField.Name == "CALL") { writer.WriteText(HtmlcheckPhonenumber(item[i]), false); } else if (objectListField.Name == "MAIL") { writer.WriteText(HtmlMail(item[i]), false); } else { writer.WriteText(item[i], false); } writer.ExitStyle(style1); writer.EndStyleContext(); writer.Write("</td></tr>\r\n"); } i++; } RenderRule(writer, color, 2); writer.Write("<tr><td colspan=2>"); writer.BeginStyleContext(); BooleanOption booleanOption = style3.Font.Italic; style3.Font.Italic = BooleanOption.False; writer.EnterStyle(style3); writer.Write("[ "); writer.ExitStyle(style3); style3.Font.Italic = booleanOption; writer.EnterStyle(style3); iEnumerator = Control.Commands.GetEnumerator(); while (iEnumerator.MoveNext()) { ObjectListCommand objectListCommand = (ObjectListCommand)iEnumerator.Current; RenderPostBackEventAsAnchor(writer, objectListCommand.Name, objectListCommand.Text, style3); writer.Write(" | "); } string str = (Control.BackCommandText != String.Empty) ? Control.BackCommandText : base.GetDefaultLabel(ControlAdapter.BackLabel); RenderPostBackEventAsAnchor(writer, BackToList, str, style3); writer.ExitStyle(style3); style3.Font.Italic = BooleanOption.False; writer.EnterStyle(style3); writer.Write(" ]"); writer.ExitStyle(style3); style3.Font.Italic = booleanOption; writer.EndStyleContext(); writer.Write("</td></tr></table>"); }
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 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 RenderItemDetailsWithoutTableTags(HtmlMobileTextWriter writer, ObjectListItem item) { Style style1 = base.Style; Style style2 = Control.LabelStyle; Style style3 = Control.CommandStyle; writer.EnterStyle(style2); writer.WriteText(item[Control.LabelFieldIndex], true); writer.ExitStyle(style2, true); IObjectListFieldCollection iObjectListFieldCollection = Control.AllFields; int i = 0; bool flag = style1.Font.Bold == BooleanOption.True; writer.EnterStyle(style1); IEnumerator iEnumerator = iObjectListFieldCollection.GetEnumerator(); while (iEnumerator.MoveNext()) { ObjectListField objectListField = (ObjectListField)iEnumerator.Current; if (objectListField.Visible) { if (!flag) { writer.Write("<b>"); } writer.WriteText(String.Concat(objectListField.Title, ":"), true); if (!flag) { writer.Write("</b>"); } writer.Write(" "); if (objectListField.Name == "CALL") { writer.WriteText(HtmlcheckPhonenumber(item[i]), true); } else if (objectListField.Name == "MAIL") { writer.WriteText(HtmlMail(item[i]), true); } else { writer.WriteText(item[i], true); } writer.WriteBreak(); } i++; } writer.ExitStyle(style1); BooleanOption booleanOption = style3.Font.Italic; style3.Font.Italic = BooleanOption.False; writer.EnterStyle(style3); writer.Write("[ "); writer.ExitStyle(style3); style3.Font.Italic = booleanOption; writer.EnterStyle(style3); iEnumerator = Control.Commands.GetEnumerator(); while (iEnumerator.MoveNext()) { ObjectListCommand objectListCommand = (ObjectListCommand)iEnumerator.Current; RenderPostBackEventAsAnchor(writer, objectListCommand.Name, objectListCommand.Text, style3); writer.Write(" | "); } string str = (Control.BackCommandText != String.Empty) ? Control.BackCommandText : base.GetDefaultLabel(ControlAdapter.BackLabel); RenderPostBackEventAsAnchor(writer, BackToList, str, style3); writer.ExitStyle(style3); style3.Font.Italic = BooleanOption.False; writer.EnterStyle(style3); writer.Write(" ]"); writer.ExitStyle(style3, Control.BreakAfter); style3.Font.Italic = booleanOption; }