/////////////////////////////////////////////////////////////////////////
        // SPECIALIZED UTILITY METHODS FOR LIST SELECTIONLIST OBJECTLIST
        /////////////////////////////////////////////////////////////////////////

        // tagname can be any of table, ul, ol.  See the list adapters for examples.
        /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderOpeningListTag"]/*' />
        protected virtual void RenderOpeningListTag(XhtmlMobileTextWriter writer, String tagName)
        {
            String classAttribute = (String)Control.CustomAttributes[XhtmlConstants.CssClassCustomAttribute];

            if (CssLocation == StyleSheetLocation.PhysicalFile && (String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true")
            {
                writer.WritePendingBreak();
                writer.WriteBeginTag(tagName);
                if (classAttribute != null &&
                    classAttribute.Length > 0 &&
                    writer.DiffersFromCurrentPhysicalCssClass(classAttribute))
                {
                    writer.WriteAttribute("class", classAttribute, true);
                    writer.PushPhysicalCssClass(classAttribute);
                    Debug.Assert(!_physicalCssClassPushed, "These calls should not be nested.");
                    _physicalCssClassPushed = true;
                }
                writer.Write(">");
            }
            else if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true")
            {
                writer.WritePendingBreak();
                StyleFilter filter = writer.CurrentStyleClass.GetFilter(Style);
                writer.EnterStyle(new XhtmlFormatStyleClass(Style, filter), tagName);
            }
            else
            {
                writer.WritePendingBreak();
                writer.WriteFullBeginTag(tagName);
            }
        }
 /// <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;
 }
Esempio n. 3
0
 /// <include file='doc\XhtmlBasicValidatorAdapter.uex' path='docs/doc[@for="XhtmlValidatorAdapter.Render"]/*' />
 public override void Render(XhtmlMobileTextWriter writer)
 {
     if (!Control.IsValid && Control.Display != WebControls.ValidatorDisplay.None)
     {
         ConditionalEnterStyle(writer, Style);
         ConditionalRenderOpeningSpanElement(writer);
         writer.WritePendingBreak();
         String controlText         = Control.Text;
         String controlErrorMessage = Control.ErrorMessage;
         if (controlText != null & controlText.Length > 0)
         {
             // ConditionalClearCachedEndTag() is for a device special case.
             ConditionalClearCachedEndTag(writer, Control.Text);
             writer.WriteEncodedText(Control.Text);
         }
         else if (controlErrorMessage != null && controlErrorMessage.Length > 0)
         {
             ConditionalClearCachedEndTag(writer, Control.ErrorMessage);
             writer.WriteEncodedText(Control.ErrorMessage);
         }
         // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
         // ConditionalExitStyle may render a block element and clear the pending break.
         ConditionalSetPendingBreak(writer);
         ConditionalRenderClosingSpanElement(writer);
         ConditionalExitStyle(writer, Style);
     }
 }
        /// <include file='doc\XhtmlBasicTextViewAdapter.uex' path='docs/doc[@for="XhtmlTextViewAdapter.Render"]/*' />
        public override void Render(XhtmlMobileTextWriter writer) {
            int beginElement = Control.FirstVisibleElementIndex;
            int beginOffset = Control.FirstVisibleElementOffset;
            int endElement = Control.LastVisibleElementIndex;
            int endOffset = Control.LastVisibleElementOffset;

            // ConditionalClearCachedEndTag() is for a device special case.
            ConditionalClearCachedEndTag(writer, Control.Text);
            ConditionalEnterStyle(writer, Style);
            ConditionalRenderOpeningSpanElement(writer);
            writer.WritePendingBreak();
            for(int i = beginElement; i <= endElement; i++) {
                int begin = (i == beginElement) ? beginOffset : 0;
                int end;
                if (i == endElement) {
                    if (endOffset <= begin) {
                        break;
                    }
                    end = endOffset;
                }
                else {
                    end = -1;
                }
                RenderElement(writer, i, begin, end);
            }
            // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
            // ConditionalExitStyle may render a block element and clear the pending break.
            ConditionalSetPendingBreak(writer);            
            ConditionalRenderClosingSpanElement(writer);
            ConditionalExitStyle(writer, Style);
        }
 /// <include file='doc\XhtmlBasicLiteralTextAdapter.uex' path='docs/doc[@for="XhtmlLiteralTextAdapter.Render"]/*' />
 public override void Render(XhtmlMobileTextWriter writer) {
     // ConditionalClearCachedEndTag() is for a device special case.
     ConditionalClearCachedEndTag(writer, Control.Text);
     String text = Control.PagedText;
     ConditionalEnterStyle(writer, Style);
     ConditionalRenderOpeningSpanElement(writer);
     writer.WritePendingBreak();
     writer.WriteEncodedText(text);
     // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
     // ConditionalExitStyle may render a block element and clear the pending break.
     ConditionalSetPendingBreak(writer);            
     ConditionalRenderClosingSpanElement(writer);
     ConditionalExitStyle(writer, Style);
 }
 /// <include file='doc\XhtmlBasicLabelAdapter.uex' path='docs/doc[@for="XhtmlLabelAdapter.Render"]/*' />
 public override void Render(XhtmlMobileTextWriter writer)
 {
     // ConditionalClearCachedEndTag() is for a device special case.
     ConditionalClearCachedEndTag(writer, Control.Text);
     ConditionalEnterStyle(writer, Style);
     ConditionalRenderOpeningSpanElement(writer);
     writer.WritePendingBreak();
     writer.WriteEncodedText(Control.Text);
     writer.WriteLine();
     // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
     // ConditionalExitStyle may render a block element and clear the pending break.
     ConditionalSetPendingBreak(writer);
     ConditionalRenderClosingSpanElement(writer);
     ConditionalExitStyle(writer, Style);
 }
        /////////////////////////////////////////////////////////////////////////
        //  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;
        }
 /// <include file='doc\XhtmlBasicValidatorAdapter.uex' path='docs/doc[@for="XhtmlValidatorAdapter.Render"]/*' />
 public override void Render(XhtmlMobileTextWriter writer) {
     if (!Control.IsValid && Control.Display != WebControls.ValidatorDisplay.None) {
         ConditionalEnterStyle(writer, Style);
         ConditionalRenderOpeningSpanElement(writer);
         writer.WritePendingBreak();
         String controlText = Control.Text;
         String controlErrorMessage = Control.ErrorMessage;
         if (controlText != null & controlText.Length > 0) {
             // ConditionalClearCachedEndTag() is for a device special case.
             ConditionalClearCachedEndTag(writer, Control.Text);
             writer.WriteEncodedText (Control.Text);
         }
         else if (controlErrorMessage != null && controlErrorMessage.Length > 0) {
             ConditionalClearCachedEndTag(writer, Control.ErrorMessage);
             writer.WriteEncodedText (Control.ErrorMessage);
         }
         // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
         // ConditionalExitStyle may render a block element and clear the pending break.
         ConditionalSetPendingBreak(writer);            
         ConditionalRenderClosingSpanElement(writer);
         ConditionalExitStyle(writer, Style);
     }
 }
        /// <include file='doc\XhtmlBasicTextViewAdapter.uex' path='docs/doc[@for="XhtmlTextViewAdapter.Render"]/*' />
        public override void Render(XhtmlMobileTextWriter writer)
        {
            int beginElement = Control.FirstVisibleElementIndex;
            int beginOffset  = Control.FirstVisibleElementOffset;
            int endElement   = Control.LastVisibleElementIndex;
            int endOffset    = Control.LastVisibleElementOffset;

            // ConditionalClearCachedEndTag() is for a device special case.
            ConditionalClearCachedEndTag(writer, Control.Text);
            ConditionalEnterStyle(writer, Style);
            ConditionalRenderOpeningSpanElement(writer);
            writer.WritePendingBreak();
            for (int i = beginElement; i <= endElement; i++)
            {
                int begin = (i == beginElement) ? beginOffset : 0;
                int end;
                if (i == endElement)
                {
                    if (endOffset <= begin)
                    {
                        break;
                    }
                    end = endOffset;
                }
                else
                {
                    end = -1;
                }
                RenderElement(writer, i, begin, end);
            }
            // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
            // ConditionalExitStyle may render a block element and clear the pending break.
            ConditionalSetPendingBreak(writer);
            ConditionalRenderClosingSpanElement(writer);
            ConditionalExitStyle(writer, Style);
        }
        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 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("&nbsp;");
                    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("[&nbsp;");
            }
            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("&nbsp;|&nbsp;");
                }
            }
            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("&nbsp;]");
            }
            ConditionalExitStyle(writer, subCommandStyleNoItalic);

            ConditionalRenderClosingDivElement(writer);
        }
        /////////////////////////////////////////////////////////////////////////
        // SPECIALIZED UTILITY METHODS FOR LIST SELECTIONLIST OBJECTLIST
        /////////////////////////////////////////////////////////////////////////

        // tagname can be any of table, ul, ol.  See the list adapters for examples.
        /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderOpeningListTag"]/*' />
        protected virtual void RenderOpeningListTag(XhtmlMobileTextWriter writer, String tagName) {            
            String classAttribute = (String) Control.CustomAttributes[XhtmlConstants.CssClassCustomAttribute];
            if (CssLocation == StyleSheetLocation.PhysicalFile && (String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true") {
                writer.WritePendingBreak();
                writer.WriteBeginTag(tagName);            
                if (classAttribute != null && 
                    classAttribute.Length > 0 &&
                    writer.DiffersFromCurrentPhysicalCssClass(classAttribute)) {
                    writer.WriteAttribute("class", classAttribute, true);
                    writer.PushPhysicalCssClass(classAttribute);
                    Debug.Assert(!_physicalCssClassPushed, "These calls should not be nested.");
                    _physicalCssClassPushed = true;
                }
                writer.Write(">");
            }
            else if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true") {
                writer.WritePendingBreak();
                StyleFilter filter = writer.CurrentStyleClass.GetFilter(Style);
                writer.EnterStyle(new XhtmlFormatStyleClass(Style, filter), tagName);
            }
            else {
                writer.WritePendingBreak();
                writer.WriteFullBeginTag(tagName);
            }
        }
        /////////////////////////////////////////////////////////////////////////
        //  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\XhtmlBasicPhoneCallAdapter.uex' path='docs/doc[@for="XhtmlPhoneCallAdapter.Render"]/*' />
        public override void Render(XhtmlMobileTextWriter writer)
        {
            ConditionalClearPendingBreak(writer);
            Style style = Style;
            StyleFilter filter = writer.CurrentStyleClass.GetFilter(style);
            if ((filter & XhtmlConstants.Layout) != 0) {
                ConditionalEnterLayout(writer, style);
            }
            if (Device.CanInitiateVoiceCall) {
                String text = Control.Text;
                String phoneNumber = Control.PhoneNumber;

                if (text == null || text.Length == 0) {
                    text = phoneNumber;
                }

                writer.WriteBeginTag("a");

                if ((String)Device["supportsWtai"] == "true") {
                    writer.Write(" href=\"wtai://wp/mc;");
                }
                else {
                    writer.Write(" href=\"tel:");
                }

                foreach (char ch in phoneNumber) {
                    if (ch >= '0' && ch <= '9' || ch == '#' || ch == '+') {
                        writer.Write(ch);
                    }
                }
                writer.Write("\"");
                ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
                String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
                if (CssLocation != StyleSheetLocation.PhysicalFile) {
                    String className = writer.GetCssFormatClassName(style);
                    if (className != null) {
                        writer.WriteAttribute ("class", className);
                    }
                }
                else if (cssClass != null && cssClass.Length > 0) {
                    writer.WriteAttribute ("class", cssClass, true /* encode */);
                }
                writer.Write(">");
                writer.WriteEncodedText(text);
                writer.WriteEndTag("a");
                ConditionalSetPendingBreakAfterInline(writer);
            }
            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 (url != null && url.Length > 0) {
                    String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
                    String accessKey = GetCustomAttributeValue(XhtmlConstants.AccessKeyCustomAttribute);
                    RenderBeginLink(writer, url, accessKey, style, cssClass);
                    writer.WriteEncodedText(text);
                    RenderEndLink(writer);
                    ConditionalSetPendingBreakAfterInline(writer);
                }
                else {
                    writer.WritePendingBreak();
                    ConditionalEnterFormat(writer, style);
                    ConditionalRenderOpeningSpanElement(writer);
                    writer.WriteEncodedText(text);
                    ConditionalRenderClosingSpanElement(writer);
                    ConditionalExitFormat(writer, style);
                    ConditionalSetPendingBreak(writer);
                }
            }
            if ((filter & XhtmlConstants.Layout) != 0) {
                ConditionalExitLayout(writer, style);
            }
        }
