/// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalSetPendingBreak"]/*' /> protected virtual void ConditionalSetPendingBreak(XhtmlMobileTextWriter writer) { MobileControl mobileControl = Control as MobileControl; if (mobileControl != null && mobileControl.BreakAfter) { writer.SetPendingBreak(); } }
///////////////////////////////////////////////////////////////////////// // PAGINATION SUPPORT ///////////////////////////////////////////////////////////////////////// /// <include file='doc\XhtmlBasicFormAdapter.uex' path='docs/doc[@for="XhtmlFormAdapter.RenderPager"]/*' /> protected virtual void RenderPager(XhtmlMobileTextWriter writer) { 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.WritePendingBreak(); ConditionalEnterStyle(writer, pagerStyle); ConditionalEnterPagerSpan(writer); } if (page > 1) { RenderPagerTag(writer, page - 1, pagerStyle.GetPreviousPageText(page), XhtmlConstants.PagerPreviousAccessKeyCustomAttribute); writer.Write(" "); } if (text.Length > 0) { writer.WriteEncodedText(text); writer.Write(" "); } if (page < pageCount) { RenderPagerTag(writer, page + 1, pagerStyle.GetNextPageText(page), XhtmlConstants.PagerNextAccessKeyCustomAttribute); } if ((page > 1) || (text.Length > 0) || (page < pageCount)) { ConditionalExitPagerSpan(writer); ConditionalExitStyle(writer, pagerStyle); writer.SetPendingBreak(); } }
/// <include file='doc\XhtmlBasicTextViewAdapter.uex' path='docs/doc[@for="XhtmlTextViewAdapter.RenderElement"]/*' /> public void RenderElement(XhtmlMobileTextWriter writer, int index, int beginSubstring, int endSubstring) { TextViewElement element = Control.GetElement(index); writer.WritePendingBreak(); if (endSubstring == -1) { endSubstring = element.Text.Length; } String text = element.Text; if (beginSubstring > 0 || endSubstring < text.Length) { text = text.Substring(beginSubstring, endSubstring - beginSubstring); } BooleanOption prevBold = Style.Font.Bold; BooleanOption prevItalic = Style.Font.Italic; if (element.IsBold) { Style.Font.Bold = BooleanOption.True; } if (element.IsItalic) { Style.Font.Italic = BooleanOption.True; } ConditionalEnterStyle(writer, Style); if (element.Url != null) { RenderBeginLink(writer, element.Url); writer.WriteEncodedText(text); RenderEndLink(writer); } else { writer.WriteEncodedText(text); } if (element.BreakAfter) { writer.SetPendingBreak(); } ConditionalExitStyle(writer, Style); Style.Font.Bold = prevBold; Style.Font.Italic = prevItalic; }
private void RenderItemsListWithoutTableTags(XhtmlMobileTextWriter writer) { if (Control.VisibleItemCount == 0) { return; } ConditionalRenderOpeningDivElement(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; String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute); String labelClass = GetCustomAttributeValue(XhtmlConstants.CssLabelClassCustomAttribute); if (labelClass == null || labelClass.Length == 0) { labelClass = cssClass; } ConditionalEnterStyle(writer, labelStyle); bool requiresLabelClassSpan = CssLocation == StyleSheetLocation.PhysicalFile && labelClass != null && labelClass.Length > 0; if (requiresLabelClassSpan) { writer.WriteBeginTag("span"); writer.WriteAttribute("class", labelClass, true); writer.Write(">"); } writer.Write(Control.AllFields[labelFieldIndex].Title); writer.SetPendingBreak(); if (requiresLabelClassSpan) { writer.WriteEndTag("span"); } ConditionalExitStyle(writer, labelStyle); writer.WritePendingBreak(); 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; ConditionalEnterStyle(writer, style); for (int i = startIndex; i < nextStartIndex; i++) { ObjectListItem item = items[i]; String accessKey = GetCustomAttributeValue(item, XhtmlConstants.AccessKeyCustomAttribute); String itemClass = GetCustomAttributeValue(item, XhtmlConstants.CssClassCustomAttribute); if (itemRequiresHyperlink) { RenderPostBackEventAsAnchor(writer, hasDefaultCommand ? item.Index.ToString(CultureInfo.InvariantCulture) : String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index), item[labelFieldIndex], accessKey, Style, cssClass); } else { bool requiresItemClassSpan = CssLocation == StyleSheetLocation.PhysicalFile && itemClass != null && itemClass.Length > 0; if (requiresItemClassSpan) { writer.WriteBeginTag("span"); writer.WriteAttribute("class", itemClass, true); writer.Write(">"); } writer.Write(item[labelFieldIndex]); if (requiresItemClassSpan) { writer.WriteEndTag("span"); } } if (itemRequiresMoreButton) { String commandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute); BooleanOption cachedItalic = subCommandStyle.Font.Italic; subCommandStyle.Font.Italic = BooleanOption.False; ConditionalEnterFormat(writer, subCommandStyle); if ((String)Device[XhtmlConstants.BreaksOnInlineElements] != "true") { writer.Write(" ["); } ConditionalExitFormat(writer, subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; ConditionalEnterFormat(writer, subCommandStyle); String controlMT = Control.MoreText; String moreText = (controlMT == null || controlMT.Length == 0) ? GetDefaultLabel(MoreLabel) : controlMT; RenderPostBackEventAsAnchor(writer, String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index), moreText, null /*accessKey*/, subCommandStyle, commandClass); ConditionalExitFormat(writer, subCommandStyle); subCommandStyle.Font.Italic = BooleanOption.False; ConditionalEnterFormat(writer, subCommandStyle); if ((String)Device[XhtmlConstants.BreaksOnInlineElements] != "true") { writer.Write("]"); } ConditionalExitFormat(writer, subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; } if (i < (nextStartIndex - 1)) { writer.WriteBreak(); } else { writer.SetPendingBreak(); } } ConditionalExitStyle(writer, style); ConditionalRenderClosingDivElement(writer); }
private void RenderItemDetailsWithoutTableTags(XhtmlMobileTextWriter writer, ObjectListItem item) { if (Control.VisibleItemCount == 0) { return; } Style style = this.Style; Style labelStyle = Control.LabelStyle; Style subCommandStyle = Control.CommandStyle; Style subCommandStyleNoItalic = (Style)subCommandStyle.Clone(); subCommandStyleNoItalic.Font.Italic = BooleanOption.False; ConditionalRenderOpeningDivElement(writer); String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute); String labelClass = GetCustomAttributeValue(XhtmlConstants.CssLabelClassCustomAttribute); if (labelClass == null || labelClass.Length == 0) { labelClass = cssClass; } ConditionalEnterStyle(writer, labelStyle); bool requiresLabelClassSpan = CssLocation == StyleSheetLocation.PhysicalFile && labelClass != null && labelClass.Length > 0; if (requiresLabelClassSpan) { writer.WriteBeginTag("span"); writer.WriteAttribute("class", labelClass, true); writer.Write(">"); } writer.Write(item[Control.LabelFieldIndex]); writer.SetPendingBreak(); if (requiresLabelClassSpan) { writer.WriteEndTag("span"); } ConditionalExitStyle(writer, labelStyle); writer.WritePendingBreak(); IObjectListFieldCollection fields = Control.AllFields; int fieldIndex = 0; ConditionalEnterStyle(writer, style); foreach (ObjectListField field in fields) { if (field.Visible) { writer.Write(field.Title + ":"); writer.Write(" "); writer.Write(item[fieldIndex]); writer.WriteBreak(); } fieldIndex++; } ConditionalExitStyle(writer, style); String commandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute); ConditionalEnterStyle(writer, subCommandStyleNoItalic); if ((String) Device[XhtmlConstants.BreaksOnInlineElements] != "true") { writer.Write("[ "); } ConditionalEnterStyle(writer, subCommandStyle); ObjectListCommandCollection commands = Control.Commands; foreach (ObjectListCommand command in commands) { RenderPostBackEventAsAnchor(writer, command.Name, command.Text); if ((String) Device[XhtmlConstants.BreaksOnInlineElements] != "true") { writer.Write(" | "); } } String controlBCT = Control.BackCommandText; String backCommandText = controlBCT == null || controlBCT.Length == 0 ? GetDefaultLabel(BackLabel) : Control.BackCommandText; RenderPostBackEventAsAnchor(writer, BackToList, backCommandText); ConditionalExitStyle(writer, subCommandStyle); if ((String) Device[XhtmlConstants.BreaksOnInlineElements] != "true") { writer.Write(" ]"); } ConditionalExitStyle(writer, subCommandStyleNoItalic); ConditionalRenderClosingDivElement(writer); }
/// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalSetPendingBreak"]/*' /> protected virtual void ConditionalSetPendingBreak (XhtmlMobileTextWriter writer) { MobileControl mobileControl = Control as MobileControl; if (mobileControl != null && mobileControl.BreakAfter) { writer.SetPendingBreak (); } }
///////////////////////////////////////////////////////////////////////// // PAGINATION SUPPORT ///////////////////////////////////////////////////////////////////////// /// <include file='doc\XhtmlBasicFormAdapter.uex' path='docs/doc[@for="XhtmlFormAdapter.RenderPager"]/*' /> protected virtual void RenderPager (XhtmlMobileTextWriter writer) { 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.WritePendingBreak(); ConditionalEnterStyle(writer, pagerStyle); ConditionalEnterPagerSpan(writer); } if (page > 1) { RenderPagerTag(writer, page - 1, pagerStyle.GetPreviousPageText(page), XhtmlConstants.PagerPreviousAccessKeyCustomAttribute); writer.Write(" "); } if (text.Length > 0) { writer.WriteEncodedText(text); writer.Write(" "); } if (page < pageCount) { RenderPagerTag(writer, page + 1, pagerStyle.GetNextPageText(page), XhtmlConstants.PagerNextAccessKeyCustomAttribute); } if((page > 1) || (text.Length > 0) || (page < pageCount)) { ConditionalExitPagerSpan(writer); ConditionalExitStyle(writer, pagerStyle); writer.SetPendingBreak(); } }
private void RenderItemDetailsWithoutTableTags(XhtmlMobileTextWriter writer, ObjectListItem item) { if (Control.VisibleItemCount == 0) { return; } Style style = this.Style; Style labelStyle = Control.LabelStyle; Style subCommandStyle = Control.CommandStyle; Style subCommandStyleNoItalic = (Style)subCommandStyle.Clone(); subCommandStyleNoItalic.Font.Italic = BooleanOption.False; ConditionalRenderOpeningDivElement(writer); String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute); String labelClass = GetCustomAttributeValue(XhtmlConstants.CssLabelClassCustomAttribute); if (labelClass == null || labelClass.Length == 0) { labelClass = cssClass; } ConditionalEnterStyle(writer, labelStyle); bool requiresLabelClassSpan = CssLocation == StyleSheetLocation.PhysicalFile && labelClass != null && labelClass.Length > 0; if (requiresLabelClassSpan) { writer.WriteBeginTag("span"); writer.WriteAttribute("class", labelClass, true); writer.Write(">"); } writer.Write(item[Control.LabelFieldIndex]); writer.SetPendingBreak(); if (requiresLabelClassSpan) { writer.WriteEndTag("span"); } ConditionalExitStyle(writer, labelStyle); writer.WritePendingBreak(); IObjectListFieldCollection fields = Control.AllFields; int fieldIndex = 0; ConditionalEnterStyle(writer, style); foreach (ObjectListField field in fields) { if (field.Visible) { writer.Write(field.Title + ":"); writer.Write(" "); writer.Write(item[fieldIndex]); writer.WriteBreak(); } fieldIndex++; } ConditionalExitStyle(writer, style); String commandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute); ConditionalEnterStyle(writer, subCommandStyleNoItalic); if ((String)Device[XhtmlConstants.BreaksOnInlineElements] != "true") { writer.Write("[ "); } ConditionalEnterStyle(writer, subCommandStyle); ObjectListCommandCollection commands = Control.Commands; foreach (ObjectListCommand command in commands) { RenderPostBackEventAsAnchor(writer, command.Name, command.Text); if ((String)Device[XhtmlConstants.BreaksOnInlineElements] != "true") { writer.Write(" | "); } } String controlBCT = Control.BackCommandText; String backCommandText = controlBCT == null || controlBCT.Length == 0 ? GetDefaultLabel(BackLabel) : Control.BackCommandText; RenderPostBackEventAsAnchor(writer, BackToList, backCommandText); ConditionalExitStyle(writer, subCommandStyle); if ((String)Device[XhtmlConstants.BreaksOnInlineElements] != "true") { writer.Write(" ]"); } ConditionalExitStyle(writer, subCommandStyleNoItalic); ConditionalRenderClosingDivElement(writer); }