/// <include file='doc\HtmlTextViewAdapter.uex' path='docs/doc[@for="HtmlTextViewAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            int beginElement = Control.FirstVisibleElementIndex;
            int beginOffset = Control.FirstVisibleElementOffset;
            int endElement = Control.LastVisibleElementIndex;
            int endOffset = Control.LastVisibleElementOffset;

            writer.EnterStyle(Style);
            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);
            }
            writer.ExitStyle(Style, Control.BreakAfter);
        }
        /// <include file='doc\HtmlTextViewAdapter.uex' path='docs/doc[@for="HtmlTextViewAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            int beginElement = Control.FirstVisibleElementIndex;
            int beginOffset  = Control.FirstVisibleElementOffset;
            int endElement   = Control.LastVisibleElementIndex;
            int endOffset    = Control.LastVisibleElementOffset;

            writer.EnterStyle(Style);
            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);
            }
            writer.ExitStyle(Style, Control.BreakAfter);
        }
        //  calls the more specific render methods
        /// <include file='doc\HtmlLiteralTextAdapter.uex' path='docs/doc[@for="HtmlLiteralTextAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            String text = Control.PagedText;

            writer.EnterStyle(Style);
            writer.WriteText(text, true);
            writer.ExitStyle(Style, Control.BreakAfter);
        }
 //  calls the more specific render methods
 /// <include file='doc\HtmlLiteralTextAdapter.uex' path='docs/doc[@for="HtmlLiteralTextAdapter.Render"]/*' />
 public override void Render(HtmlMobileTextWriter writer)
 {
     String text = Control.PagedText;
     
     writer.EnterStyle(Style);
     writer.WriteText(text, true);
     writer.ExitStyle(Style, Control.BreakAfter);
 }
