public override void Render(HtmlMobileTextWriter writer)
        {
            String additionalStyle;

            Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];
            Wrapping  wrapping  = (Wrapping)Style[Style.WrappingKey, true];
            bool      wrap      = (wrapping == Wrapping.Wrap || wrapping == Wrapping.NotSet);
            String    width     = DesignerAdapterUtil.GetWidth(Control);

            ((DesignerTextWriter)writer).EnterZeroFontSizeTag();
            writer.EnterLayout(Style);
            writer.WriteBeginTag("div");
            if (!wrap)
            {
                byte templateStatus;
                int  maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus);
                if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT)
                {
                    width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px";
                }
                additionalStyle = "overflow-x:hidden;width:" + width + ";";
            }
            else
            {
                additionalStyle = "word-wrap:break-word;width:" + width + ";";
            }

            ((DesignerTextWriter)writer).WriteStyleAttribute(Style, additionalStyle);
            if (alignment != Alignment.NotSet)
            {
                writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment));
            }
            writer.Write(">");

            writer.WriteText(Control.HeaderText, true);

            writer.WriteFullBeginTag("ul");
            for (int i = 1; i <= 2; i++)
            {
                writer.WriteFullBeginTag("li");
                writer.Write(SR.GetString(SR.ValidationSummary_ErrorMessage, i.ToString(CultureInfo.InvariantCulture)));
                writer.WriteEndTag("li");
            }
            writer.WriteEndTag("ul");

            writer.WriteBeginTag("a");
            writer.WriteAttribute("href", "NavigationUrl");
            writer.Write(">");
            writer.WriteText(String.IsNullOrEmpty(Control.BackLabel) ? GetDefaultLabel(BackLabel) : Control.BackLabel, true);
            writer.WriteEndTag("a");

            writer.WriteEndTag("div");
            writer.ExitLayout(Style);
            ((DesignerTextWriter)writer).ExitZeroFontSizeTag();
        }
Ejemplo n.º 2
0
        /// <include file='doc\HtmlTextBoxAdapter.uex' path='docs/doc[@for="HtmlTextBoxAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            writer.EnterLayout(Style);

            writer.WriteBeginTag("input");

            writer.WriteAttribute("name", GetRenderName());

            if ((Control.Text == null || Control.Text.Length > 0) && !Control.Password)
            {
                writer.Write(" value=\"");
                writer.WriteText(Control.Text, true);
                writer.Write("\"");
            }
            if (Control.Size > 0)
            {
                writer.WriteAttribute("size", Control.Size.ToString(CultureInfo.InvariantCulture));
            }
            if (Control.MaxLength > 0)
            {
                writer.WriteAttribute("maxlength", Control.MaxLength.ToString(CultureInfo.InvariantCulture));
            }
            if (Control.Password)
            {
                writer.WriteAttribute("type", "password");
            }
            AddAttributes(writer);
            writer.Write("/>");

            writer.ExitLayout(Style, Control.BreakAfter);
            writer.InputWritten = true;
        }
        /// <include file='doc\HtmlTextBoxAdapter.uex' path='docs/doc[@for="HtmlTextBoxAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            writer.EnterLayout(Style); 

            writer.WriteBeginTag("input");

            writer.WriteAttribute("name", GetRenderName());

            if ((Control.Text == null || Control.Text.Length > 0) && !Control.Password)
            {
                writer.Write(" value=\"");
                writer.WriteText(Control.Text, true);
                writer.Write("\"");
            }
            if (Control.Size > 0)
            {
                writer.WriteAttribute("size", Control.Size.ToString(CultureInfo.InvariantCulture));
            }
            if (Control.MaxLength > 0)
            {
                writer.WriteAttribute("maxlength", Control.MaxLength.ToString(CultureInfo.InvariantCulture));
            }
            if (Control.Password)
            {
                writer.WriteAttribute("type", "password");
            }
            AddAttributes(writer);
            writer.Write("/>");

            writer.ExitLayout(Style, Control.BreakAfter);
            writer.InputWritten = true;
        }
        public override void Render(HtmlMobileTextWriter writer)
        {
            writer.WriteBeginTag("div");
            String width = DesignerAdapterUtil.GetWidth(Control);

            writer.WriteAttribute("style", "cellpadding=2px;width:" + width);

            Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];

            if (alignment != Alignment.NotSet)
            {
                writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment));
            }
            writer.Write("/>");

            ((DesignerTextWriter)writer).EnterZeroFontSizeTag();

            //Note: Although this is an internal method of runtime, but it is still
            //      pretty easy to achieve the same goal without using this method.
            Style.ApplyTo(Control.WebCalendar);
            base.Render(writer);

            ((DesignerTextWriter)writer).ExitZeroFontSizeTag();
            writer.WriteEndTag("div");
        }
Ejemplo n.º 5
0
        public override void Render(HtmlMobileTextWriter writer)
        {
            Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];

            byte   templateStatus;
            int    maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus);
            String width    = DesignerAdapterUtil.GetWidth(Control);

            if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT)
            {
                width = maxWidth.ToString() + "px";
            }

            writer.WriteBeginTag("div");
            if (alignment == Alignment.Center)
            {
                writer.WriteAttribute("align", "center");
            }
            writer.WriteAttribute("style", "overflow-x:hidden;width:" + width);
            writer.Write(">");

            String source = Control.ImageUrl;

            writer.WriteBeginTag("img");
            ((DesignerTextWriter)writer).WriteStyleAttribute(Style);
            if (source != "")
            {
                writer.WriteAttribute("src", source, true);
            }
            if (Control.AlternateText != "")
            {
                writer.Write(" alt=\"");
                writer.WriteText(Control.AlternateText, true);
                writer.Write("\"");
            }

            // center alignment not part of HTML for images.
            if (alignment == Alignment.Right ||
                alignment == Alignment.Left)
            {
                writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment));
            }

            writer.WriteAttribute("border", "0");
            writer.Write(">");
            writer.WriteEndTag("div");
        }
 /// <include file='doc\HtmlFormAdapter.uex' path='docs/doc[@for="HtmlFormAdapter.RenderBodyTag"]/*' />
 protected virtual void RenderBodyTag(HtmlMobileTextWriter writer, IDictionary attributes)
 {
     writer.WriteBeginTag("body");
     foreach (DictionaryEntry entry in attributes)
     {
         writer.WriteAttribute((String)entry.Key, (String)entry.Value, true);
     }
     writer.WriteLine(">");
 }