Esempio n. 17
0
        /// <include file='doc\XhtmlBasicPhoneCallAdapter.uex' path='docs/doc[@for="XhtmlPhoneCallAdapter.Render"]/*' />
        public override void Render(XhtmlMobileTextWriter writer)
        {
            ConditionalClearPendingBreak(writer);
            Style       style  = Style;
            StyleFilter filter = writer.CurrentStyleClass.GetFilter(style);

            if ((filter & XhtmlConstants.Layout) != 0)
            {
                ConditionalEnterLayout(writer, style);
            }
            if (Device.CanInitiateVoiceCall)
            {
                String text        = Control.Text;
                String phoneNumber = Control.PhoneNumber;

                if (text == null || text.Length == 0)
                {
                    text = phoneNumber;
                }

                writer.WriteBeginTag("a");

                if ((String)Device["supportsWtai"] == "true")
                {
                    writer.Write(" href=\"wtai://wp/mc;");
                }
                else
                {
                    writer.Write(" href=\"tel:");
                }

                foreach (char ch in phoneNumber)
                {
                    if (ch >= '0' && ch <= '9' || ch == '#' || ch == '+')
                    {
                        writer.Write(ch);
                    }
                }
                writer.Write("\"");
                ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
                String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
                if (CssLocation != StyleSheetLocation.PhysicalFile)
                {
                    String className = writer.GetCssFormatClassName(style);
                    if (className != null)
                    {
                        writer.WriteAttribute("class", className);
                    }
                }
                else if (cssClass != null && cssClass.Length > 0)
                {
                    writer.WriteAttribute("class", cssClass, true /* encode */);
                }
                writer.Write(">");
                writer.WriteEncodedText(text);
                writer.WriteEndTag("a");
                ConditionalSetPendingBreakAfterInline(writer);
            }
            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 (url != null && url.Length > 0)
                {
                    String cssClass  = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
                    String accessKey = GetCustomAttributeValue(XhtmlConstants.AccessKeyCustomAttribute);
                    RenderBeginLink(writer, url, accessKey, style, cssClass);
                    writer.WriteEncodedText(text);
                    RenderEndLink(writer);
                    ConditionalSetPendingBreakAfterInline(writer);
                }
                else
                {
                    writer.WritePendingBreak();
                    ConditionalEnterFormat(writer, style);
                    ConditionalRenderOpeningSpanElement(writer);
                    writer.WriteEncodedText(text);
                    ConditionalRenderClosingSpanElement(writer);
                    ConditionalExitFormat(writer, style);
                    ConditionalSetPendingBreak(writer);
                }
            }
            if ((filter & XhtmlConstants.Layout) != 0)
            {
                ConditionalExitLayout(writer, style);
            }
        }
        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("&nbsp;");
                    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("[&nbsp;");
            }
            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("&nbsp;|&nbsp;");
                }
            }
            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("&nbsp;]");
            }
            ConditionalExitStyle(writer, subCommandStyleNoItalic);

            ConditionalRenderClosingDivElement(writer);
        }