Example #5
0
 public override void Render(HtmlMobileTextWriter writer)
 {
     writer.EnterStyle(Style);
     RenderBeginLink(writer, Control.NavigateUrl);
     writer.WriteText((Control.Text == String.Empty) ? Control.NavigateUrl : Control.Text, true);
     RenderEndLink(writer);
     writer.ExitStyle(Style, Control.BreakAfter);
 }
 /// <include file='doc\HtmlLinkAdapter.uex' path='docs/doc[@for="HtmlLinkAdapter.Render"]/*' />
 public override void Render(HtmlMobileTextWriter writer)
 {
     writer.EnterStyle(Style);
     String navigateUrl = Control.NavigateUrl;
     RenderBeginLink(writer, navigateUrl);
     writer.WriteText(String.IsNullOrEmpty(Control.Text) ? navigateUrl : Control.Text, true);
     RenderEndLink(writer);
     writer.ExitStyle(Style, Control.BreakAfter);
 }
        /// <include file='doc\HtmlLinkAdapter.uex' path='docs/doc[@for="HtmlLinkAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            writer.EnterStyle(Style);
            String navigateUrl = Control.NavigateUrl;

            RenderBeginLink(writer, navigateUrl);
            writer.WriteText(String.IsNullOrEmpty(Control.Text) ? navigateUrl : Control.Text, true);
            RenderEndLink(writer);
            writer.ExitStyle(Style, Control.BreakAfter);
        }
 public override void Render(HtmlMobileTextWriter writer)
 {
     if (Control.Content != null)
     {
         Control.Content.RenderControl(writer);
     }
     else
     {
         writer.EnterStyle(Style);
         RenderChildren(writer);
         writer.ExitStyle(Style, Control.BreakAfter);
     }
 }
 /// <include file='doc\HtmlPanelAdapter.uex' path='docs/doc[@for="HtmlPanelAdapter.Render"]/*' />
 public override void Render(HtmlMobileTextWriter writer)
 {
     if (Control.Content != null)
     {
         Control.Content.RenderControl(writer);
     }
     else
     {
         writer.EnterStyle(Style);
         RenderChildren(writer);
         writer.ExitStyle(Style, Control.BreakAfter);
     }
 }
 protected void RenderPostBackEventAsAnchor(
     HtmlMobileTextWriter writer,
     String argument,
     String linkText)
 {
     writer.EnterStyle(Style);
     writer.WriteBeginTag("a");
     RenderPostBackEventAsAttribute(writer, "href", argument);
     writer.Write(">");
     writer.WriteText(linkText, true);
     writer.WriteEndTag("a");
     writer.ExitStyle(Style);
 }
        /// <include file='doc\HtmlPhoneCallAdapter.uex' path='docs/doc[@for="HtmlPhoneCallAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            writer.EnterStyle(Style);
            if (Device.CanInitiateVoiceCall)
            {
                String text        = Control.Text;
                String phoneNumber = Control.PhoneNumber;

                if (String.IsNullOrEmpty(text))
                {
                    text = phoneNumber;
                }

                writer.WriteBeginTag("a");
                writer.Write(" href=\"tel:");

                foreach (char ch in phoneNumber)
                {
                    if (ch >= '0' && ch <= '9' || ch == '#' || ch == '+')
                    {
                        writer.Write(ch);
                    }
                }
                writer.Write("\"");
                AddAttributes(writer);
                writer.Write(">");
                writer.WriteText(text, true);
                writer.WriteEndTag("a");
            }
            else
            {
                // Format the text string based on properties
                String text = String.Format(CultureInfo.CurrentCulture, Control.AlternateFormat, Control.Text,
                                            Control.PhoneNumber);
                String url = Control.AlternateUrl;

                // If URI specified, create a link.  Otherwise, only text is displayed.
                if (!String.IsNullOrEmpty(url))
                {
                    RenderBeginLink(writer, url);
                    writer.WriteText(text, true);
                    RenderEndLink(writer);
                }
                else
                {
                    writer.WriteText(text, true);
                }
            }
            writer.ExitStyle(Style, Control.BreakAfter);
        }
 /// <include file='doc\HtmlLabelAdapter.uex' path='docs/doc[@for="HtmlLabelAdapter.Render"]/*' />
 public override void Render(HtmlMobileTextWriter writer)
 {
     writer.EnterStyle(Style);
     if( (writer.BeforeFirstControlWritten) &&
         (Device.RequiresLeadingPageBreak)  &&
         (String.IsNullOrEmpty(Control.Text) || WhiteSpace(Control.Text) ) )
     {
         writer.WriteBreak();
     }
     else
     {
         writer.WriteText(Control.Text, true);
     }
     writer.ExitStyle(Style, Control.BreakAfter);
 }
 public override void Render(HtmlMobileTextWriter writer)
 {
     writer.EnterStyle(Style);
     if ((writer.BeforeFirstControlWritten) &&
         (Device.RequiresLeadingPageBreak) &&
         ((Control.Text == String.Empty) || WhiteSpace(Control.Text)))
     {
         writer.WriteBreak();
     }
     else
     {
         writer.WriteText(Control.Text, true);
     }
     writer.ExitStyle(Style, Control.BreakAfter);
 }
        public override void Render(HtmlMobileTextWriter writer)
        {
            String[] errorMessages = null;

            if (Control.Visible)
            {
                errorMessages = Control.GetErrorMessages();
            }

            if (errorMessages != null)
            {
                writer.EnterStyle(Style);
                if (Control.HeaderText.Length > 0)
                {
                    writer.WriteText(Control.HeaderText, true);
                }

                ArrayList arr = new ArrayList();
                foreach (String errorMessage in errorMessages)
                {
                    Debug.Assert(errorMessage != null && errorMessage.Length > 0, "Bad Error Messages");
                    arr.Add(errorMessage);
                }

                _list.Decoration = ListDecoration.Bulleted;
                _list.DataSource = arr;
                _list.DataBind();

                if (String.Compare(Control.FormToValidate, Control.Form.UniqueID, true, CultureInfo.InvariantCulture) != 0)
                {
                    _link.NavigateUrl = Constants.FormIDPrefix + Control.FormToValidate;
                    _link.Text        = Control.BackLabel == String.Empty? GetDefaultLabel(BackLabel) : Control.BackLabel;
                    // Summary writes its own break so last control should write one.
                    _link.BreakAfter = false;
                }
                else
                {
                    _link.Visible = false;
                    // Summary writes its own break so last control should write one.
                    _list.BreakAfter = false;
                }

                // Render the child controls to display error message list and a
                // link for going back to the Form that is having error
                RenderChildren(writer);
                writer.ExitStyle(Style, Control.BreakAfter);
            }
        }
 public override void Render(HtmlMobileTextWriter writer)
 {
     if (!Control.IsValid && Control.Display != ValidatorDisplay.None)
     {
         writer.EnterStyle(Style);
         if (Control.Text != String.Empty)
         {
             writer.WriteText(Control.Text, true);
         }
         else if (Control.ErrorMessage != String.Empty)
         {
             writer.WriteText(Control.ErrorMessage, true);
         }
         writer.ExitStyle(Style, Control.BreakAfter);
     }
 }
 /// <include file='doc\HtmlValidatorAdapter.uex' path='docs/doc[@for="HtmlValidatorAdapter.Render"]/*' />
 public override void Render(HtmlMobileTextWriter writer)
 {
     if (!Control.IsValid && Control.Display != ValidatorDisplay.None)
     {
         writer.EnterStyle(Style);
         if (!String.IsNullOrEmpty(Control.Text))
         {
             writer.WriteText(Control.Text, true);
         }
         else if (!String.IsNullOrEmpty(Control.ErrorMessage))
         {
             writer.WriteText(Control.ErrorMessage, true);
         }
         writer.ExitStyle(Style, Control.BreakAfter);
     }
 }
        /// <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);
            }
        }
        private void RenderElement(HtmlMobileTextWriter writer, int index, int begin, int end)
        {
            TextViewElement element = Control.GetElement(index);

            if (end == -1)
            {
                end = element.Text.Length;
            }

            String text = element.Text;

            if (begin > 0 || end < text.Length)
            {
                text = text.Substring(begin, end - begin);
            }

            BooleanOption previousBold   = Style.Font.Bold;
            BooleanOption previousItalic = Style.Font.Italic;

            if (element.IsBold)
            {
                Style.Font.Bold = BooleanOption.True;
            }
            if (element.IsItalic)
            {
                Style.Font.Italic = BooleanOption.True;
            }

            writer.EnterStyle(Style);
            if (element.Url != null)
            {
                RenderBeginLink(writer, element.Url);
                writer.WriteText(text, true);
                RenderEndLink(writer);
            }
            else
            {
                writer.WriteText(text, true);
            }
            writer.ExitStyle(Style, element.BreakAfter);

            Style.Font.Bold   = previousBold;
            Style.Font.Italic = previousItalic;
        }
        /// <include file='doc\HtmlValidationSummaryAdapter.uex' path='docs/doc[@for="HtmlValidationSummaryAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            String[] errorMessages = null;

            if (Control.Visible)
            {
                errorMessages = Control.GetErrorMessages();
            }

            if (errorMessages != null)
            {
                writer.EnterStyle(Style);
                if (Control.HeaderText.Length > 0)
                {
                    writer.WriteText(Control.HeaderText, true);
                }

                ArrayList arr = new ArrayList();
                foreach (String errorMessage in errorMessages)
                {
                    Debug.Assert(errorMessage != null && errorMessage.Length > 0, "Bad Error Messages");
                    arr.Add(errorMessage);
                }

                _list.Decoration = ListDecoration.Bulleted;
                _list.DataSource = arr;
                _list.DataBind();

                if (String.Compare(Control.FormToValidate, Control.Form.UniqueID, StringComparison.OrdinalIgnoreCase) != 0)
                {
                    _link.NavigateUrl = Constants.FormIDPrefix + Control.FormToValidate;
                    _link.Text = String.IsNullOrEmpty(Control.BackLabel) ? GetDefaultLabel(BackLabel) : Control.BackLabel;
                    // Summary writes its own break so last control should write one.
                    _link.BreakAfter = false;
                }
                else
                {
                    _link.Visible = false;
                    // Summary writes its own break so last control should write one.
                    _list.BreakAfter = false;
                }

                // Render the child controls to display error message list and a
                // link for going back to the Form that is having error
                RenderChildren(writer);
                writer.ExitStyle(Style, Control.BreakAfter);
            }
        }
        /// <include file='doc\HtmlSelectionListAdapter.uex' path='docs/doc[@for="HtmlSelectionListAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            MobileListItemCollection items = Control.Items;
            ListSelectType selectType = Control.SelectType;

            if (items.Count == 0 && 
                selectType != ListSelectType.ListBox && 
                selectType != ListSelectType.MultiSelectListBox)
            {
                return;
            }
            
            int selectedIndex = Control.SelectedIndex;
            String renderName;
            if(Device.RequiresAttributeColonSubstitution)
            {
                renderName = Control.UniqueID.Replace(':', ',');
            }
            else
            {
                renderName = Control.UniqueID;
            }

            switch(selectType)
            {
                case ListSelectType.DropDown:
                case ListSelectType.ListBox:
                case ListSelectType.MultiSelectListBox:

                    if (items.Count == 0 && !Device.CanRenderEmptySelects)
                    {
                        break;
                    }

                    writer.EnterLayout(Style);
                    writer.WriteBeginTag("select");

                    if (selectType == ListSelectType.MultiSelectListBox)
                    {
                        writer.Write(" multiple");
                    }

                    if (selectType == ListSelectType.ListBox || selectType == ListSelectType.MultiSelectListBox)
                    {
                        writer.WriteAttribute("size", Control.Rows.ToString(CultureInfo.InvariantCulture));
                    }

                    writer.WriteAttribute("name", renderName);
                    writer.Write(">");

                    for(int itemIndex = 0; itemIndex < items.Count; itemIndex++)
                    {
                        MobileListItem item = items[itemIndex];
                        writer.WriteBeginTag("option");
                        WriteItemValueAttribute(writer, itemIndex, item.Value);
                        if (item.Selected && (Control.IsMultiSelect || itemIndex == selectedIndex))
                        {
                            writer.Write(" selected>");
                        }
                        else
                        {
                            writer.Write(">");
                        }
                        writer.WriteEncodedText(item.Text);
                        writer.WriteLine("");
                    }
                    writer.Write("</select>");
            
                    if(Device.HidesRightAlignedMultiselectScrollbars &&
                        selectType == ListSelectType.MultiSelectListBox)
                    {
                        // nested if for perf
                        if((Alignment)Style[Style.AlignmentKey, true] == Alignment.Right)
                        {                                                
                            writer.Write("&nbsp;&nbsp;&nbsp;&nbsp;");
                        }
                    }
                    writer.WriteLine("");
                    
                    if (!Page.DesignMode)
                    {
                        writer.ExitLayout(Style, Control.BreakAfter);
                    }
                    else
                    {
                        writer.ExitLayout(Style, false);
                    }
                    break;

                case ListSelectType.Radio:
                case ListSelectType.CheckBox:

                    String selectTypeString =
                        (selectType == ListSelectType.Radio) ?
                        "radio" :
                        "checkbox";
                    Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];
                    if(!Device.Tables || alignment == Alignment.Left || alignment == Alignment.NotSet)
                    {
                        writer.EnterStyle(Style);
                        bool breakAfter = false;
                        for(int itemIndex = 0; itemIndex < items.Count; itemIndex++)
                        {
                            if(breakAfter)
                            {
                                writer.WriteBreak();
                            }
                            MobileListItem item = items[itemIndex];

                            writer.WriteBeginTag("input");
                            writer.WriteAttribute("type", selectTypeString);
                            writer.WriteAttribute("name", renderName);
                            WriteItemValueAttribute(writer, itemIndex, item.Value);
                            if (item.Selected && 
                                (Control.IsMultiSelect || itemIndex == selectedIndex) &&
                                Device.SupportsUncheck)
                            {
                                writer.Write(" checked>");
                            }
                            else
                            {
                                writer.Write(">");
                            }
                            writer.WriteEncodedText(item.Text);
                            breakAfter = true;
                        }
                        writer.ExitStyle(Style, Control.BreakAfter);
                    }
                    else // Device supports tables and alignment is non default.
                    {
                        Wrapping  wrapping  = (Wrapping) Style[Style.WrappingKey , true];
                        bool nowrap = (wrapping == Wrapping.NoWrap);

                        writer.EnterLayout(Style);
                        writer.WriteFullBeginTag("table");
                        writer.BeginStyleContext();
                        for(int itemIndex = 0; itemIndex < items.Count; itemIndex++)
                        {
                            MobileListItem item = items[itemIndex];
                            writer.WriteFullBeginTag("tr");
                            writer.WriteBeginTag("td");
                            if(nowrap)
                            {
                                writer.WriteAttribute("nowrap","true");
                            }
                            writer.Write(">");

                            writer.WriteBeginTag("input");
                            writer.WriteAttribute("type", selectTypeString);
                            writer.WriteAttribute("name", renderName);
                            WriteItemValueAttribute(writer, itemIndex, item.Value);
                            if (item.Selected && 
                                (Control.IsMultiSelect || itemIndex == selectedIndex) &&
                                Device.SupportsUncheck)
                            {
                                writer.Write(" checked>");
                            }
                            else
                            {
                                writer.Write(">");
                            }

                            writer.MarkStyleContext();
                            writer.EnterFormat(Style);
                            writer.WriteEncodedText(item.Text);
                            writer.ExitFormat(Style);
                            writer.UnMarkStyleContext();
                            writer.WriteEndTag("td");
                            writer.WriteEndTag("tr");
                        }
                        writer.WriteEndTag("table");
                        writer.EndStyleContext();
                        writer.ExitFormat(Style, Control.BreakAfter);
                    }
                break;
            }
        }