Ejemplo n.º 7
0
        public override void Render(HtmlMobileTextWriter writer)
        {
            writer.WriteBeginTag("div");
            ((DesignerTextWriter)writer).WriteDesignerStyleAttributes(Control, Style);
            writer.Write("\">");

            base.Render(writer);

            writer.WriteEndTag("div");
        }
Ejemplo n.º 8
0
 private void RenderPostBackEventAsAnchor(HtmlMobileTextWriter writer, string argument, string linkText, Style style)
 {
     writer.EnterFormat(style);
     writer.WriteBeginTag("a");
     base.RenderPostBackEventAsAttribute(writer, "href", argument);
     writer.Write(">");
     writer.WriteText(linkText, true);
     writer.WriteEndTag("a");
     writer.ExitFormat(style);
 }
        public override void Render(HtmlMobileTextWriter writer)
        {
            Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];
            String    width     = DesignerAdapterUtil.GetWidth(Control);

            byte templateStatus;
            int  maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus);

            if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT)
            {
                width = maxWidth.ToString() + "px";
            }

            writer.WriteBeginTag("div");
            if (alignment == Alignment.Center)
            {
                writer.WriteAttribute("align", "center");
            }
            writer.WriteAttribute("style", "padding=2px;overflow-x:hidden;width:" + width);
            writer.Write(">");

            ((DesignerTextWriter)writer).EnterZeroFontSizeTag();

            writer.WriteBeginTag("img");
            writer.WriteAttribute("alt", Control.ID);
            ((DesignerTextWriter)writer).WriteStyleAttribute(Style);

            // center alignment not part of HTML for images.
            if (alignment == Alignment.Right ||
                alignment == Alignment.Left)
            {
                writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment));
            }

            writer.WriteAttribute("height", "40");
            writer.WriteAttribute("width", "250");
            writer.WriteAttribute("border", "0");
            writer.Write(">");

            ((DesignerTextWriter)writer).ExitZeroFontSizeTag();
            writer.WriteEndTag("div");
        }
Ejemplo n.º 10
0
 protected override void RenderBodyTag(HtmlMobileTextWriter
                                       writer, IDictionary attributes)
 {
     writer.WriteBeginTag("body");
     foreach (DictionaryEntry entry in attributes)
     {
         writer.WriteAttribute((string)entry.Key, (string)
                               entry.Value);
     }
     writer.WriteAttribute("leftmargin", "0");
     writer.WriteLine(">");
 }
        public override void Render(HtmlMobileTextWriter writer)
        {
            Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];
            Wrapping  wrapping  = (Wrapping)Style[Style.WrappingKey, true];
            bool      wrap      = (wrapping == Wrapping.Wrap || wrapping == Wrapping.NotSet);

            ((DesignerTextWriter)writer).EnterZeroFontSizeTag();
            writer.WriteBeginTag("div");
            String width = DesignerAdapterUtil.GetWidth(Control);

            if (!wrap)
            {
                byte templateStatus;
                int  maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus);
                if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT)
                {
                    width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px";
                }
                writer.WriteAttribute("style", "overflow-x:hidden;width:" + width);
            }
            else
            {
                writer.WriteAttribute("style", "word-wrap:break-word;width:" + width);
            }

            if (alignment != Alignment.NotSet)
            {
                writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment));
            }
            writer.Write(">");

            writer.WriteBeginTag("a");
            writer.WriteAttribute("href", "NavigationUrl");
            writer.Write(">");
            ((DesignerTextWriter)writer).WriteCssStyleText(Style, null, Control.Text, true);
            writer.WriteEndTag("a");

            writer.WriteEndTag("div");
            ((DesignerTextWriter)writer).ExitZeroFontSizeTag();
        }
 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\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);
        }
        public override void Render(HtmlMobileTextWriter writer)
        {
            Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];
            Wrapping  wrapping  = (Wrapping)Style[Style.WrappingKey, true];
            bool      wrap      = (wrapping == Wrapping.Wrap || wrapping == Wrapping.NotSet);
            String    width     = DesignerAdapterUtil.GetWidth(Control);

            ((DesignerTextWriter)writer).EnterZeroFontSizeTag();
            writer.WriteBeginTag("div");
            if (!wrap)
            {
                byte templateStatus;
                int  maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus);
                if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT)
                {
                    width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px";
                }
                writer.WriteAttribute("style", "overflow-x:hidden;width:" + width);
            }
            else
            {
                writer.WriteAttribute("style", "word-wrap:break-word;width:" + width);
            }

            if (alignment != Alignment.NotSet)
            {
                writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment));
            }
            writer.Write(">");

            MSHTMLHostUtil.ApplyStyle(null, null, null);
            String filteredText     = FilterTags(Control.Text.Trim());
            int    uniqueLineHeight = MSHTMLHostUtil.GetHtmlFragmentHeight("a");
            int    requiredHeight   = MSHTMLHostUtil.GetHtmlFragmentHeight(filteredText);
            int    requiredWidth    = MSHTMLHostUtil.GetHtmlFragmentWidth(filteredText);

            ((DesignerTextWriter)writer).WriteCssStyleText(Style, null, (requiredHeight > uniqueLineHeight || requiredWidth > 1) ? filteredText : "&nbsp;", false);
            writer.WriteEndTag("div");
            ((DesignerTextWriter)writer).ExitZeroFontSizeTag();
        }
        /// <include file='doc\HtmlImageAdapter.uex' path='docs/doc[@for="HtmlImageAdapter.RenderImage"]/*' />
        protected internal virtual void RenderImage(HtmlMobileTextWriter writer)
        {
            String source = Control.ImageUrl;

            writer.WriteBeginTag("img");

            if (!String.IsNullOrEmpty(source))
            {
                // AUI 3652
                source = Control.ResolveUrl(source);

                writer.WriteAttribute("src", source, true /*encode*/);
                writer.AddResource(source);
            }

            if (!String.IsNullOrEmpty(Control.AlternateText))
            {
                writer.WriteAttribute("alt", Control.AlternateText, true);
            }

            writer.WriteAttribute("border", "0");
            writer.Write(" />");
        }
