public unsafe override void Render(HtmlMobileTextWriter writer) { Alignment alignment = *((Alignment*) base.get_Style().get_Item(Style.AlignmentKey, true)); string str = "100%"; writer.WriteBeginTag("div"); if (alignment == 2) { writer.WriteAttribute("align", "center"); } writer.WriteAttribute("style", "overflow-x:hidden;width:" + str); writer.Write(">"); string str2 = base.get_Control().get_ImageUrl(); writer.WriteBeginTag("img"); Utils.WriteStyleAttribute(writer, base.get_Style(), null); if (str2 != "") { writer.WriteAttribute("src", str2, true); } if (base.get_Control().get_AlternateText() != "") { writer.Write(" alt=\""); writer.WriteText(base.get_Control().get_AlternateText(), true); writer.Write("\""); } if ((alignment == 3) || (alignment == 1)) { writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); } writer.WriteAttribute("border", "0"); writer.Write(">"); writer.WriteEndTag("div"); }
internal static unsafe void WriteDesignerStyleAttributes(HtmlMobileTextWriter writer, MobileControl control, Style style) { Alignment alignment = *((Alignment*) style.get_Item(Style.AlignmentKey, true)); Wrapping wrapping = *((Wrapping*) style.get_Item(Style.WrappingKey, true)); Color c = (Color) style.get_Item(Style.BackColorKey, true); bool flag = alignment != 0; bool flag2 = (wrapping == 1) || (wrapping == 0); string str = "100%"; if (!flag2) { writer.Write(" style=\"overflow-x:hidden;width:" + str); } else { writer.Write(" style=\"word-wrap:break-word;overflow-x:hidden;width:" + str); } if (c != Color.Empty) { writer.Write(";background-color:" + ColorTranslator.ToHtml(c)); } if (flag) { writer.Write(";text-align:" + Enum.GetName(typeof(Alignment), alignment)); } }
public unsafe override void Render(HtmlMobileTextWriter writer) { Alignment alignment = *((Alignment*) base.get_Style().get_Item(Style.AlignmentKey, true)); Wrapping wrapping = *((Wrapping*) base.get_Style().get_Item(Style.WrappingKey, true)); bool flag = (wrapping == 1) || (wrapping == 0); Utils.EnterZeroFontSizeTag(writer); writer.WriteBeginTag("div"); string str = "100%"; if (!flag) { writer.WriteAttribute("style", "overflow-x:hidden;width:" + str); } else { writer.WriteAttribute("style", "word-wrap:break-word;width:" + str); } if (alignment != null) { writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); } writer.Write(">"); writer.WriteBeginTag("a"); writer.WriteAttribute("href", "NavigationUrl"); writer.Write(">"); Utils.WriteCssStyleText(writer, base.get_Style(), null, base.get_Control().get_Text(), true); writer.WriteEndTag("a"); writer.WriteEndTag("div"); Utils.ExitZeroFontSizeTag(writer); }
public unsafe override void Render(HtmlMobileTextWriter writer) { Alignment alignment = *((Alignment*) base.get_Style().get_Item(Style.AlignmentKey, true)); string str = "100%"; writer.WriteBeginTag("div"); if (alignment == 2) { writer.WriteAttribute("align", "center"); } writer.WriteAttribute("style", "padding=2px;overflow-x:hidden;width:" + str); writer.Write(">"); Utils.EnterZeroFontSizeTag(writer); writer.WriteBeginTag("img"); writer.WriteAttribute("alt", base.get_Control().ID); Utils.WriteStyleAttribute(writer, base.get_Style(), null); if ((alignment == 3) || (alignment == 1)) { writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); } writer.WriteAttribute("height", "40"); writer.WriteAttribute("width", "250"); writer.WriteAttribute("border", "0"); writer.Write(">"); Utils.ExitZeroFontSizeTag(writer); writer.WriteEndTag("div"); }
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\HtmlControlAdapter.uex' path='docs/doc[@for="HtmlControlAdapter.RenderPostBackEventAsAttribute"]/*' /> protected void RenderPostBackEventAsAttribute( HtmlMobileTextWriter writer, String attributeName, String argument) { writer.Write(" "); writer.Write(attributeName); writer.Write("=\""); RenderPostBackEventReference(writer, argument); writer.Write("\" "); }
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(CultureInfo.InvariantCulture) + "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 (!String.IsNullOrEmpty(source)) { writer.WriteAttribute("src", source, true); } if (!String.IsNullOrEmpty(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) { writer.WriteBeginTag("div"); Utils.WriteDesignerStyleAttributes(writer, base.get_Control(), base.get_Style()); writer.Write("\">"); base.Render(writer); writer.WriteEndTag("div"); }
/// <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); } }
public unsafe override void Render(HtmlMobileTextWriter writer) { bool flag = base.get_Control().get_Password(); int num = base.get_Control().get_Size(); Alignment alignment = *((Alignment*) base.get_Style().get_Item(Style.AlignmentKey, true)); writer.Write("<div style='width:" + "100%"); if (alignment != null) { writer.Write(";text-align:" + Enum.GetName(typeof(Alignment), alignment)); } writer.Write("'>"); Utils.EnterZeroFontSizeTag(writer); writer.EnterLayout(base.get_Style()); writer.WriteBeginTag("input"); Utils.WriteStyleAttribute(writer, base.get_Style(), null); if (base.get_Control().get_Text() != string.Empty) { writer.Write(" value=\""); writer.WriteText(base.get_Control().get_Text(), true); writer.Write("\" "); } writer.WriteAttribute("size", num.ToString()); if (flag) { writer.WriteAttribute("type", "password"); } writer.Write("/>"); writer.ExitLayout(base.get_Style()); Utils.ExitZeroFontSizeTag(writer); writer.Write("</div>"); }
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(CultureInfo.InvariantCulture) + "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 unsafe override void Render(HtmlMobileTextWriter writer) { string str; Alignment alignment = *((Alignment*) base.get_Style().get_Item(Style.AlignmentKey, true)); Wrapping wrapping = *((Wrapping*) base.get_Style().get_Item(Style.WrappingKey, true)); bool flag = (wrapping == 1) || (wrapping == 0); string str2 = "100%"; Utils.EnterZeroFontSizeTag(writer); writer.EnterLayout(base.get_Style()); writer.WriteBeginTag("div"); if (!flag) { str = "overflow-x:hidden;width:" + str2 + ";"; } else { str = "word-wrap:break-word;width:" + str2 + ";"; } Utils.WriteStyleAttribute(writer, base.get_Style(), str); if (alignment != null) { writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); } writer.Write(">"); writer.WriteText(base.get_Control().get_HeaderText(), true); writer.WriteFullBeginTag("ul"); for (int i = 1; i <= 2; i++) { writer.WriteFullBeginTag("li"); writer.Write(Constants.ValidationSummaryErrorMessage, i.ToString()); writer.WriteEndTag("li"); } writer.WriteEndTag("ul"); writer.WriteBeginTag("a"); writer.WriteAttribute("href", "NavigationUrl"); writer.Write(">"); writer.WriteText((base.get_Control().get_BackLabel() == string.Empty) ? base.GetDefaultLabel(ControlAdapter.BackLabel) : base.get_Control().get_BackLabel(), true); writer.WriteEndTag("a"); writer.WriteEndTag("div"); writer.ExitLayout(base.get_Style()); Utils.ExitZeroFontSizeTag(writer); }
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(); }
public unsafe override void Render(HtmlMobileTextWriter writer) { writer.WriteBeginTag("div"); writer.WriteAttribute("style", "cellpadding=2px;width:" + "100%"); Alignment alignment = *((Alignment*) base.get_Style().get_Item(Style.AlignmentKey, true)); if (alignment != null) { writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); } writer.Write("/>"); Utils.EnterZeroFontSizeTag(writer); Utils.ApplyStyleToWebControl(base.get_Style(), base.get_Control().get_WebCalendar()); base.Render(writer); Utils.ExitZeroFontSizeTag(writer); 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); 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(); }
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) { // 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.IsNullOrEmpty((String) Style[Style.FontNameKey, true])) { // 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(CultureInfo.InvariantCulture, htmlFragment, size) : 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(CultureInfo.InvariantCulture, htmlFragment, fittingSize)); } 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 (!String.IsNullOrEmpty(Control.Text)) { writer.Write(" value=\""); writer.WriteText(Control.Text, true); writer.Write("\" "); } if (fittingSize > 0) { writer.WriteAttribute("size", fittingSize.ToString(CultureInfo.InvariantCulture)); } if (pwd) { writer.WriteAttribute("type", "password"); } writer.Write("/>"); writer.ExitLayout(Style); ((DesignerTextWriter)writer).ExitZeroFontSizeTag(); writer.Write("</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\ChtmlCalendarAdapter.uex' path='docs/doc[@for="ChtmlCalendarAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { ArrayList arr; DateTime tempDate; DateTimeFormatInfo currentDateTimeInfo = DateTimeFormatInfo.CurrentInfo; String abbreviatedMonthDayPattern = AbbreviateMonthPattern(currentDateTimeInfo.MonthDayPattern); _threadCalendar = currentDateTimeInfo.Calendar; bool breakAfter = false; writer.EnterStyle(Style); Debug.Assert(NotSecondaryUI == NotSecondaryUIInit); switch (SecondaryUIMode) { case FirstPrompt: String promptText = Control.CalendarEntryText; if (String.IsNullOrEmpty(promptText)) { promptText = SR.GetString(SR.CalendarAdapterFirstPrompt); } // Link to input option selection screen RenderPostBackEventAsAnchor(writer, OptionPrompt.ToString(CultureInfo.InvariantCulture), promptText); // We should honor BreakAfter property here as the first // UI is shown with other controls on the same form. // For other secondary UI, it is not necessary. if (Control.BreakAfter) { breakAfter = true; } break; // Render the first secondary page that provides differnt // options to select a date. case OptionPrompt: writer.Write(SR.GetString(SR.CalendarAdapterOptionPrompt)); writer.WriteBreak(); arr = new ArrayList(); // Option to select the default date arr.Add(Control.VisibleDate.ToString( currentDateTimeInfo.ShortDatePattern, CultureInfo.CurrentCulture)); // Option to another page that can enter a date by typing arr.Add(SR.GetString(SR.CalendarAdapterOptionType)); // Options to a set of pages for selecting a date, a week // or a month by picking month/year, week and day // accordingly. Available options are determined by // SelectionMode. arr.Add(SR.GetString(SR.CalendarAdapterOptionChooseDate)); if (Control.SelectionMode == CalendarSelectionMode.DayWeek || Control.SelectionMode == CalendarSelectionMode.DayWeekMonth) { arr.Add(SR.GetString(SR.CalendarAdapterOptionChooseWeek)); if (Control.SelectionMode == CalendarSelectionMode.DayWeekMonth) { arr.Add(SR.GetString(SR.CalendarAdapterOptionChooseMonth)); } } DataBindAndRender(writer, _optionList, arr); break; // Render a title and textbox to capture a date entered by user case TypeDate: if (_textBoxErrorMessage != null) { writer.Write(_textBoxErrorMessage); writer.WriteBreak(); } if (_selectList.Visible) { writer.Write(SR.GetString(SR.CalendarAdapterOptionEra)); writer.WriteBreak(); _selectList.RenderControl(writer); } String numericDateFormat = GetNumericDateFormat(); writer.Write(SR.GetString(SR.CalendarAdapterOptionType)); writer.Write(":"); writer.WriteBreak(); writer.Write("("); writer.Write(numericDateFormat.ToUpper(CultureInfo.InvariantCulture)); writer.Write(")"); if (!_selectList.Visible) { writer.Write(GetEra(Control.VisibleDate)); } writer.WriteBreak(); _textBox.Numeric = true; _textBox.Size = numericDateFormat.Length; _textBox.MaxLength = numericDateFormat.Length; _textBox.Text = Control.VisibleDate.ToString(numericDateFormat, CultureInfo.InvariantCulture); _textBox.Visible = true; _textBox.RenderControl(writer); // Command button for sending the textbox value back to the server _command.Text = GetDefaultLabel(OKLabel); _command.Visible = true; _command.RenderControl(writer); break; // Render a paged list for choosing a month case ChooseMonth: writer.Write(SR.GetString(SR.CalendarAdapterOptionChooseMonth)); writer.Write(":"); writer.WriteBreak(); tempDate = Control.VisibleDate; String abbreviatedYearMonthPattern = AbbreviateMonthPattern(currentDateTimeInfo.YearMonthPattern); // This is to be consistent with ASP.NET Calendar control // on handling YearMonthPattern: // Some cultures have a comma in their YearMonthPattern, // which does not look right in a calendar. Here we // strip the comma off. int indexComma = abbreviatedYearMonthPattern.IndexOf(','); if (indexComma >= 0) { abbreviatedYearMonthPattern = abbreviatedYearMonthPattern.Remove(indexComma, 1); } arr = new ArrayList(); for (int i = 0; i < _monthsToDisplay; i++) { arr.Add(tempDate.ToString(abbreviatedYearMonthPattern, CultureInfo.CurrentCulture)); tempDate = _threadCalendar.AddMonths(tempDate, 1); } arr.Add(GetDefaultLabel(NextLabel)); arr.Add(GetDefaultLabel(PreviousLabel)); DataBindAndRender(writer, _monthList, arr); break; // Based on the month selected in case ChooseMonth above, render a list of // availabe weeks of the month. case ChooseWeek: String monthFormat = (GetNumericDateFormat()[0] == 'y') ? "yyyy/M" : "M/yyyy"; writer.Write(SR.GetString(SR.CalendarAdapterOptionChooseWeek)); writer.Write(" ("); writer.Write(Control.VisibleDate.ToString(monthFormat, CultureInfo.CurrentCulture)); writer.Write("):"); writer.WriteBreak(); // List weeks of days of the selected month. May include // days from the previous and the next month to fill out // all six week choices. This is consistent with the // ASP.NET Calendar control. // Note that the event handling code of this list control // should be implemented according to the index content // generated here. tempDate = FirstCalendarDay(Control.VisibleDate); arr = new ArrayList(); String weekDisplay; for (int i = 0; i < 6; i++) { weekDisplay = tempDate.ToString(abbreviatedMonthDayPattern, CultureInfo.CurrentCulture); weekDisplay += DaySeparator; tempDate = _threadCalendar.AddDays(tempDate, 6); weekDisplay += tempDate.ToString(abbreviatedMonthDayPattern, CultureInfo.CurrentCulture); arr.Add(weekDisplay); tempDate = _threadCalendar.AddDays(tempDate, 1); } DataBindAndRender(writer, _weekList, arr); break; // Based on the month and week selected in case ChooseMonth and ChooseWeek above, // render a list of the dates in the week. case ChooseDay: writer.Write(SR.GetString(SR.CalendarAdapterOptionChooseDate)); writer.Write(":"); writer.WriteBreak(); tempDate = Control.VisibleDate; arr = new ArrayList(); String date; String dayName; StringBuilder dayDisplay = new StringBuilder(); bool dayNameFirst = (GetNumericDateFormat()[0] != 'y'); for (int i = 0; i < 7; i++) { date = tempDate.ToString(abbreviatedMonthDayPattern, CultureInfo.CurrentCulture); if (Control.ShowDayHeader) { // Use the short format for displaying day name dayName = GetAbbreviatedDayName(tempDate); dayDisplay.Length = 0; if (dayNameFirst) { dayDisplay.Append(dayName); dayDisplay.Append(Space); dayDisplay.Append(date); } else { dayDisplay.Append(date); dayDisplay.Append(Space); dayDisplay.Append(dayName); } arr.Add(dayDisplay.ToString()); } else { arr.Add(date); } tempDate = _threadCalendar.AddDays(tempDate, 1); } DataBindAndRender(writer, _dayList, arr); break; default: Debug.Assert(false, "Unexpected Secondary UI Mode"); break; } writer.ExitStyle(Style, breakAfter); }
// 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 unsafe override void Render(HtmlMobileTextWriter writer) { Alignment alignment = *((Alignment*) base.get_Style().get_Item(Style.AlignmentKey, true)); if (base.get_Control().get_ImageUrl().Length == 0) { Utils.EnterZeroFontSizeTag(writer); writer.WriteBeginTag("div"); if (base.get_Control().get_Format() == null) { writer.WriteAttribute("style", "width:100%"); if (alignment != null) { writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); } writer.Write(">"); writer.EnterLayout(base.get_Style()); writer.WriteBeginTag("input"); Utils.WriteStyleAttribute(writer, base.get_Style(), null); writer.WriteAttribute("type", "submit"); writer.Write(" value=\""); writer.WriteText(base.get_Control().get_Text(), true); writer.Write("\"/>"); writer.ExitLayout(base.get_Style()); } else { Wrapping wrapping = *((Wrapping*) base.get_Style().get_Item(Style.WrappingKey, true)); if ((wrapping != 1) && (wrapping != 0)) { writer.WriteAttribute("style", "overflow-x:hidden;width:100%"); } else { writer.WriteAttribute("style", "word-wrap:break-word;width:100%"); } if (alignment != null) { writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); } writer.Write(">"); writer.WriteBeginTag("a"); writer.WriteAttribute("href", "NavigationUrl"); writer.Write(">"); Utils.WriteCssStyleText(writer, base.get_Style(), null, base.get_Control().get_Text(), true); writer.WriteEndTag("a"); } writer.WriteEndTag("div"); Utils.ExitZeroFontSizeTag(writer); } else { writer.WriteBeginTag("div"); if (alignment == 2) { writer.WriteAttribute("align", "center"); } writer.WriteAttribute("style", "overflow-x:hidden;width:100%"); writer.Write(">"); writer.WriteBeginTag("img"); Utils.WriteStyleAttribute(writer, base.get_Style(), null); writer.WriteAttribute("src", base.get_Control().get_ImageUrl(), true); if ((alignment == 3) || (alignment == 1)) { writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); } writer.WriteAttribute("border", "0"); writer.Write(">"); writer.WriteEndTag("div"); } }
/// <include file='doc\HtmlPageAdapter.uex' path='docs/doc[@for="HtmlPageAdapter.RenderPostBackHeader"]/*' /> public virtual void RenderPostBackHeader(HtmlMobileTextWriter writer, Form form) { bool postBack = form.Action.Length == 0; RenderPageState(writer); writer.WriteHiddenField(EventSourceKey, postBack ? "" : _postedFromOtherFile); writer.WriteHiddenField(EventArgumentKey, ""); RenderHiddenVariables(writer); writer.Write("<script language=javascript><!--\r\n"); writer.Write("function __doPostBack(target, argument){\r\n"); writer.Write(" var theform = document."); writer.Write(form.ClientID); writer.Write("\r\n"); if (form.Action.Length > 0) { writer.Write(" theform.action = \"\"\r\n"); } writer.Write(" theform."); writer.Write(EventSourceKey); writer.Write(".value = target\r\n"); writer.Write(" theform."); writer.Write(EventArgumentKey); writer.Write(".value = argument\r\n"); writer.Write(" theform.submit()\r\n"); writer.Write("}\r\n"); writer.Write("// -->\r\n"); writer.Write("</script>\r\n"); }
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); } } }
/// <include file='doc\HtmlPageAdapter.uex' path='docs/doc[@for="HtmlPageAdapter.RenderUrlPostBackEvent"]/*' /> 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); } }
/// <include file='doc\HtmlPageAdapter.uex' path='docs/doc[@for="HtmlPageAdapter.RenderPostBackEvent"]/*' /> public virtual void RenderPostBackEvent(HtmlMobileTextWriter writer, String target, String argument) { writer.Write("javascript:__doPostBack('"); writer.Write(target); writer.Write("','"); writer.Write(argument); writer.Write("')"); }
/// <include file='doc\HtmlPageAdapter.uex' path='docs/doc[@for="HtmlPageAdapter.RenderForm"]/*' /> 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(); }
/// <include file='doc\HtmlFormAdapter.uex' path='docs/doc[@for="HtmlFormAdapter.RenderPager"]/*' /> protected virtual void RenderPager(HtmlMobileTextWriter writer) { if(!_renderPager) { return; } PagerStyle pagerStyle = Control.PagerStyle; int pageCount = Control.PageCount; if (pageCount <= 1) { return; } int page = Control.CurrentPage; String text = pagerStyle.GetPageLabelText(page, pageCount); if((page > 1) || (text.Length > 0) || (page < pageCount)) { writer.EnterStyle(pagerStyle); } if (page > 1) { RenderPagerTag(writer, page - 1, pagerStyle.GetPreviousPageText(page)); writer.Write(" "); } if (text.Length > 0) { writer.WriteEncodedText(text); writer.Write(" "); } if (page < pageCount) { RenderPagerTag(writer, page + 1, pagerStyle.GetNextPageText(page)); } if((page > 1) || (text.Length > 0) || (page < pageCount)) { writer.ExitStyle(pagerStyle, true); } }
/// <include file='doc\HtmlFormAdapter.uex' path='docs/doc[@for="HtmlFormAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { Color backColor = (Color)Style[Style.BackColorKey, true]; String title = Control.Title; bool isTitleEmpty = String.IsNullOrEmpty(title); bool willWriteHeadElements = !isTitleEmpty || RenderExtraHeadElements(null); if (willWriteHeadElements) { writer.Write("\r\n"); writer.WriteFullBeginTag("head"); } if (!isTitleEmpty) { writer.Write("\r\n"); writer.WriteFullBeginTag("title"); writer.Write(title); writer.WriteEndTag("title"); writer.Write("\r\n"); } _renderPager = true; RenderExtraHeadElements(writer); if (willWriteHeadElements) { writer.WriteEndTag("head"); writer.Write("\r\n"); } IDictionary bodyAttributes = new ListDictionary(); if ((backColor != Color.Empty) && (writer.RenderBodyColor)) { bodyAttributes.Add("bgcolor", ColorTranslator.ToHtml(backColor)); } RenderBodyTag(writer, bodyAttributes); bool formTagRequired = ShouldRenderFormTag(); if (formTagRequired) { writer.WriteBeginTag("form"); writer.WriteAttribute("id", Control.ClientID); writer.WriteAttribute("name", Control.ClientID); writer.WriteAttribute("method", Control.Method.ToString().ToLower(CultureInfo.InvariantCulture)); writer.Write(" action=\""); if (Control.Action.Length > 0) { // AUI 3652 String url = Control.ResolveUrl(Control.Action); if (!Device.SupportsQueryStringInFormAction) { // If query string is not supported, we don't write // it here, and the query string will be added as // hidden variables later. int i = url.IndexOf('?'); if (i != -1) { url = url.Substring(0, i); } } writer.Write(url); } else { writer.WriteEncodedUrl(Page.RelativeFilePath); if (Device.SupportsQueryStringInFormAction) { writer.Write("?"); writer.Write(Page.UniqueFilePathSuffix); if (Control.Method != FormMethod.Get) { String queryStringText = Page.QueryStringText; if (queryStringText != null && queryStringText.Length > 0) { writer.Write('&'); writer.Write(queryStringText); } } } } writer.Write("\""); writer.Write(">\r\n"); PageAdapter.RenderPostBackHeader(writer, Control); // Renders hidden variables for IPostBackDataHandlers which are // not displayed due to pagination or secondary UI. RenderOffPageVariables(writer, Control, Control.CurrentPage); } writer.EnterStyle(Style); writer.BeforeFirstControlWritten = true; MobileControl secondaryUIControl = SecondaryUIControl as MobileControl; if (secondaryUIControl != null && secondaryUIControl.Form == Control) { bool secondaryUIInHeaderOrFooter = IsControlInFormHeader(secondaryUIControl) || IsControlInFormFooter(secondaryUIControl); SetControlPageRecursive(secondaryUIControl, -1); if(Control.Header != null && !secondaryUIInHeaderOrFooter) { Control.Header.RenderControl(writer); } secondaryUIControl.RenderControl(writer); if(Control.Footer != null && !secondaryUIInHeaderOrFooter) { Control.Footer.RenderControl(writer); } } else { bool pagerRendered = false; if(Control.HasControls()) { foreach(Control child in Control.Controls) { if(Control.Footer == child) { RenderPager(writer); pagerRendered = true; } child.RenderControl(writer); } } if(!pagerRendered) { RenderPager(writer); } } writer.ExitStyle(Style, false); if (formTagRequired) { if (!Device.SupportsQueryStringInFormAction) { // Add query string parameters at the end of the form if // there are any RenderQueryParametersAsHiddenFields(writer); } writer.WriteEndTag("form"); } writer.WriteEndTag("body"); }
/// <include file='doc\HtmlControlAdapter.uex' path='docs/doc[@for="HtmlControlAdapter.RenderPostBackEventAsAnchor"]/*' /> protected void RenderPostBackEventAsAnchor( HtmlMobileTextWriter writer, String argument, String linkText) { writer.EnterStyle(Style); writer.WriteBeginTag("a"); RenderPostBackEventAsAttribute(writer, "href", argument); writer.Write(">"); writer.WriteText(linkText, true); writer.WriteEndTag("a"); writer.ExitStyle(Style); }