Example #21
0
        /// <include file='doc\HtmlListAdapter.uex' path='docs/doc[@for="HtmlListAdapter.RenderList"]/*' />
        protected virtual void RenderList(HtmlMobileTextWriter writer)
        {
            MobileListItemCollection items = Control.Items;
            Wrapping wrap = Style.Wrapping; // used for tables, no decoration case.

            if (items.Count == 0)
            {
                return;
            }

            int pageStart = Control.FirstVisibleItemIndex;
            int pageSize  = Control.VisibleItemCount;

            // Determine what markup to use.

            String         listSuffix, itemPrefix, itemSuffix;
            ListDecoration decoration  = Control.Decoration;
            bool           insideStyle = true;

            // We know that for table tag, outer style doesn't carry over
            // into inside tags so style state needs to be reset.
            // For other cases, we enter the style here once and exit at the
            // end once.
            if (decoration != ListDecoration.None || !Device.Tables)
            {
                writer.EnterStyle(Style);
                insideStyle = false;
            }

            switch (decoration)
            {
            case ListDecoration.Bulleted:
                writer.WriteLine("<ul>");
                listSuffix = "</ul>";
                itemPrefix = "<li>";
                itemSuffix = "</li>";

                if (!Device.RendersBreaksAfterHtmlLists)
                {
                    listSuffix += "<br>";
                }
                break;

            case ListDecoration.Numbered:
                if (pageStart == 0)
                {
                    writer.WriteLine("<ol>");
                }
                else
                {
                    writer.Write("<ol start=\"");
                    writer.Write(pageStart + 1);
                    writer.WriteLine("\">");
                }
                listSuffix = "</ol>";
                itemPrefix = "<li>";
                itemSuffix = "</li>";

                if (!Device.RendersBreaksAfterHtmlLists)
                {
                    listSuffix += "<br>";
                }
                break;

            default:
                if (Device.Tables)
                {
                    listSuffix     = "</table>";
                    Style.Wrapping = Wrapping.NotSet;
                    writer.EnterLayout(Style);
                    writer.WriteLine("<table>");
                    if (wrap == Wrapping.NoWrap)
                    {
                        itemPrefix = "<tr nowrap><td>";
                    }
                    else
                    {
                        itemPrefix = "<tr><td>";
                    }
                    itemSuffix = "</td></tr>";
                }
                else
                {
                    listSuffix = String.Empty;
                    itemPrefix = String.Empty;
                    itemSuffix = "<br>";
                }
                break;
            }

            bool hasCmdHandler = Control.HasItemCommandHandler;

            for (int i = 0; i < pageSize; i++)
            {
                MobileListItem item = items[pageStart + i];
                writer.Write(itemPrefix);

                if (insideStyle)
                {
                    writer.BeginStyleContext();
                    writer.EnterFormat(Style);
                }

                if (Control.ItemsAsLinks)
                {
                    RenderBeginLink(writer, item.Value);
                }
                else if (hasCmdHandler)
                {
                    writer.WriteBeginTag("a");
                    RenderPostBackEventAsAttribute(writer, "href", item.Index.ToString(CultureInfo.InvariantCulture));
                    writer.Write(">");
                }
                writer.WriteEncodedText(item.Text);

                if (hasCmdHandler || Control.ItemsAsLinks)
                {
                    RenderEndLink(writer);
                }

                if (insideStyle)
                {
                    writer.ExitFormat(Style);
                    writer.EndStyleContext();
                }
                writer.WriteLine(itemSuffix);
            }

            if (listSuffix == null || listSuffix.Length > 0)
            {
                writer.WriteLine(listSuffix);
            }

            if (decoration != ListDecoration.None || !Device.Tables)
            {
                writer.ExitStyle(Style);
            }
            else
            {
                writer.ExitLayout(Style);
                Style.Wrapping = wrap;
            }
        }
        /// <include file='doc\HtmlListAdapter.uex' path='docs/doc[@for="HtmlListAdapter.RenderList"]/*' />
        protected virtual void RenderList(HtmlMobileTextWriter writer)
        {
            MobileListItemCollection items = Control.Items;
            Wrapping wrap = Style.Wrapping; // used for tables, no decoration case.
            if (items.Count == 0)
            {
                return;
            }

            int pageStart = Control.FirstVisibleItemIndex;
            int pageSize = Control.VisibleItemCount;

            // Determine what markup to use.

            String listSuffix, itemPrefix, itemSuffix;
            ListDecoration decoration = Control.Decoration;
            bool insideStyle = true;

            // We know that for table tag, outer style doesn't carry over
            // into inside tags so style state needs to be reset.
            // For other cases, we enter the style here once and exit at the
            // end once.
            if (decoration != ListDecoration.None || !Device.Tables)
            {
                writer.EnterStyle(Style);
                insideStyle = false;
            }

            switch (decoration)
            {
                case ListDecoration.Bulleted:
                    writer.WriteLine("<ul>");
                    listSuffix = "</ul>";
                    itemPrefix = "<li>";
                    itemSuffix = "</li>";

                    if (!Device.RendersBreaksAfterHtmlLists)
                    {
                        listSuffix += "<br>";
                    }
                    break;
                case ListDecoration.Numbered:
                    if (pageStart == 0)
                    {
                        writer.WriteLine("<ol>");
                    }
                    else
                    {
                        writer.Write("<ol start=\"");
                        writer.Write(pageStart + 1);
                        writer.WriteLine("\">");
                    }
                    listSuffix = "</ol>";
                    itemPrefix = "<li>";
                    itemSuffix = "</li>";

                    if (!Device.RendersBreaksAfterHtmlLists)
                    {
                        listSuffix += "<br>";
                    }
                    break;
                default:
                    if (Device.Tables)
                    {
                        listSuffix = "</table>";
                        Style.Wrapping = Wrapping.NotSet;
                        writer.EnterLayout(Style);
                        writer.WriteLine("<table>");
                        if(wrap == Wrapping.NoWrap)
                        {
                            itemPrefix = "<tr nowrap><td>";
                        }
                        else
                        {
                            itemPrefix = "<tr><td>";
                        }
                        itemSuffix = "</td></tr>";
                    }
                    else
                    {
                        listSuffix = String.Empty;
                        itemPrefix = String.Empty;
                        itemSuffix = "<br>";
                    }
                    break;
            }

            bool hasCmdHandler = Control.HasItemCommandHandler;

            for (int i = 0; i < pageSize; i++)
            {
                MobileListItem item = items[pageStart + i];
                writer.Write(itemPrefix);

                if(insideStyle)
                {
                    writer.BeginStyleContext();
                    writer.EnterFormat(Style);
                }

                if(Control.ItemsAsLinks)
                {
                    RenderBeginLink(writer, item.Value);
                }
                else if(hasCmdHandler) 
                {
                    writer.WriteBeginTag("a");
                    RenderPostBackEventAsAttribute(writer, "href", item.Index.ToString(CultureInfo.InvariantCulture));
                    writer.Write(">");
                } 
                writer.WriteEncodedText(item.Text);
                
                if (hasCmdHandler || Control.ItemsAsLinks)
                {
                    RenderEndLink(writer);
                }

                if(insideStyle)
                {
                    writer.ExitFormat(Style);
                    writer.EndStyleContext();
                }
                writer.WriteLine(itemSuffix);
            }

            if (listSuffix == null || listSuffix.Length > 0)
            {
                writer.WriteLine(listSuffix);
            }

            if (decoration != ListDecoration.None || !Device.Tables)
            {
                writer.ExitStyle(Style);
            }
            else
            {
                writer.ExitLayout(Style);
                Style.Wrapping = wrap;
            }
        }
        /// <include file='doc\HtmlCommandAdapter.uex' path='docs/doc[@for="HtmlCommandAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            bool renderLink  = false;
            bool renderImage = false;

            // If image is defined and renderable, just do it.  Otherwise,
            // render as a link if specified.
            if (!String.IsNullOrEmpty(Control.ImageUrl) &&
                Device.SupportsImageSubmit)
            {
                renderImage = true;
            }
            else if (Control.Format == CommandFormat.Link &&
                     Device.JavaScript)
            {
                renderLink = true;
            }


            if (renderLink)
            {
                writer.EnterStyle(Style);
                Form form = Control.Form;
                if (form.Action.Length > 0)
                {
                    writer.Write("<a href=\"javascript:document.");
                    writer.Write(form.ClientID);
                    writer.Write(".submit()\"");
                    AddAttributes(writer);
                    writer.Write(">");
                    writer.WriteText(Control.Text, true);
                    writer.WriteEndTag("a");
                }
                else
                {
                    RenderBeginLink(writer, Constants.FormIDPrefix + form.UniqueID);
                    writer.WriteText(Control.Text, true);
                    RenderEndLink(writer);
                }
                writer.ExitStyle(Style, Control.BreakAfter);
            }
            else
            {
                writer.EnterLayout(Style);
                writer.WriteBeginTag("input");
                writer.WriteAttribute("name", Control.UniqueID);

                if (renderImage)
                {
                    writer.WriteAttribute("type", "image");
                    writer.WriteAttribute("src", Control.ResolveUrl(Control.ImageUrl), true);
                    writer.WriteAttribute("alt", Control.Text, true);
                }
                else
                {
                    writer.WriteAttribute("type", "submit");
                    writer.Write(" value=\"");
                    writer.WriteText(Control.Text, true);
                    writer.Write("\"");
                }

                AddAttributes(writer);
                writer.Write("/>");
                writer.ExitLayout(Style, Control.BreakAfter);
            }
        }
        /// <include file='doc\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);
        }
        public override void Render(HtmlMobileTextWriter writer)
        {
            writer.EnterStyle(Style);

            IPanelPane activePane = Control.ActivePane;
            writer.Write("[ ");
            int index = 0;
            foreach (IPanelPane child in Control.Controls)
            {
                if (!((Control) child).Visible)
                {
                    index++;
                    continue;
                }
                if (index > 0)
                {
                    writer.Write(" | ");
                }

                if (child == activePane)
                {
                    writer.Write("<b>");
                    writer.WriteText(child.Title, true);
                    writer.Write("</b>");
                }
                else
                {
                    writer.WriteBeginTag("a");
                    RenderPostBackEventAsAttribute(writer, "href", index.ToString());
                    writer.Write(">");
                    writer.WriteText(child.Title, true);
                    writer.WriteEndTag("a");
                }

                index++;
            }
            writer.Write(" ]");
            writer.WriteBreak();
            ((Control) activePane).RenderControl(writer);

            writer.ExitStyle(Style);
        }
        /// <include file='doc\HtmlCommandAdapter.uex' path='docs/doc[@for="HtmlCommandAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            bool renderLink = false;
            bool renderImage = false;

            // If image is defined and renderable, just do it.  Otherwise,
            // render as a link if specified.
            if (!String.IsNullOrEmpty(Control.ImageUrl) &&
                Device.SupportsImageSubmit)
            {
                renderImage = true;
            }
            else if (Control.Format == CommandFormat.Link &&
                     Device.JavaScript)
            {
                renderLink = true;
            }


            if (renderLink)
            {
                writer.EnterStyle(Style);
                Form form = Control.Form;
                if (form.Action.Length > 0)
                {
                    writer.Write("<a href=\"javascript:document.");
                    writer.Write(form.ClientID);
                    writer.Write(".submit()\"");
                    AddAttributes(writer);
                    writer.Write(">");
                    writer.WriteText(Control.Text, true);
                    writer.WriteEndTag("a");
                }
                else
                {
                    RenderBeginLink(writer, Constants.FormIDPrefix + form.UniqueID);
                    writer.WriteText(Control.Text, true);
                    RenderEndLink(writer);
                }
                writer.ExitStyle(Style, Control.BreakAfter);
            }
            else
            {
                writer.EnterLayout(Style);
                writer.WriteBeginTag("input");
                writer.WriteAttribute("name", Control.UniqueID);

                if (renderImage)
                {
                    writer.WriteAttribute("type", "image");
                    writer.WriteAttribute("src", Control.ResolveUrl(Control.ImageUrl), true);
                    writer.WriteAttribute("alt", Control.Text, true);
                }
                else
                {
                    writer.WriteAttribute("type", "submit");
                    writer.Write(" value=\"");
                    writer.WriteText(Control.Text, true);
                    writer.Write("\"");
                }

                AddAttributes(writer);
                writer.Write("/>");
                writer.ExitLayout(Style, Control.BreakAfter);
            }

        }
        /// <include file='doc\HtmlPhoneCallAdapter.uex' path='docs/doc[@for="HtmlPhoneCallAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            writer.EnterStyle(Style);
            if (Device.CanInitiateVoiceCall)
            {
                String text = Control.Text;
                String phoneNumber = Control.PhoneNumber;

                if (String.IsNullOrEmpty(text))
                {
                    text = phoneNumber;
                }

                writer.WriteBeginTag("a");
                writer.Write(" href=\"tel:");

                foreach (char ch in phoneNumber)
                {
                    if (ch >= '0' && ch <= '9' || ch == '#' || ch=='+')
                    {
                        writer.Write(ch);
                    }
                }
                writer.Write("\"");
                AddAttributes(writer);
                writer.Write(">");
                writer.WriteText(text, true);
                writer.WriteEndTag("a");
            }
            else
            {
                // Format the text string based on properties
                String text = String.Format(CultureInfo.CurrentCulture, Control.AlternateFormat, Control.Text,
                                            Control.PhoneNumber);
                String url = Control.AlternateUrl;

                // If URI specified, create a link.  Otherwise, only text is displayed.
                if (!String.IsNullOrEmpty(url))
                {
                    RenderBeginLink(writer, url);
                    writer.WriteText(text, true);
                    RenderEndLink(writer);
                }
                else
                {
                    writer.WriteText(text, true);
                }
            }
            writer.ExitStyle(Style, Control.BreakAfter);
        }
        private void RenderItemsListWithoutTableTags(HtmlMobileTextWriter writer)
        {
            int startIndex = Control.FirstVisibleItemIndex;
            int pageSize   = Control.VisibleItemCount;
            ObjectListItemCollection   items     = Control.Items;
            IObjectListFieldCollection allFields = Control.AllFields;
            int count = allFields.Count;

            int nextStartIndex  = startIndex + pageSize;
            int labelFieldIndex = Control.LabelFieldIndex;


            Style style      = this.Style;
            Style labelStyle = Control.LabelStyle;

            writer.EnterStyle(labelStyle);
            writer.WriteText(Control.AllFields[labelFieldIndex].Title, true);
            writer.ExitStyle(labelStyle, true);

            bool hasDefaultCommand     = HasDefaultCommand();
            bool onlyHasDefaultCommand = OnlyHasDefaultCommand();
            bool requiresDetailsScreen = !onlyHasDefaultCommand && HasCommands();

            // if there is > 1 visible field, need a details screen
            for (int visibleFields = 0, i = 0; !requiresDetailsScreen && i < count; i++)
            {
                visibleFields        += allFields[i].Visible ? 1 : 0;
                requiresDetailsScreen =
                    requiresDetailsScreen || visibleFields > 1;
            }
            bool itemRequiresHyperlink  = requiresDetailsScreen || hasDefaultCommand;
            bool itemRequiresMoreButton = requiresDetailsScreen && hasDefaultCommand;


            Style subCommandStyle = Control.CommandStyle;

            subCommandStyle.Alignment = style.Alignment;
            subCommandStyle.Wrapping  = style.Wrapping;

            writer.EnterStyle(style);
            for (int i = startIndex; i < nextStartIndex; i++)
            {
                ObjectListItem item = items[i];

                if (itemRequiresHyperlink)
                {
                    RenderPostBackEventAsAnchor(writer,
                                                hasDefaultCommand ?
                                                item.Index.ToString(CultureInfo.InvariantCulture) :
                                                String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index),
                                                item[labelFieldIndex]);
                }
                else
                {
                    writer.WriteText(item[labelFieldIndex], true);
                }

                if (itemRequiresMoreButton)
                {
                    BooleanOption cachedItalic = subCommandStyle.Font.Italic;
                    subCommandStyle.Font.Italic = BooleanOption.False;
                    writer.EnterFormat(subCommandStyle);
                    writer.Write(" [");
                    writer.ExitFormat(subCommandStyle);
                    subCommandStyle.Font.Italic = cachedItalic;
                    writer.EnterFormat(subCommandStyle);
                    String moreText = Control.MoreText.Length == 0 ?
                                      GetDefaultLabel(MoreLabel) :
                                      Control.MoreText;
                    writer.WriteBeginTag("a");
                    RenderPostBackEventAsAttribute(writer, "href", String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index));
                    writer.Write(">");
                    writer.WriteText(moreText, true);
                    writer.WriteEndTag("a");
                    writer.ExitFormat(subCommandStyle);
                    subCommandStyle.Font.Italic = BooleanOption.False;
                    writer.EnterFormat(subCommandStyle);
                    writer.Write("]");
                    writer.ExitFormat(subCommandStyle);
                    subCommandStyle.Font.Italic = cachedItalic;
                }

                if (i < (nextStartIndex - 1))
                {
                    writer.WriteBreak();
                }
            }
            writer.ExitStyle(style, Control.BreakAfter);
        }
        /// <include file='doc\ChtmlSelectionListAdapter.uex' path='docs/doc[@for="ChtmlSelectionListAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            ListSelectType selectType = Control.SelectType;

            if (selectType == ListSelectType.MultiSelectListBox &&
                Device.SupportsSelectMultiple == false)
            {
                // Render occurs after SaveViewState.  Here we make a temp
                // change which is not persisted to the view state.
                Control.SelectType = selectType = ListSelectType.CheckBox;
            }

            if (!Device.RequiresUniqueHtmlCheckboxNames ||
                selectType != ListSelectType.CheckBox)
            {
                base.Render(writer);
            }
            else
            {
                MobileListItemCollection items = Control.Items;
                if (items.Count == 0)
                {
                    return;
                }
                writer.EnterStyle(Style);
                bool writeBreak = false;
                foreach (MobileListItem item in items)
                {
                    int index = items.IndexOf(item);
                    if (writeBreak)
                    {
                        writer.WriteBreak();
                    }

                    writer.Write("<input type=\"checkbox\" name=\"");
                    if (Device.RequiresAttributeColonSubstitution)
                    {
                        writer.Write(Control.UniqueID.Replace(':', ','));
                    }
                    else
                    {
                        writer.Write(Control.UniqueID);
                    }
                    writer.Write(Constants.SelectionListSpecialCharacter);
                    writer.Write(index);
                    writer.Write("\" value=\"");
                    if (!String.IsNullOrEmpty(Control.Form.Action))
                    {
                        writer.WriteEncodedText(item.Value);
                    }
                    else
                    {
                        writer.Write(item.Index.ToString(CultureInfo.InvariantCulture));
                    }
                    if (item.Selected &&
                        Device.SupportsUncheck)
                    {
                        writer.Write("\" checked>");
                    }
                    else
                    {
                        writer.Write("\">");
                    }

                    writer.WriteText(item.Text, true);
                    writeBreak = true;
                }
                writer.ExitStyle(Style, Control.BreakAfter);
            }
        }
        private void RenderItemDetailsWithoutTableTags(HtmlMobileTextWriter writer, ObjectListItem item)
        {
            Style style           = this.Style;
            Style labelStyle      = Control.LabelStyle;
            Style subCommandStyle = Control.CommandStyle;

            writer.EnterStyle(labelStyle);
            writer.WriteText(item[Control.LabelFieldIndex], true);
            writer.ExitStyle(labelStyle, true);

            IObjectListFieldCollection fields = Control.AllFields;
            int  fieldIndex  = 0;
            bool boldInStyle =
                (style.Font.Bold == BooleanOption.True) ? true : false;

            writer.EnterStyle(style);
            foreach (ObjectListField field in fields)
            {
                if (field.Visible)
                {
                    if (!boldInStyle)
                    {
                        writer.Write("<b>");
                    }
                    writer.WriteText(field.Title + ":", true);
                    if (!boldInStyle)
                    {
                        writer.Write("</b>");
                    }
                    writer.Write("&nbsp;");
                    writer.WriteText(item[fieldIndex], true);
                    writer.WriteBreak();
                }
                fieldIndex++;
            }
            writer.ExitStyle(style);

            BooleanOption cachedItalic = subCommandStyle.Font.Italic;

            subCommandStyle.Font.Italic = BooleanOption.False;
            writer.EnterStyle(subCommandStyle);
            writer.Write("[&nbsp;");
            writer.ExitStyle(subCommandStyle);
            subCommandStyle.Font.Italic = cachedItalic;
            writer.EnterStyle(subCommandStyle);

            ObjectListCommandCollection commands = Control.Commands;

            foreach (ObjectListCommand command in commands)
            {
                RenderPostBackEventAsAnchor(writer, command.Name, command.Text, subCommandStyle);
                writer.Write("&nbsp;|&nbsp;");
            }
            String backCommandText = Control.BackCommandText.Length == 0 ?
                                     GetDefaultLabel(BackLabel) :
                                     Control.BackCommandText;

            RenderPostBackEventAsAnchor(writer, BackToList, backCommandText, subCommandStyle);
            writer.ExitStyle(subCommandStyle);
            subCommandStyle.Font.Italic = BooleanOption.False;
            writer.EnterStyle(subCommandStyle);
            writer.Write("&nbsp;]");
            writer.ExitStyle(subCommandStyle, Control.BreakAfter);
            subCommandStyle.Font.Italic = cachedItalic;
        }
        /// <include file='doc\HtmlSelectionListAdapter.uex' path='docs/doc[@for="HtmlSelectionListAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            MobileListItemCollection items      = Control.Items;
            ListSelectType           selectType = Control.SelectType;

            if (items.Count == 0 &&
                selectType != ListSelectType.ListBox &&
                selectType != ListSelectType.MultiSelectListBox)
            {
                return;
            }

            int    selectedIndex = Control.SelectedIndex;
            String renderName;

            if (Device.RequiresAttributeColonSubstitution)
            {
                renderName = Control.UniqueID.Replace(':', ',');
            }
            else
            {
                renderName = Control.UniqueID;
            }

            switch (selectType)
            {
            case ListSelectType.DropDown:
            case ListSelectType.ListBox:
            case ListSelectType.MultiSelectListBox:

                if (items.Count == 0 && !Device.CanRenderEmptySelects)
                {
                    break;
                }

                writer.EnterLayout(Style);
                writer.WriteBeginTag("select");

                if (selectType == ListSelectType.MultiSelectListBox)
                {
                    writer.Write(" multiple");
                }

                if (selectType == ListSelectType.ListBox || selectType == ListSelectType.MultiSelectListBox)
                {
                    writer.WriteAttribute("size", Control.Rows.ToString(CultureInfo.InvariantCulture));
                }

                writer.WriteAttribute("name", renderName);
                writer.Write(">");

                for (int itemIndex = 0; itemIndex < items.Count; itemIndex++)
                {
                    MobileListItem item = items[itemIndex];
                    writer.WriteBeginTag("option");
                    WriteItemValueAttribute(writer, itemIndex, item.Value);
                    if (item.Selected && (Control.IsMultiSelect || itemIndex == selectedIndex))
                    {
                        writer.Write(" selected>");
                    }
                    else
                    {
                        writer.Write(">");
                    }
                    writer.WriteEncodedText(item.Text);
                    writer.WriteLine("");
                }
                writer.Write("</select>");

                if (Device.HidesRightAlignedMultiselectScrollbars &&
                    selectType == ListSelectType.MultiSelectListBox)
                {
                    // nested if for perf
                    if ((Alignment)Style[Style.AlignmentKey, true] == Alignment.Right)
                    {
                        writer.Write("&nbsp;&nbsp;&nbsp;&nbsp;");
                    }
                }
                writer.WriteLine("");

                if (!Page.DesignMode)
                {
                    writer.ExitLayout(Style, Control.BreakAfter);
                }
                else
                {
                    writer.ExitLayout(Style, false);
                }
                break;

            case ListSelectType.Radio:
            case ListSelectType.CheckBox:

                String selectTypeString =
                    (selectType == ListSelectType.Radio) ?
                    "radio" :
                    "checkbox";
                Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];
                if (!Device.Tables || alignment == Alignment.Left || alignment == Alignment.NotSet)
                {
                    writer.EnterStyle(Style);
                    bool breakAfter = false;
                    for (int itemIndex = 0; itemIndex < items.Count; itemIndex++)
                    {
                        if (breakAfter)
                        {
                            writer.WriteBreak();
                        }
                        MobileListItem item = items[itemIndex];

                        writer.WriteBeginTag("input");
                        writer.WriteAttribute("type", selectTypeString);
                        writer.WriteAttribute("name", renderName);
                        WriteItemValueAttribute(writer, itemIndex, item.Value);
                        if (item.Selected &&
                            (Control.IsMultiSelect || itemIndex == selectedIndex) &&
                            Device.SupportsUncheck)
                        {
                            writer.Write(" checked>");
                        }
                        else
                        {
                            writer.Write(">");
                        }
                        writer.WriteEncodedText(item.Text);
                        breakAfter = true;
                    }
                    writer.ExitStyle(Style, Control.BreakAfter);
                }
                else     // Device supports tables and alignment is non default.
                {
                    Wrapping wrapping = (Wrapping)Style[Style.WrappingKey, true];
                    bool     nowrap   = (wrapping == Wrapping.NoWrap);

                    writer.EnterLayout(Style);
                    writer.WriteFullBeginTag("table");
                    writer.BeginStyleContext();
                    for (int itemIndex = 0; itemIndex < items.Count; itemIndex++)
                    {
                        MobileListItem item = items[itemIndex];
                        writer.WriteFullBeginTag("tr");
                        writer.WriteBeginTag("td");
                        if (nowrap)
                        {
                            writer.WriteAttribute("nowrap", "true");
                        }
                        writer.Write(">");

                        writer.WriteBeginTag("input");
                        writer.WriteAttribute("type", selectTypeString);
                        writer.WriteAttribute("name", renderName);
                        WriteItemValueAttribute(writer, itemIndex, item.Value);
                        if (item.Selected &&
                            (Control.IsMultiSelect || itemIndex == selectedIndex) &&
                            Device.SupportsUncheck)
                        {
                            writer.Write(" checked>");
                        }
                        else
                        {
                            writer.Write(">");
                        }

                        writer.MarkStyleContext();
                        writer.EnterFormat(Style);
                        writer.WriteEncodedText(item.Text);
                        writer.ExitFormat(Style);
                        writer.UnMarkStyleContext();
                        writer.WriteEndTag("td");
                        writer.WriteEndTag("tr");
                    }
                    writer.WriteEndTag("table");
                    writer.EndStyleContext();
                    writer.ExitFormat(Style, Control.BreakAfter);
                }
                break;
            }
        }