Ejemplo n.º 17
0
        /// <include file='doc\HtmlImageAdapter.uex' path='docs/doc[@for="HtmlImageAdapter.RenderImage"]/*' />
        protected internal virtual void RenderImage(HtmlMobileTextWriter writer)
        {
            String source = Control.ImageUrl;

            writer.WriteBeginTag("img");

            if (!String.IsNullOrEmpty(source))
            {
                // AUI 3652
                source = Control.ResolveUrl(source);

                writer.WriteAttribute("src", source, true /*encode*/);
                writer.AddResource(source);
            }

            if (!String.IsNullOrEmpty(Control.AlternateText))
            {
                writer.WriteAttribute("alt", Control.AlternateText, true);
            }

            writer.WriteAttribute("border", "0");
            writer.Write(" />");
        }
Ejemplo n.º 18
0
        /// <include file='doc\ChtmlFormAdapter.uex' path='docs/doc[@for="ChtmlFormAdapter.RenderPagerTag"]/*' />
        protected internal override void RenderPagerTag(
            HtmlMobileTextWriter writer,
            int pageToNavigate,
            String text)
        {
            writer.EnterLayout(Style);
            writer.EnterFormat(Style);
            writer.WriteBeginTag("input");

            // Specially encode the page number with the control id.
            // The corresponding code that handles postback should know how
            // to extract the page number correctly.
            writer.Write(" name=\"");
            writer.Write(Control.UniqueID);
            writer.Write(Constants.PagePrefix);
            writer.Write(pageToNavigate.ToString(CultureInfo.InvariantCulture));
            writer.Write("\"");

            writer.WriteAttribute("type", "submit");
            writer.WriteAttribute("value", text, true);
            writer.Write("/>");
            writer.ExitFormat(Style);
            writer.ExitLayout(Style);
        }
Ejemplo n.º 19
0
        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\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;
            }
        }