Example #32
0
        private void RenderItemDetailsWithTableTags(HtmlMobileTextWriter writer, ObjectListItem item)
        {
            Style style1 = base.Style;
            Style style2 = Control.LabelStyle;
            Style style3 = Control.CommandStyle;
            Color color  = (Color)style1[Style.ForeColorKey, true];

            writer.Write("<table border=0 width=\"100%\">\r\n<tr><td colspan=2>");
            writer.BeginStyleContext();
            writer.EnterStyle(style2);
            writer.WriteText(item[Control.LabelFieldIndex], true);
            writer.ExitStyle(style2);
            writer.EndStyleContext();
            writer.Write("</td></tr>\r\n<tr>");
            RenderRule(writer, color, 2);
            IObjectListFieldCollection iObjectListFieldCollection = Control.AllFields;
            int         i           = 0;
            IEnumerator iEnumerator = iObjectListFieldCollection.GetEnumerator();

            while (iEnumerator.MoveNext())
            {
                ObjectListField objectListField = (ObjectListField)iEnumerator.Current;
                if (objectListField.Visible)
                {
                    writer.Write("<tr><td>");
                    writer.BeginStyleContext();
                    writer.EnterStyle(base.Style);
                    writer.WriteText(objectListField.Title, true);
                    writer.ExitStyle(base.Style);
                    writer.EndStyleContext();
                    writer.Write("</td><td>");
                    writer.BeginStyleContext();
                    writer.EnterStyle(style1);
                    if (objectListField.Name == "CALL")
                    {
                        writer.WriteText(HtmlcheckPhonenumber(item[i]), false);
                    }
                    else if (objectListField.Name == "MAIL")
                    {
                        writer.WriteText(HtmlMail(item[i]), false);
                    }
                    else
                    {
                        writer.WriteText(item[i], false);
                    }
                    writer.ExitStyle(style1);
                    writer.EndStyleContext();
                    writer.Write("</td></tr>\r\n");
                }
                i++;
            }
            RenderRule(writer, color, 2);
            writer.Write("<tr><td colspan=2>");
            writer.BeginStyleContext();
            BooleanOption booleanOption = style3.Font.Italic;

            style3.Font.Italic = BooleanOption.False;
            writer.EnterStyle(style3);
            writer.Write("[&nbsp;");
            writer.ExitStyle(style3);
            style3.Font.Italic = booleanOption;
            writer.EnterStyle(style3);
            iEnumerator = Control.Commands.GetEnumerator();
            while (iEnumerator.MoveNext())
            {
                ObjectListCommand objectListCommand = (ObjectListCommand)iEnumerator.Current;
                RenderPostBackEventAsAnchor(writer, objectListCommand.Name, objectListCommand.Text, style3);
                writer.Write("&nbsp;|&nbsp;");
            }

            string str = (Control.BackCommandText != String.Empty) ? Control.BackCommandText : base.GetDefaultLabel(ControlAdapter.BackLabel);

            RenderPostBackEventAsAnchor(writer, BackToList, str, style3);
            writer.ExitStyle(style3);
            style3.Font.Italic = BooleanOption.False;
            writer.EnterStyle(style3);
            writer.Write("&nbsp;]");
            writer.ExitStyle(style3);
            style3.Font.Italic = booleanOption;
            writer.EndStyleContext();
            writer.Write("</td></tr></table>");
        }
        private void RenderElement(HtmlMobileTextWriter writer, int index, int begin, int end)
        {
            TextViewElement element = Control.GetElement(index);
            if (end == -1)
            {
                end = element.Text.Length;
            }

            String text = element.Text;
            if (begin > 0 || end < text.Length)
            {
                text = text.Substring(begin, end - begin);
            }

            BooleanOption previousBold   = Style.Font.Bold;
            BooleanOption previousItalic = Style.Font.Italic;
            if (element.IsBold)
            {
                Style.Font.Bold = BooleanOption.True;
            }
            if (element.IsItalic)
            {
                Style.Font.Italic = BooleanOption.True;
            }
            
            writer.EnterStyle(Style);
            if (element.Url != null)
            {
                RenderBeginLink(writer, element.Url);
                writer.WriteText(text, true);
                RenderEndLink(writer);
            }
            else
            {
                writer.WriteText(text, true);
            }
            writer.ExitStyle(Style, element.BreakAfter);

            Style.Font.Bold   = previousBold;
            Style.Font.Italic = previousItalic;
        }
        private void RenderItemDetailsWithTableTags(HtmlMobileTextWriter writer, ObjectListItem item)
        {
            Style style = this.Style;
            Style labelStyle = Control.LabelStyle;
            Style subCommandStyle = Control.CommandStyle;
            Color foreColor = (Color)style[Style.ForeColorKey, true];

            writer.Write("<table border=0 width=\"100%\">\r\n<tr><td colspan=2>");
            writer.BeginStyleContext();
            writer.EnterStyle(labelStyle);
            writer.WriteText(item[Control.LabelFieldIndex], true);
            writer.ExitStyle(labelStyle);
            writer.EndStyleContext();
            writer.Write("</td></tr>\r\n<tr>");
            RenderRule(writer, foreColor, 2);

            IObjectListFieldCollection fields = Control.AllFields;
            int fieldIndex = 0;

            foreach (ObjectListField field in fields)
            {
                if (field.Visible)
                {
                    writer.Write("<tr><td>");
                    writer.BeginStyleContext();
                    writer.EnterStyle(Style);
                    writer.WriteText(field.Title, true);
                    writer.ExitStyle(Style);
                    writer.EndStyleContext();
                    writer.Write("</td><td>");
                    writer.BeginStyleContext();
                    writer.EnterStyle(style);
                    writer.WriteText(item[fieldIndex], true);
                    writer.ExitStyle(style);
                    writer.EndStyleContext();
                    writer.Write("</td></tr>\r\n");
                }
                fieldIndex++;
            }

            RenderRule(writer, foreColor, 2);

            writer.Write("<tr><td colspan=2>");
            writer.BeginStyleContext();
            BooleanOption cachedItalic = subCommandStyle.Font.Italic;
            subCommandStyle.Font.Italic = BooleanOption.False;
            writer.EnterStyle(subCommandStyle);
            writer.Write("[&nbsp;");
            writer.ExitStyle(subCommandStyle);
            subCommandStyle.Font.Italic = cachedItalic;
            writer.EnterStyle(subCommandStyle);

            ObjectListCommandCollection commands = Control.Commands;

            foreach (ObjectListCommand command in commands)
            {
                RenderPostBackEventAsAnchor(writer, command.Name, command.Text, subCommandStyle);
                writer.Write("&nbsp;|&nbsp;");
            }
            String backCommandText = Control.BackCommandText.Length == 0 ?
                GetDefaultLabel(BackLabel) :
                Control.BackCommandText;

            RenderPostBackEventAsAnchor(writer, BackToList, backCommandText, subCommandStyle);
            writer.ExitStyle(subCommandStyle);
            subCommandStyle.Font.Italic = BooleanOption.False;
            writer.EnterStyle(subCommandStyle);
            writer.Write("&nbsp;]");
            writer.ExitStyle(subCommandStyle);
            subCommandStyle.Font.Italic = cachedItalic;

            writer.EndStyleContext();
            writer.Write("</td></tr></table>");
        }
        /// <include file='doc\ChtmlSelectionListAdapter.uex' path='docs/doc[@for="ChtmlSelectionListAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            ListSelectType selectType = Control.SelectType;
            if (selectType == ListSelectType.MultiSelectListBox && 
                Device.SupportsSelectMultiple == false)
            {
                // Render occurs after SaveViewState.  Here we make a temp
                // change which is not persisted to the view state.
                Control.SelectType = selectType = ListSelectType.CheckBox;
            }

            if (!Device.RequiresUniqueHtmlCheckboxNames ||
                selectType != ListSelectType.CheckBox)
            {
                base.Render(writer);
            }
            else
            { 
                MobileListItemCollection items = Control.Items;
                if (items.Count == 0)
                {
                    return;
                }
                writer.EnterStyle(Style);
                bool writeBreak = false;
                foreach (MobileListItem item in items)
                {
                    int index = items.IndexOf(item);
                    if(writeBreak)
                    {
                        writer.WriteBreak();
                    }

                    writer.Write("<input type=\"checkbox\" name=\"");
                    if(Device.RequiresAttributeColonSubstitution)
                    {
                        writer.Write(Control.UniqueID.Replace(':', ','));
                    }
                    else
                    {
                        writer.Write(Control.UniqueID);
                    }
                    writer.Write(Constants.SelectionListSpecialCharacter);
                    writer.Write(index);
                    writer.Write("\" value=\"");
                    if (!String.IsNullOrEmpty(Control.Form.Action))
                    {
                        writer.WriteEncodedText(item.Value);
                    }
                    else
                    {
                        writer.Write(item.Index.ToString(CultureInfo.InvariantCulture));
                    }
                    if (item.Selected &&
                        Device.SupportsUncheck)
                    {
                        writer.Write("\" checked>");
                    }
                    else
                    {
                        writer.Write("\">");
                    }

                    writer.WriteText(item.Text, true);
                    writeBreak = true;
                }
                writer.ExitStyle(Style, Control.BreakAfter);
            }
        }
        private void RenderItemDetailsWithoutTableTags(HtmlMobileTextWriter writer, ObjectListItem item)
        {
            Style style = this.Style;
            Style labelStyle = Control.LabelStyle;
            Style subCommandStyle = Control.CommandStyle;

            writer.EnterStyle(labelStyle);
            writer.WriteText(item[Control.LabelFieldIndex], true);
            writer.ExitStyle(labelStyle, true);

            IObjectListFieldCollection fields = Control.AllFields;
            int fieldIndex = 0;
            bool boldInStyle =
                (style.Font.Bold == BooleanOption.True) ? true : false;

            writer.EnterStyle(style);
            foreach (ObjectListField field in fields)
            {
                if (field.Visible)
                {
                    if (!boldInStyle)
                    {
                        writer.Write("<b>");
                    }
                    writer.WriteText(field.Title + ":", true);
                    if (!boldInStyle)
                    {
                        writer.Write("</b>");
                    }
                    writer.Write("&nbsp;");
                    writer.WriteText(item[fieldIndex], true);
                    writer.WriteBreak();
                }
                fieldIndex++;
            }
            writer.ExitStyle(style);

            BooleanOption cachedItalic = subCommandStyle.Font.Italic;
            subCommandStyle.Font.Italic = BooleanOption.False;
            writer.EnterStyle(subCommandStyle);
            writer.Write("[&nbsp;");
            writer.ExitStyle(subCommandStyle);
            subCommandStyle.Font.Italic = cachedItalic;
            writer.EnterStyle(subCommandStyle);

            ObjectListCommandCollection commands = Control.Commands;
            foreach (ObjectListCommand command in commands)
            {
                RenderPostBackEventAsAnchor(writer, command.Name, command.Text, subCommandStyle);
                writer.Write("&nbsp;|&nbsp;");
            }
            String backCommandText = Control.BackCommandText.Length == 0 ?
                GetDefaultLabel(BackLabel) :
                Control.BackCommandText;

            RenderPostBackEventAsAnchor(writer, BackToList, backCommandText, subCommandStyle);
            writer.ExitStyle(subCommandStyle);
            subCommandStyle.Font.Italic = BooleanOption.False;
            writer.EnterStyle(subCommandStyle);
            writer.Write("&nbsp;]");
            writer.ExitStyle(subCommandStyle, Control.BreakAfter);
            subCommandStyle.Font.Italic = cachedItalic;
        }
        private void RenderItemsListWithTableTags(HtmlMobileTextWriter writer)
        {
            int pageStart = Control.FirstVisibleItemIndex;
            int pageSize  = Control.VisibleItemCount;
            ObjectListItemCollection items = Control.Items;

            // Determine how to render.
            bool shouldRenderAsTable    = ShouldRenderAsTable();
            bool hasDefaultCommand      = HasDefaultCommand();
            bool onlyHasDefaultCommand  = OnlyHasDefaultCommand();
            bool requiresDetailsScreen  = HasItemDetails() || (!onlyHasDefaultCommand && HasCommands());
            bool itemRequiresHyperlink  = requiresDetailsScreen || hasDefaultCommand;
            bool itemRequiresMoreButton = requiresDetailsScreen && hasDefaultCommand;

            int fieldCount;

            int[] fieldIndices = new int[] {};
            if (shouldRenderAsTable)
            {
                fieldIndices = Control.TableFieldIndices;
            }
            Debug.Assert(fieldIndices != null, "fieldIndices is null");
            fieldCount = fieldIndices.Length;

            if (fieldCount == 0)
            {
                fieldIndices    = new int[1];
                fieldIndices[0] = Control.LabelFieldIndex;
                fieldCount      = 1;
            }

            Style style           = this.Style;
            Style subCommandStyle = Control.CommandStyle;
            Style labelStyle      = Control.LabelStyle;
            Color foreColor       = (Color)style[Style.ForeColorKey, true];

            writer.BeginStyleContext();
            writer.WriteLine("<table border=0 width=\"100%\">\r\n<tr>");
            for (int field = 0; field < fieldCount; field++)
            {
                writer.Write("<td>");
                writer.BeginStyleContext();
                writer.EnterStyle(labelStyle);
                writer.WriteText(Control.AllFields[fieldIndices[field]].Title, true);
                writer.ExitStyle(labelStyle);
                writer.EndStyleContext();
                writer.Write("</td>");
            }
            if (itemRequiresMoreButton)
            {
                writer.WriteLine("<td/>");
            }
            writer.WriteLine("\r\n</tr>");
            RenderRule(writer, foreColor, fieldCount + 1);

            for (int i = 0; i < pageSize; i++)
            {
                ObjectListItem item = items[pageStart + i];
                writer.WriteLine("<tr>");
                for (int field = 0; field < fieldCount; field++)
                {
                    writer.Write("<td>");
                    if (field == 0 && itemRequiresHyperlink)
                    {
                        writer.BeginStyleContext();
                        writer.EnterStyle(style);
                        String eventArgument =
                            hasDefaultCommand ?
                            item.Index.ToString(CultureInfo.InvariantCulture) :
                            String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index.ToString(CultureInfo.InvariantCulture));
                        RenderPostBackEventAsAnchor(writer,
                                                    eventArgument,
                                                    item[fieldIndices[0]]);
                        writer.ExitStyle(style);
                        writer.EndStyleContext();
                    }
                    else
                    {
                        writer.BeginStyleContext();
                        writer.EnterStyle(style);
                        writer.WriteText(item[fieldIndices[field]], true);
                        writer.ExitStyle(style);
                        writer.EndStyleContext();
                    }
                    writer.WriteLine("</td>");
                }

                if (itemRequiresMoreButton)
                {
                    writer.Write("<td align=right>");
                    writer.BeginStyleContext();
                    writer.EnterFormat(subCommandStyle);
                    String moreText = Control.MoreText.Length == 0 ?
                                      GetDefaultLabel(MoreLabel) :
                                      Control.MoreText;
                    RenderPostBackEventAsAnchor(writer,
                                                String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index),
                                                moreText,
                                                subCommandStyle);
                    writer.ExitFormat(subCommandStyle);
                    writer.EndStyleContext();
                    writer.Write("</td>\r\n");
                }

                writer.WriteLine("</tr>");
            }

            RenderRule(writer, foreColor, fieldCount + 1);

            writer.Write("</table>\r\n");
            writer.EndStyleContext();
        }
        /// <include file='doc\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");
        }
        private void RenderItemDetailsWithTableTags(HtmlMobileTextWriter writer, ObjectListItem item)
        {
            Style style           = this.Style;
            Style labelStyle      = Control.LabelStyle;
            Style subCommandStyle = Control.CommandStyle;
            Color foreColor       = (Color)style[Style.ForeColorKey, true];

            writer.Write("<table border=0 width=\"100%\">\r\n<tr><td colspan=2>");
            writer.BeginStyleContext();
            writer.EnterStyle(labelStyle);
            writer.WriteText(item[Control.LabelFieldIndex], true);
            writer.ExitStyle(labelStyle);
            writer.EndStyleContext();
            writer.Write("</td></tr>\r\n<tr>");
            RenderRule(writer, foreColor, 2);

            IObjectListFieldCollection fields = Control.AllFields;
            int fieldIndex = 0;

            foreach (ObjectListField field in fields)
            {
                if (field.Visible)
                {
                    writer.Write("<tr><td>");
                    writer.BeginStyleContext();
                    writer.EnterStyle(Style);
                    writer.WriteText(field.Title, true);
                    writer.ExitStyle(Style);
                    writer.EndStyleContext();
                    writer.Write("</td><td>");
                    writer.BeginStyleContext();
                    writer.EnterStyle(style);
                    writer.WriteText(item[fieldIndex], true);
                    writer.ExitStyle(style);
                    writer.EndStyleContext();
                    writer.Write("</td></tr>\r\n");
                }
                fieldIndex++;
            }

            RenderRule(writer, foreColor, 2);

            writer.Write("<tr><td colspan=2>");
            writer.BeginStyleContext();
            BooleanOption cachedItalic = subCommandStyle.Font.Italic;

            subCommandStyle.Font.Italic = BooleanOption.False;
            writer.EnterStyle(subCommandStyle);
            writer.Write("[&nbsp;");
            writer.ExitStyle(subCommandStyle);
            subCommandStyle.Font.Italic = cachedItalic;
            writer.EnterStyle(subCommandStyle);

            ObjectListCommandCollection commands = Control.Commands;

            foreach (ObjectListCommand command in commands)
            {
                RenderPostBackEventAsAnchor(writer, command.Name, command.Text, subCommandStyle);
                writer.Write("&nbsp;|&nbsp;");
            }
            String backCommandText = Control.BackCommandText.Length == 0 ?
                                     GetDefaultLabel(BackLabel) :
                                     Control.BackCommandText;

            RenderPostBackEventAsAnchor(writer, BackToList, backCommandText, subCommandStyle);
            writer.ExitStyle(subCommandStyle);
            subCommandStyle.Font.Italic = BooleanOption.False;
            writer.EnterStyle(subCommandStyle);
            writer.Write("&nbsp;]");
            writer.ExitStyle(subCommandStyle);
            subCommandStyle.Font.Italic = cachedItalic;

            writer.EndStyleContext();
            writer.Write("</td></tr></table>");
        }
        private void RenderItemsListWithTableTags(HtmlMobileTextWriter writer)
        {
            int pageStart = Control.FirstVisibleItemIndex;
            int pageSize = Control.VisibleItemCount;
            ObjectListItemCollection items = Control.Items;

            // Determine how to render.
            bool shouldRenderAsTable = ShouldRenderAsTable();
            bool hasDefaultCommand = HasDefaultCommand();
            bool onlyHasDefaultCommand = OnlyHasDefaultCommand();
            bool requiresDetailsScreen = HasItemDetails() || (!onlyHasDefaultCommand && HasCommands());
            bool itemRequiresHyperlink = requiresDetailsScreen || hasDefaultCommand;
            bool itemRequiresMoreButton = requiresDetailsScreen && hasDefaultCommand;

            int fieldCount;
            int[] fieldIndices = new int[]{};
            if (shouldRenderAsTable)
            {
                fieldIndices = Control.TableFieldIndices;
            }
            Debug.Assert(fieldIndices != null, "fieldIndices is null");
            fieldCount = fieldIndices.Length;

            if(fieldCount == 0)
            {
                fieldIndices = new int[1];
                fieldIndices[0] = Control.LabelFieldIndex;
                fieldCount = 1;
            }

            Style style = this.Style;
            Style subCommandStyle = Control.CommandStyle;
            Style labelStyle = Control.LabelStyle;
            Color foreColor = (Color)style[Style.ForeColorKey, true];

            writer.BeginStyleContext();
            writer.WriteLine("<table border=0 width=\"100%\">\r\n<tr>");
            for (int field = 0; field < fieldCount; field++)
            {
                writer.Write("<td>");
                writer.BeginStyleContext();
                writer.EnterStyle(labelStyle);
                writer.WriteText(Control.AllFields[fieldIndices[field]].Title, true);
                writer.ExitStyle(labelStyle);
                writer.EndStyleContext();
                writer.Write("</td>");
            }
            if (itemRequiresMoreButton)
            {
                writer.WriteLine("<td/>");
            }
            writer.WriteLine("\r\n</tr>");
            RenderRule(writer, foreColor, fieldCount + 1);

            for (int i = 0; i < pageSize; i++)
            {
                ObjectListItem item = items[pageStart + i];
                writer.WriteLine("<tr>");
                for (int field = 0; field < fieldCount; field++)
                {
                    writer.Write("<td>");
                    if (field == 0 && itemRequiresHyperlink)
                    {
                        writer.BeginStyleContext();
                        writer.EnterStyle(style);
                        String eventArgument =
                            hasDefaultCommand ?
                                item.Index.ToString(CultureInfo.InvariantCulture) :
                                String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index.ToString(CultureInfo.InvariantCulture));
                        RenderPostBackEventAsAnchor(writer,
                            eventArgument,
                            item[fieldIndices[0]]);
                        writer.ExitStyle(style);
                        writer.EndStyleContext();
                    }
                    else
                    {
                        writer.BeginStyleContext();
                        writer.EnterStyle(style);
                        writer.WriteText(item[fieldIndices[field]], true);
                        writer.ExitStyle(style);
                        writer.EndStyleContext();
                    }
                    writer.WriteLine("</td>");
                }

                if (itemRequiresMoreButton)
                {
                    writer.Write("<td align=right>");
                    writer.BeginStyleContext();
                    writer.EnterFormat(subCommandStyle);
                    String moreText = Control.MoreText.Length == 0 ?
                        GetDefaultLabel(MoreLabel) :
                        Control.MoreText;
                    RenderPostBackEventAsAnchor(writer,
                        String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index), 
                        moreText,
                        subCommandStyle);
                    writer.ExitFormat(subCommandStyle);
                    writer.EndStyleContext();
                    writer.Write("</td>\r\n");
                }

                writer.WriteLine("</tr>");
            }

            RenderRule(writer, foreColor, fieldCount + 1);

            writer.Write("</table>\r\n");
            writer.EndStyleContext();
        }
        private void RenderItemsListWithoutTableTags(HtmlMobileTextWriter writer)
        {
            int startIndex = Control.FirstVisibleItemIndex;
            int pageSize = Control.VisibleItemCount;
            ObjectListItemCollection items = Control.Items;
            IObjectListFieldCollection allFields = Control.AllFields;
            int count = allFields.Count;
            
            int nextStartIndex =  startIndex + pageSize;
            int labelFieldIndex = Control.LabelFieldIndex;

             
            Style style = this.Style;
            Style labelStyle = Control.LabelStyle;
            writer.EnterStyle(labelStyle);
            writer.WriteText(Control.AllFields[labelFieldIndex].Title, true);
            writer.ExitStyle(labelStyle, true);

            bool hasDefaultCommand = HasDefaultCommand();
            bool onlyHasDefaultCommand = OnlyHasDefaultCommand();
            bool requiresDetailsScreen = !onlyHasDefaultCommand && HasCommands();
            // if there is > 1 visible field, need a details screen
            for (int visibleFields = 0, i = 0; !requiresDetailsScreen && i < count; i++)
            {
                visibleFields += allFields[i].Visible ? 1 : 0;
                requiresDetailsScreen = 
                    requiresDetailsScreen || visibleFields > 1;
            }   
            bool itemRequiresHyperlink = requiresDetailsScreen || hasDefaultCommand;
            bool itemRequiresMoreButton = requiresDetailsScreen && hasDefaultCommand;
            

            Style subCommandStyle = Control.CommandStyle;
            subCommandStyle.Alignment = style.Alignment;
            subCommandStyle.Wrapping = style.Wrapping;

            writer.EnterStyle(style);
            for (int i = startIndex; i < nextStartIndex; i++)
            {
                ObjectListItem item = items[i];

                if (itemRequiresHyperlink)
                {
                    RenderPostBackEventAsAnchor(writer,
                        hasDefaultCommand ?
                        item.Index.ToString(CultureInfo.InvariantCulture) :
                        String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index),
                        item[labelFieldIndex]);
                }
                else
                {
                    writer.WriteText(item[labelFieldIndex], true);
                }

                if (itemRequiresMoreButton)
                {
                    BooleanOption cachedItalic = subCommandStyle.Font.Italic;
                    subCommandStyle.Font.Italic = BooleanOption.False;
                    writer.EnterFormat(subCommandStyle);
                    writer.Write(" [");
                    writer.ExitFormat(subCommandStyle);
                    subCommandStyle.Font.Italic = cachedItalic;
                    writer.EnterFormat(subCommandStyle);
                    String moreText = Control.MoreText.Length == 0 ?
                        GetDefaultLabel(MoreLabel) :
                        Control.MoreText;
                    writer.WriteBeginTag("a");
                    RenderPostBackEventAsAttribute(writer, "href", String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index));
                    writer.Write(">");
                    writer.WriteText(moreText, true);
                    writer.WriteEndTag("a");                  
                    writer.ExitFormat(subCommandStyle);
                    subCommandStyle.Font.Italic = BooleanOption.False;
                    writer.EnterFormat(subCommandStyle);
                    writer.Write("]");
                    writer.ExitFormat(subCommandStyle);
                    subCommandStyle.Font.Italic = cachedItalic;
                }
                
                if(i < (nextStartIndex - 1))
                {
                    writer.WriteBreak();            
                }
            }
            writer.ExitStyle(style, Control.BreakAfter);
        }