Ejemplo n.º 21
0
        public override void Render(HtmlMobileTextWriter writer)
        {
            // Invalid text writers are not supported in this Adapter.
            if (!(writer is DesignerTextWriter))
            {
                return;
            }

            Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];
            byte      templateStatus;
            int       maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus);
            String    width    = DesignerAdapterUtil.GetWidth(Control);

            if (Control.ImageUrl.Length == 0)
            {
                if (Control.Format == CommandFormat.Button)
                {
                    if (maxWidth == 0 && templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_NONEDIT)
                    {
                        maxWidth = DesignerAdapterUtil.CONTROL_MAX_WIDTH_IN_TEMPLATE;
                    }

                    if (maxWidth == 0 && DesignerAdapterUtil.InMobileUserControl(Control))
                    {
                        maxWidth = Constants.ControlMaxsizeAtToplevel;
                    }

                    if (maxWidth == 0)
                    {
                        // Render will be called a second time for which maxWidth != 0
                        return;
                    }

                    String additionalStyle = null;
                    String controlText     = Control.Text;
                    String commandCaption;
                    int    requiredWidth = 0;

                    DesignerTextWriter twTmp;
                    twTmp = new DesignerTextWriter();
                    twTmp.WriteBeginTag("input");
                    twTmp.WriteStyleAttribute(Style, null);
                    twTmp.WriteAttribute("type", "submit");
                    twTmp.Write(" value=\"");
                    twTmp.WriteText(controlText, true);
                    twTmp.Write("\"/>");
                    String htmlFragment = twTmp.ToString();

                    MSHTMLHostUtil.ApplyStyle(String.Empty, String.Empty, null);
                    requiredWidth = MSHTMLHostUtil.GetHtmlFragmentWidth(htmlFragment);

                    ((DesignerTextWriter)writer).EnterZeroFontSizeTag();
                    writer.WriteBeginTag("div");
                    if (requiredWidth + SAFETY_MARGIN > maxWidth)
                    {
                        if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT)
                        {
                            int tmpRequiredWidth, allowedLength;
                            int captionLength = controlText.Length;
                            twTmp = new DesignerTextWriter();
                            twTmp.WriteBeginTag("input");
                            twTmp.WriteStyleAttribute(Style, null);
                            twTmp.WriteAttribute("type", "submit");
                            twTmp.WriteAttribute("value", "{0}");
                            twTmp.Write("/>");
                            htmlFragment = twTmp.ToString();
                            // At least 10 characters can fit into the caption of the command
                            for (allowedLength = (captionLength < 10 ? captionLength : 10); allowedLength <= captionLength; allowedLength++)
                            {
                                tmpRequiredWidth = MSHTMLHostUtil.GetHtmlFragmentWidth(String.Format(CultureInfo.CurrentCulture, htmlFragment, HttpUtility.HtmlEncode(controlText.Substring(0, allowedLength))));
                                if (tmpRequiredWidth + SAFETY_MARGIN > maxWidth)
                                {
                                    break;
                                }
                            }
                            commandCaption = controlText.Substring(0, allowedLength - 1);
                        }
                        else
                        {
                            commandCaption = controlText;
                        }
                    }
                    else
                    {
                        writer.WriteAttribute("style", "width:" + width);
                        commandCaption = controlText;
                    }

                    if (alignment != Alignment.NotSet)
                    {
                        writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment));
                    }
                    writer.Write(">");

                    writer.EnterLayout(Style);

                    writer.WriteBeginTag("input");
                    if (requiredWidth + SAFETY_MARGIN > maxWidth)
                    {
                        additionalStyle = String.Format(CultureInfo.CurrentCulture, "width:{0};", width);
                    }
                    ((DesignerTextWriter)writer).WriteStyleAttribute(Style, additionalStyle);
                    writer.WriteAttribute("type", "submit");

                    writer.Write(" value=\"");
                    writer.WriteText(commandCaption, true);
                    writer.Write("\"/>");

                    writer.ExitLayout(Style);
                }
                else
                {
                    Wrapping wrapping = (Wrapping)Style[Style.WrappingKey, true];
                    bool     wrap     = (wrapping == Wrapping.Wrap || wrapping == Wrapping.NotSet);

                    ((DesignerTextWriter)writer).EnterZeroFontSizeTag();
                    writer.WriteBeginTag("div");

                    if (!wrap)
                    {
                        if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT)
                        {
                            width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px";
                        }
                        writer.WriteAttribute("style", "overflow-x:hidden;width:" + width);
                    }
                    else
                    {
                        writer.WriteAttribute("style", "word-wrap:break-word;width:" + width);
                    }

                    if (alignment != Alignment.NotSet)
                    {
                        writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment));
                    }
                    writer.Write(">");

                    writer.WriteBeginTag("a");
                    writer.WriteAttribute("href", "NavigationUrl");
                    writer.Write(">");
                    ((DesignerTextWriter)writer).WriteCssStyleText(Style, null, Control.Text, true);
                    writer.WriteEndTag("a");
                }
                writer.WriteEndTag("div");
                ((DesignerTextWriter)writer).ExitZeroFontSizeTag();
            }
            else
            {
                if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT)
                {
                    width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px";
                }

                writer.WriteBeginTag("div");
                if (alignment == Alignment.Center)
                {
                    writer.WriteAttribute("align", "center");
                }
                writer.WriteAttribute("style", "overflow-x:hidden;width:" + width);
                writer.Write(">");

                writer.WriteBeginTag("img");
                ((DesignerTextWriter)writer).WriteStyleAttribute(Style);
                writer.WriteAttribute("src", Control.ImageUrl, true);

                // center alignment not part of HTML for images.
                if (alignment == Alignment.Right ||
                    alignment == Alignment.Left)
                {
                    writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment));
                }

                writer.WriteAttribute("border", "0");
                writer.Write(">");
                writer.WriteEndTag("div");
            }
        }
Ejemplo n.º 22
0
        //*********************************************************************
        //
        // HtmlTabbedPanelAdapter.Render Method
        //
        // Renders the control. The TabbedPanel is rendered as one or more
        // rows of tabs that the user can click on to move between tabs.
        //
        //*********************************************************************
        public override void Render(HtmlMobileTextWriter writer)
        {
            IPanelPane activePane = Control.ActivePane;
            int tabsPerRow = Control.TabsPerRow;
            PanelPaneCollection panes = Control.Panes;
            int paneCount = panes.Count;

            // Figure out the number of visible panes.
            int[] visiblePanes = new int[paneCount];
            int visiblePaneCount = 0;
            for (int i = 0; i < paneCount; i++)
            {
                if (((Control) panes[i]).Visible)
                {
                    visiblePanes[visiblePaneCount++] = i;
                }
            }

            // Calculate how many rows are necessary.
            int rows = (visiblePaneCount + tabsPerRow - 1)/tabsPerRow;

            // make sure tabsPerRow doesn't exceed the number of visible panes
            tabsPerRow = (Control.TabsPerRow > visiblePaneCount) ? visiblePaneCount : Control.TabsPerRow;

            // Open the table.
            writer.WriteBeginTag("table");
            writer.WriteAttribute("cellspacing", "0");
            writer.WriteAttribute("cellpadding", "2");
            writer.WriteAttribute("border", "0");
            writer.WriteLine(">");

            for (int row = rows - 1; row >= 0; row--)
            {
                writer.WriteFullBeginTag("tr");
                writer.WriteLine();
                for (int col = 0; col < tabsPerRow; col++)
                {
                    writer.WriteBeginTag("td");
                    writer.WriteAttribute("width", "0");
                    writer.Write(">");
                    writer.WriteEndTag("td");

                    int i = row*tabsPerRow + col;
                    if (row > 0 && i >= visiblePaneCount)
                    {
                        writer.WriteFullBeginTag("td");
                        writer.WriteEndTag("td");
                        continue;
                    }

                    int index = visiblePanes[i];
                    IPanelPane child = panes[index];
                    if (child == activePane)
                    {
                        writer.WriteBeginTag("td");
                        writer.WriteAttribute("bgcolor", GetColorString(Control.ActiveTabColor, "#333333"));
                        writer.Write(">");

                        writer.WriteBeginTag("font");
                        writer.WriteAttribute("face", "Verdana");
                        writer.WriteAttribute("size", "-2");
                        writer.WriteAttribute("color", GetColorString(Control.ActiveTabTextColor, "#000000"));
                        writer.Write(">");

                        writer.WriteFullBeginTag("b");
                        writer.Write("&nbsp;");
                        writer.WriteText(child.Title, true);
                        writer.Write("&nbsp;");
                        writer.WriteEndTag("b");

                        writer.WriteEndTag("font");

                        writer.WriteEndTag("td");
                        writer.WriteLine();
                    }
                    else
                    {
                        writer.WriteBeginTag("td");
                        writer.WriteAttribute("bgcolor", GetColorString(Control.TabColor, "#cccccc"));
                        writer.Write(">");

                        writer.WriteBeginTag("font");
                        writer.WriteAttribute("face", "Verdana");
                        writer.WriteAttribute("size", "-2");
                        writer.WriteAttribute("color", GetColorString(Control.TabTextColor, "#000000"));
                        writer.Write(">");

                        writer.Write("&nbsp;");
                        writer.WriteBeginTag("a");
                        RenderPostBackEventAsAttribute(writer, "href", index.ToString());
                        writer.Write(">");
                        writer.WriteText(child.Title, true);
                        writer.WriteEndTag("a");
                        writer.Write("&nbsp;");

                        writer.WriteEndTag("font");

                        writer.WriteEndTag("td");
                        writer.WriteLine();
                    }
                }
                writer.WriteEndTag("tr");
                writer.WriteLine();

                if (row > 0)
                {
                    writer.WriteFullBeginTag("tr");
                    writer.WriteBeginTag("td");
                    writer.WriteAttribute("height", "1");
                    writer.Write(">");
                    writer.WriteEndTag("td");
                    writer.WriteEndTag("tr");
                    writer.WriteLine();
                }
            }

            writer.WriteEndTag("table");
            writer.WriteLine();

            writer.WriteBeginTag("table");
            writer.WriteAttribute("width", "100%");
            writer.WriteAttribute("height", "2");
            writer.WriteAttribute("border", "0");
            writer.WriteAttribute("cellspacing", "0");
            writer.WriteAttribute("bgcolor", "#000000");
            writer.Write(">");
            writer.WriteFullBeginTag("tr");
            writer.WriteFullBeginTag("td");
            writer.WriteEndTag("td");
            writer.WriteEndTag("tr");
            writer.WriteEndTag("table");
            writer.WriteBreak();

            ((Control) activePane).RenderControl(writer);
        }
        /// <include file='doc\HtmlFormAdapter.uex' path='docs/doc[@for="HtmlFormAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            Color  backColor    = (Color)Style[Style.BackColorKey, true];
            String title        = Control.Title;
            bool   isTitleEmpty = String.IsNullOrEmpty(title);

            bool willWriteHeadElements =
                !isTitleEmpty ||
                RenderExtraHeadElements(null);

            if (willWriteHeadElements)
            {
                writer.Write("\r\n");
                writer.WriteFullBeginTag("head");
            }

            if (!isTitleEmpty)
            {
                writer.Write("\r\n");
                writer.WriteFullBeginTag("title");
                writer.Write(title);
                writer.WriteEndTag("title");
                writer.Write("\r\n");
            }

            _renderPager = true;

            RenderExtraHeadElements(writer);

            if (willWriteHeadElements)
            {
                writer.WriteEndTag("head");
                writer.Write("\r\n");
            }

            IDictionary bodyAttributes = new ListDictionary();

            if ((backColor != Color.Empty) && (writer.RenderBodyColor))
            {
                bodyAttributes.Add("bgcolor", ColorTranslator.ToHtml(backColor));
            }
            RenderBodyTag(writer, bodyAttributes);

            bool formTagRequired = ShouldRenderFormTag();

            if (formTagRequired)
            {
                writer.WriteBeginTag("form");
                writer.WriteAttribute("id", Control.ClientID);
                writer.WriteAttribute("name", Control.ClientID);
                writer.WriteAttribute("method", Control.Method.ToString().ToLower(CultureInfo.InvariantCulture));
                writer.Write(" action=\"");

                if (Control.Action.Length > 0)
                {
                    // AUI 3652
                    String url = Control.ResolveUrl(Control.Action);

                    if (!Device.SupportsQueryStringInFormAction)
                    {
                        // If query string is not supported, we don't write
                        // it here, and the query string will be added as
                        // hidden variables later.
                        int i = url.IndexOf('?');
                        if (i != -1)
                        {
                            url = url.Substring(0, i);
                        }
                    }

                    writer.Write(url);
                }
                else
                {
                    writer.WriteEncodedUrl(Page.RelativeFilePath);

                    if (Device.SupportsQueryStringInFormAction)
                    {
                        writer.Write("?");
                        writer.Write(Page.UniqueFilePathSuffix);
                        if (Control.Method != FormMethod.Get)
                        {
                            String queryStringText = Page.QueryStringText;
                            if (queryStringText != null && queryStringText.Length > 0)
                            {
                                writer.Write('&');
                                writer.Write(queryStringText);
                            }
                        }
                    }
                }

                writer.Write("\"");
                writer.Write(">\r\n");

                PageAdapter.RenderPostBackHeader(writer, Control);

                // Renders hidden variables for IPostBackDataHandlers which are
                // not displayed due to pagination or secondary UI.
                RenderOffPageVariables(writer, Control, Control.CurrentPage);
            }

            writer.EnterStyle(Style);

            writer.BeforeFirstControlWritten = true;

            MobileControl secondaryUIControl = SecondaryUIControl as MobileControl;

            if (secondaryUIControl != null && secondaryUIControl.Form == Control)
            {
                bool secondaryUIInHeaderOrFooter = IsControlInFormHeader(secondaryUIControl) ||
                                                   IsControlInFormFooter(secondaryUIControl);


                SetControlPageRecursive(secondaryUIControl, -1);
                if (Control.Header != null && !secondaryUIInHeaderOrFooter)
                {
                    Control.Header.RenderControl(writer);
                }
                secondaryUIControl.RenderControl(writer);
                if (Control.Footer != null && !secondaryUIInHeaderOrFooter)
                {
                    Control.Footer.RenderControl(writer);
                }
            }
            else
            {
                bool pagerRendered = false;
                if (Control.HasControls())
                {
                    foreach (Control child in Control.Controls)
                    {
                        if (Control.Footer == child)
                        {
                            RenderPager(writer);
                            pagerRendered = true;
                        }
                        child.RenderControl(writer);
                    }
                }
                if (!pagerRendered)
                {
                    RenderPager(writer);
                }
            }

            writer.ExitStyle(Style, false);

            if (formTagRequired)
            {
                if (!Device.SupportsQueryStringInFormAction)
                {
                    // Add query string parameters at the end of the form if
                    // there are any
                    RenderQueryParametersAsHiddenFields(writer);
                }
                writer.WriteEndTag("form");
            }
            writer.WriteEndTag("body");
        }
        /// <include file='doc\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\ChtmlFormAdapter.uex' path='docs/doc[@for="ChtmlFormAdapter.RenderPagerTag"]/*' />
        protected internal override void RenderPagerTag(
            HtmlMobileTextWriter writer,
            int pageToNavigate,
            String text)
        {
            writer.EnterLayout(Style);
            writer.EnterFormat(Style);
            writer.WriteBeginTag("input");

            // Specially encode the page number with the control id.
            // The corresponding code that handles postback should know how
            // to extract the page number correctly.
            writer.Write(" name=\"");
            writer.Write(Control.UniqueID);
            writer.Write(Constants.PagePrefix);
            writer.Write(pageToNavigate.ToString(CultureInfo.InvariantCulture));
            writer.Write("\"");

            writer.WriteAttribute("type", "submit");
            writer.WriteAttribute("value", text, true);
            writer.Write("/>");
            writer.ExitFormat(Style);
            writer.ExitLayout(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\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;
            }
        }
        protected void RenderBeginLink(HtmlMobileTextWriter writer, String target)
        {
            bool queryStringWritten = false;
            bool appendCookieless   = (PageAdapter.PersistCookielessData) &&
                                      (!((target.StartsWith("http:")) || (target.StartsWith("https:"))));

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

            String targetUrl = null;
            String prefix    = Constants.FormIDPrefix;

            if (target.StartsWith(prefix))
            {
                String name = target.Substring(prefix.Length);
                Form   form = Control.ResolveFormReference(name);

                if (writer.SupportsMultiPart)
                {
                    if (form != null && PageAdapter.IsFormRendered(form))
                    {
                        targetUrl = PageAdapter.GetFormUrl(form);
                    }
                }

                if (targetUrl == null)
                {
                    RenderPostBackEventReference(writer, form.UniqueID);
                    appendCookieless = false;
                }
                else
                {
                    writer.Write(targetUrl);
                    queryStringWritten = targetUrl.IndexOf('?') != -1;
                }
            }
            else
            {
                MobileControl control = Control;

                // There is some adapter that Control is not set.  And we
                // don't do any url resolution then.  E.g. a page adapter
                if (control != null)
                {
                    // AUI 3652
                    target = control.ResolveUrl(target);
                }

                writer.Write(target);
                queryStringWritten = target.IndexOf('?') != -1;
            }

            IDictionary dictionary = PageAdapter.CookielessDataDictionary;

            if ((dictionary != null) && (appendCookieless))
            {
                foreach (String name in dictionary.Keys)
                {
                    if (queryStringWritten)
                    {
                        writer.Write('&');
                    }
                    else
                    {
                        writer.Write('?');
                        queryStringWritten = true;
                    }
                    writer.Write(name);
                    writer.Write('=');
                    writer.Write(dictionary[name]);
                }
            }

            writer.Write("\"");
            AddAttributes(writer);
            writer.Write(">");
        }
        public override void Render(HtmlMobileTextWriter writer)
        {
            // Invalid text writers are not supported in this Adapter.
            if (!(writer is DesignerTextWriter))
            {
                return;
            }

            byte templateStatus;
            bool pwd  = Control.Password;
            int  size = Control.Size;
            int  fittingSize;

            int maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus);

            if (maxWidth == 0)
            {
                if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_NONEDIT)
                {
                    maxWidth = DesignerAdapterUtil.CONTROL_MAX_WIDTH_IN_TEMPLATE;
                }
                else if (DesignerAdapterUtil.InMobileUserControl(Control))
                {
                    maxWidth = Constants.ControlMaxsizeAtToplevel;
                }
            }

            if (maxWidth == 0)
            {
                return;
            }

            bool restoreEmptyFontName = false;

            if ((String)Style[Style.FontNameKey, true] == String.Empty)
            {
                // MSHTMLHostUtil is using another font by default.
                // Setting the font name to the one that is actually
                // used by default for the desig-time rendering
                // assures that the requiredWidth returned by
                // MSHTMLHostUtil.GetHtmlFragmentWidth is accurate.
                Style[Style.FontNameKey] = "Arial";
                restoreEmptyFontName     = true;
            }

            int requiredWidth = 0;
            DesignerTextWriter tw;

            tw = new DesignerTextWriter(false);
            tw.EnterLayout(Style);
            String enterLayout = tw.ToString();

            tw = new DesignerTextWriter(false);
            tw.ExitLayout(Style);
            String exitLayout = tw.ToString();

            tw = new DesignerTextWriter(false);
            tw.WriteBeginTag("input");
            tw.WriteStyleAttribute(Style, null);
            if (size > 0)
            {
                tw.WriteAttribute("size", "{0}");
            }
            tw.Write("/>");
            String htmlFragment = tw.ToString();

            MSHTMLHostUtil.ApplyStyle(enterLayout, exitLayout, null);

            if (size < LARGESIZE_THRESHOLD)
            {
                requiredWidth = MSHTMLHostUtil.GetHtmlFragmentWidth(size > 0 ? String.Format(htmlFragment, size.ToString()) : htmlFragment);
            }

            if (requiredWidth + SAFETY_MARGIN > maxWidth || size >= LARGESIZE_THRESHOLD)
            {
                if (size == 0)
                {
                    tw = new DesignerTextWriter(false);
                    tw.WriteBeginTag("input");
                    tw.WriteStyleAttribute(Style, null);
                    tw.WriteAttribute("size", "{0}");
                    tw.Write("/>");
                    htmlFragment = tw.ToString();
                }
                fittingSize = 0;
                do
                {
                    fittingSize++;
                    requiredWidth = MSHTMLHostUtil.GetHtmlFragmentWidth(String.Format(htmlFragment, fittingSize.ToString()));
                }while (requiredWidth + SAFETY_MARGIN <= maxWidth);

                if (fittingSize > 1)
                {
                    fittingSize--;
                }
            }
            else
            {
                fittingSize = size;
            }

            if (restoreEmptyFontName)
            {
                Style[Style.FontNameKey] = String.Empty;
            }

            Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];
            String    width     = DesignerAdapterUtil.GetWidth(Control);

            writer.Write("<div style='width:" + width);
            if (alignment != Alignment.NotSet)
            {
                writer.Write(";text-align:" + Enum.GetName(typeof(Alignment), alignment));
            }
            writer.Write("'>");

            ((DesignerTextWriter)writer).EnterZeroFontSizeTag();
            writer.EnterLayout(Style);

            writer.WriteBeginTag("input");
            ((DesignerTextWriter)writer).WriteStyleAttribute(Style, null);
            if (Control.Text != String.Empty)
            {
                writer.Write(" value=\"");
                writer.WriteText(Control.Text, true);
                writer.Write("\" ");
            }
            if (fittingSize > 0)
            {
                writer.WriteAttribute("size", fittingSize.ToString());
            }
            if (pwd)
            {
                writer.WriteAttribute("type", "password");
            }
            writer.Write("/>");

            writer.ExitLayout(Style);
            ((DesignerTextWriter)writer).ExitZeroFontSizeTag();
            writer.Write("</div>");
        }
 // Private overload for use with subcommands.
 // Style, Enter/ExitFormat included only for completeness because style
 // is already set for subcommands.
 private void RenderPostBackEventAsAnchor(
     HtmlMobileTextWriter writer,
     String argument,
     String linkText,
     Style style)
 {
     writer.EnterFormat(style);
     writer.WriteBeginTag("a");
     RenderPostBackEventAsAttribute(writer, "href", argument);
     writer.Write(">");
     writer.WriteText(linkText, true);
     writer.WriteEndTag("a");
     writer.ExitFormat(style);
 }