Example #42
0
        private void RenderItemDetailsWithoutTableTags(HtmlMobileTextWriter writer, ObjectListItem item)
        {
            Style style1 = base.Style;
            Style style2 = Control.LabelStyle;
            Style style3 = Control.CommandStyle;

            writer.EnterStyle(style2);
            writer.WriteText(item[Control.LabelFieldIndex], true);
            writer.ExitStyle(style2, true);
            IObjectListFieldCollection iObjectListFieldCollection = Control.AllFields;
            int  i    = 0;
            bool flag = style1.Font.Bold == BooleanOption.True;

            writer.EnterStyle(style1);
            IEnumerator iEnumerator = iObjectListFieldCollection.GetEnumerator();

            while (iEnumerator.MoveNext())
            {
                ObjectListField objectListField = (ObjectListField)iEnumerator.Current;
                if (objectListField.Visible)
                {
                    if (!flag)
                    {
                        writer.Write("<b>");
                    }
                    writer.WriteText(String.Concat(objectListField.Title, ":"), true);
                    if (!flag)
                    {
                        writer.Write("</b>");
                    }
                    writer.Write("&nbsp;");
                    if (objectListField.Name == "CALL")
                    {
                        writer.WriteText(HtmlcheckPhonenumber(item[i]), true);
                    }
                    else if (objectListField.Name == "MAIL")
                    {
                        writer.WriteText(HtmlMail(item[i]), true);
                    }
                    else
                    {
                        writer.WriteText(item[i], true);
                    }
                    writer.WriteBreak();
                }
                i++;
            }

            writer.ExitStyle(style1);
            BooleanOption booleanOption = style3.Font.Italic;

            style3.Font.Italic = BooleanOption.False;
            writer.EnterStyle(style3);
            writer.Write("[&nbsp;");
            writer.ExitStyle(style3);
            style3.Font.Italic = booleanOption;
            writer.EnterStyle(style3);
            iEnumerator = Control.Commands.GetEnumerator();
            while (iEnumerator.MoveNext())
            {
                ObjectListCommand objectListCommand = (ObjectListCommand)iEnumerator.Current;
                RenderPostBackEventAsAnchor(writer, objectListCommand.Name, objectListCommand.Text, style3);
                writer.Write("&nbsp;|&nbsp;");
            }

            string str = (Control.BackCommandText != String.Empty) ? Control.BackCommandText : base.GetDefaultLabel(ControlAdapter.BackLabel);

            RenderPostBackEventAsAnchor(writer, BackToList, str, style3);
            writer.ExitStyle(style3);
            style3.Font.Italic = BooleanOption.False;
            writer.EnterStyle(style3);
            writer.Write("&nbsp;]");
            writer.ExitStyle(style3, Control.BreakAfter);
            style3.Font.Italic = booleanOption;
        }