Ejemplo n.º 31
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;
            }
        }
Ejemplo n.º 32
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;
            }
        }
Ejemplo n.º 33
0
        internal void Transition(WriterStyle newStyle, bool captureOutput)
        {
            HtmlMobileTextWriter tempWriter = _writer;

            try
            {
                if (!captureOutput)
                {
                    tempWriter = _writer;
                    _writer    = new HtmlMobileTextWriter(
                        new HtmlTextWriter(new StringWriter(CultureInfo.InvariantCulture)), tempWriter.Device);
                }

                if (_inTransition)
                {
                    return;
                }
                else
                {
                    _inTransition = true;
                }

                if (Count == 0)
                {
                    while (_tagsWritten.Count > 0)
                    {
                        CloseTag();
                    }
                    _inTransition = false;
                    return;
                }

                //close italic if target format !italic
                if ((_current.Italic && !newStyle.Italic) && (_writer.RenderItalic))
                {
                    while (_current.Italic)
                    {
                        CloseTag();
                    }
                }

                //close bold if target format !bold
                if ((_current.Bold && !newStyle.Bold) && (_writer.RenderBold))
                {
                    while (_current.Bold)
                    {
                        CloseTag();
                    }
                }

                //if the target FontColor is Color.Empty, then we need to
                //close all open color tags
                if (
                    (newStyle.FontColor == Color.Empty) &&
                    (_current.FontColor != Color.Empty) &&
                    (_writer.RenderFontColor))
                {
                    while (_current.FontColor != Color.Empty)
                    {
                        CloseTag();
                    }
                }

                //if the target FontName is String.Empty, then we need to
                //close all open name tags
                if (
                    (newStyle.FontName != null && newStyle.FontName.Length == 0) &&
                    (_current.FontName == null || _current.FontName.Length > 0) &&
                    (_writer.RenderFontName))
                {
                    while (_current.FontName == null || _current.FontName.Length > 0)
                    {
                        CloseTag();
                    }
                }

                //close the font if it is of the same or a later generation
                //and differs

                bool newFont = FontChange(newStyle);

                if (newFont)
                {
                    while (FontLevel >= Count)
                    {
                        CloseTag();
                    }
                }

                //if the new wrapping is Wrap, and the current is NoWrap
                //the outer NoWrap must be removed
                if (
                    (newStyle.Wrapping == Wrapping.Wrap) &&
                    (_current.Wrapping == Wrapping.NoWrap) &&
                    (_writer.RenderDivNoWrap))
                {
                    while (_current.Wrapping != Wrapping.Wrap)
                    {
                        CloseTag();
                    }
                }
                //if the alignment differs for the same generation, close any divs at this level
                if ((newStyle.Alignment != _current.Alignment) && (_writer.RenderDivAlign))
                {
                    while (DivLevel >= Count)
                    {
                        CloseTag();
                    }
                }

                //determine if we will be opening a div before writing any break
                bool newDiv = DivChange(newStyle);

                //an opening div will function as a logical break
                if ((BreakPending) && (!(newDiv)))
                {
                    ((HtmlMobileTextWriter)_writer).WriteBreak();
                    BreakPending = false;
                }

                if (newDiv)
                {
                    while (_current.Bold || _current.Italic || (FontLevel == Count))
                    {
                        CloseTag();
                    }
                }

                newFont = FontChange(newStyle);
                newDiv  = DivChange(newStyle);

                //open div
                if (newDiv && newStyle.Layout)
                {
                    DivStyleTag div = new DivStyleTag(Count);
                    BreakPending = false;
                    if (
                        ((_writer.BeforeFirstControlWritten) || (_writer.InputWritten)) &&
                        (_writer.Device.Type == _pocketPC) &&
                        (_writer.Device.MinorVersion == 0) &&
                        (_writer.Device.MajorVersion == 4) &&
                        (newStyle.Alignment != _current.Alignment))
                    {
                        _writer.WriteBreak();
                        _writer.InputWritten = false;
                    }


                    _writer.WriteBeginTag("div");
                    DivLevel = Count;

                    if (newStyle.Wrapping == Wrapping.NoWrap)
                    {
                        if (_writer.RenderDivNoWrap)
                        {
                            _writer.Write(" nowrap");
                        }
                        div.Wrapping      = Wrapping.NoWrap;
                        _current.Wrapping = Wrapping.NoWrap;
                    }
                    else
                    {
                        div.Wrapping      = Wrapping.Wrap;
                        _current.Wrapping = Wrapping.Wrap;
                    }

                    if (newStyle.Alignment != _current.Alignment)
                    {
                        if (_writer.RenderDivAlign)
                        {
                            _writer.WriteAttribute(
                                "align",
                                Enum.GetName(typeof(Alignment), newStyle.Alignment));
                        }
                        _current.Alignment   = newStyle.Alignment;
                        div.Alignment        = newStyle.Alignment;
                        div.AlignmentWritten = true;
                    }
                    _tagsWritten.Push(div);
                    _writer.Write(">");
                }

                //open font
                if (newFont && newStyle.Format)
                {
                    FontStyleTag fontTag = new FontStyleTag(Count);
                    _writer.WriteBeginTag("font");
                    if (_current.FontSize != newStyle.FontSize)
                    {
                        String relativeSize;
                        if (newStyle.FontSize == FontSize.Large)
                        {
                            relativeSize = (
                                ((HtmlMobileTextWriter)_writer).Device.Type == _pocketPC) ? "+2" : "+1";
                            _current.FontSize = FontSize.Large;
                            fontTag.FontSize  = FontSize.Large;
                        }
                        else if (newStyle.FontSize == FontSize.Small)
                        {
                            relativeSize      = "-1";
                            _current.FontSize = FontSize.Small;
                            fontTag.FontSize  = FontSize.Small;
                        }
                        else //(newStyle.FontSize == FontSize.Normal)
                        {
                            relativeSize      = "+0";
                            _current.FontSize = FontSize.Normal;
                            fontTag.FontSize  = FontSize.Normal;
                        }
                        if (_writer.RenderFontSize)
                        {
                            _writer.WriteAttribute("size", relativeSize);
                        }
                    }

                    if (_current.FontColor != newStyle.FontColor)
                    {
                        if (_writer.RenderFontColor)
                        {
                            _writer.WriteAttribute(
                                "color",
                                ColorTranslator.ToHtml(newStyle.FontColor));
                        }
                        _current.FontColor = newStyle.FontColor;
                        fontTag.Color      = newStyle.FontColor;
                    }
                    if (_current.FontName != newStyle.FontName)
                    {
                        if (_writer.RenderFontName)
                        {
                            _writer.WriteAttribute("face", newStyle.FontName);
                        }
                        _current.FontName = newStyle.FontName;
                        fontTag.Name      = newStyle.FontName;
                    }
                    _writer.Write(">");
                    _tagsWritten.Push(fontTag);
                    FontLevel = Count;
                }

                //open bold
                if (newStyle.Format)
                {
                    if (newStyle.Bold && !_current.Bold && _writer.RenderBold)
                    {
                        _writer.WriteFullBeginTag("b");
                        _current.Bold = true;
                        _tagsWritten.Push(new BoldStyleTag(Count));
                    }

                    //open italic
                    if (newStyle.Italic && !_current.Italic && _writer.RenderItalic)
                    {
                        _writer.WriteFullBeginTag("i");
                        _current.Italic = true;
                        _tagsWritten.Push(new ItalicStyleTag(Count));
                    }
                }
                _inTransition = false;
            }
            finally
            {
                _writer = tempWriter;
            }
        }
        private void RenderItemsListWithoutTableTags(HtmlMobileTextWriter writer)
        {
            int startIndex = Control.FirstVisibleItemIndex;
            int pageSize   = Control.VisibleItemCount;
            ObjectListItemCollection   items     = Control.Items;
            IObjectListFieldCollection allFields = Control.AllFields;
            int count = allFields.Count;

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


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

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

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

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


            Style subCommandStyle = Control.CommandStyle;

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

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

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

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

                if (i < (nextStartIndex - 1))
                {
                    writer.WriteBreak();
                }
            }
            writer.ExitStyle(style, Control.BreakAfter);
        }
        private void 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);
        }