コード例 #1
0
 private void CloseSecondaryUIDivs(XhtmlMobileTextWriter writer)
 {
     for (int i = 0; i < _secondaryUIDivsOpened; i++)
     {
         if ((String)Device["usePOverDiv"] == "true")
         {
             writer.WriteEndTag("p");
         }
         else
         {
             writer.WriteEndTag("div");
         }
         writer.WriteLine();
     }
 }
コード例 #2
0
 private void ConditionalExitPagerSpan(XhtmlMobileTextWriter writer)
 {
     if (_pagerCssSpanWritten)
     {
         writer.WriteEndTag("span");
     }
 }
コード例 #3
0
 // For Style/CssClass args, see ASURT 144034
 /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderPostBackEventAsAnchor2"]/*' />
 protected virtual void RenderPostBackEventAsAnchor(
     XhtmlMobileTextWriter writer,
     String argument,
     String linkText,
     String accessKey,
     Style style,
     String cssClass)
 {
     writer.WriteBeginTag("a");
     writer.Write(" href=\"");
     PageAdapter.RenderUrlPostBackEvent(writer, Control.UniqueID /* target */, argument);
     writer.Write("\" ");
     if (accessKey != null && accessKey.Length > 0)
     {
         writer.WriteAttribute("accesskey", accessKey);
     }
     if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true")
     {
         if (CssLocation != StyleSheetLocation.PhysicalFile)
         {
             String className = writer.GetCssFormatClassName(style);
             if (className != null)
             {
                 writer.WriteAttribute("class", className);
             }
         }
         else if (cssClass != null && cssClass.Length > 0)
         {
             writer.WriteAttribute("class", cssClass, true /* encode */);
         }
     }
     writer.Write(">");
     writer.WriteEncodedText(linkText);
     writer.WriteEndTag("a");
 }
コード例 #4
0
 /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderClosingListTag"]/*' />
 protected virtual void RenderClosingListTag(XhtmlMobileTextWriter writer, String tagName)
 {
     if (CssLocation == StyleSheetLocation.PhysicalFile && (String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true")
     {
         writer.WriteEndTag(tagName);
         ConditionalPopPhysicalCssClass(writer);
     }
     else if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true")
     {
         writer.ExitStyle(Style);
     }
     else
     {
         writer.WriteEndTag(tagName);
     }
 }
コード例 #5
0
        // Render closing </span> in case the stylesheet location has been specified as a physical file.
        /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalRenderClosingSpanElement"]/*' />
        protected virtual void ConditionalRenderClosingSpanElement(XhtmlMobileTextWriter writer)
        {
            String classAttribute = (String)Control.CustomAttributes[XhtmlConstants.CssClassCustomAttribute];

            if (_physicalSpanClassOpen)
            {
                Debug.Assert(_physicalCssClassPushed, "_physicalSpanClassOpen implies _physicalCssClassPushed");
                writer.WriteEndTag("span");
                writer.WriteLine();
                ConditionalPopPhysicalCssClass(writer); // resets _physicalCssClassPushed
                _physicalSpanClassOpen = false;
            }
        }
コード例 #6
0
        private void RenderClosingBodyElement(XhtmlMobileTextWriter writer)
        {
            Style formStyle = ((ControlAdapter)Page.ActiveForm.Adapter).Style;

            if (CssLocation == StyleSheetLocation.PhysicalFile)
            {
                writer.WriteEndTag("body");
                if (_pushedCssClassForBody)
                {
                    writer.PopPhysicalCssClass();
                }
            }
            else if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true" &&
                     (String)Device[XhtmlConstants.SupportsBodyClassAttribute] != "false")
            {
                writer.ExitStyle(formStyle); // writes the closing body element.
            }
            else
            {
                writer.WriteEndTag("body");
            }
        }
コード例 #7
0
        // Render closing </div> in case the stylesheet location has been specified as a physical file.
        /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalRenderClosingDivElement"]/*' />
        protected virtual void ConditionalRenderClosingDivElement(XhtmlMobileTextWriter writer)
        {
            if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] == "true")
            {
                return;
            }
            String classAttribute = (String)Control.CustomAttributes[XhtmlConstants.CssClassCustomAttribute];

            if (CssLocation == StyleSheetLocation.PhysicalFile)
            {
                writer.WriteLine();
                if ((String)Device["usePOverDiv"] == "true")
                {
                    writer.WriteEndTag("p");
                }
                else
                {
                    writer.WriteEndTag("div");
                }
                writer.WriteLine();
                ConditionalPopPhysicalCssClass(writer);
            }
        }
コード例 #8
0
        void RenderSelectElement(XhtmlMobileTextWriter writer)
        {
            if ((String)Device["supportsSelectFollowingTable"] == "false" && writer.CachedEndTag == "table")
            {
                writer.Write("&nbsp;");
            }

            ConditionalEnterStyle(writer, Style);
            writer.WriteBeginTag("select");

            if (Control.SelectType == ListSelectType.MultiSelectListBox)
            {
                writer.WriteAttribute("multiple", "multiple");
            }

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

            writer.WriteAttribute("name", Control.UniqueID);
            ConditionalRenderClassAttribute(writer);
            writer.Write(">");

            for (int itemIndex = 0; itemIndex < Control.Items.Count; itemIndex++)
            {
                MobileListItem item = Control.Items[itemIndex];
                writer.WriteBeginTag("option");
                WriteItemValueAttribute(writer, itemIndex, item.Value);
                if (item.Selected && (Control.IsMultiSelect || itemIndex == Control.SelectedIndex))
                {
                    writer.Write(" selected=\"selected\">");
                }
                else
                {
                    writer.Write(">");
                }
                writer.WriteEncodedText(item.Text);
                writer.WriteLine("</option>");
            }
            ConditionalSetPendingBreak(writer);
            writer.WriteEndTag("select");
            writer.WriteLine();
            ConditionalPopPhysicalCssClass(writer);
            ConditionalExitStyle(writer, Style);
        }
コード例 #9
0
        private void RenderRule(XhtmlMobileTextWriter writer, Color foreColor, int columnSpan)
        {
            if (CssLocation == StyleSheetLocation.PhysicalFile || Device["requiresXhtmlCssSuppression"] == "true")
            {
                // Review: Since, if there is a physical stylesheet, we cannot know the intended foreColor,
                // do not render a rule.
                return;
            }
            writer.Write("<tr>");
            Style hruleStyle = new Style();

            // Rendering <td...> with background color equal to the style's forecolor renders a thin
            // rule with color forecolor, as intended.
            hruleStyle[Style.BackColorKey] = foreColor == Color.Empty ? Color.Black : foreColor;
            NameValueCollection additionalAttributes = new NameValueCollection();

            additionalAttributes["colspan"] = columnSpan.ToString(CultureInfo.InvariantCulture);
            writer.EnterStyleInternal(hruleStyle, "td", StyleFilter.BackgroundColor, additionalAttributes);
            writer.ExitStyle(Style);
            writer.WriteEndTag("tr");
        }
コード例 #10
0
 private void ConditionalRenderStyleElement(XhtmlMobileTextWriter writer)
 {
     if (!writer.IsStyleSheetEmpty() && CssLocation == StyleSheetLocation.Internal)
     {
         bool requiresComments = (String)Device["requiresCommentInStyleElement"] == "true";
         writer.WriteLine();
         writer.WriteBeginTag("style");
         writer.Write(" type=\"text/css\">");
         writer.WriteLine();
         if (requiresComments)
         {
             writer.WriteLine("<!--");
         }
         writer.Write(writer.GetStyles());
         if (requiresComments)
         {
             writer.WriteLine("-->");
         }
         writer.WriteEndTag("style");
         writer.WriteLine();
     }
 }
コード例 #11
0
 private void ConditionalExitPagerSpan(XhtmlMobileTextWriter writer) {
     if (_pagerCssSpanWritten) {
         writer.WriteEndTag("span");
     }
 }
コード例 #12
0
 private void RenderClosingBodyElement(XhtmlMobileTextWriter writer) {
     Style formStyle = ((ControlAdapter)Page.ActiveForm.Adapter).Style;
     if (CssLocation == StyleSheetLocation.PhysicalFile) {
         writer.WriteEndTag("body");
         if (_pushedCssClassForBody) {
             writer.PopPhysicalCssClass();
         }
     }
     else if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true" &&
         (String)Device[XhtmlConstants.SupportsBodyClassAttribute] != "false") {
         writer.ExitStyle(formStyle); // writes the closing body element.
     }
     else {
         writer.WriteEndTag ("body");
     }
 }
コード例 #13
0
 private void CloseSecondaryUIDivs(XhtmlMobileTextWriter writer) {
     for (int i = 0; i < _secondaryUIDivsOpened; i++) {
         if((String)Device["usePOverDiv"] == "true") {
             writer.WriteEndTag("p");
         }
         else {
             writer.WriteEndTag("div");
         }
         writer.WriteLine();
     }
 }
コード例 #14
0
 private void ConditionalRenderStyleElement (XhtmlMobileTextWriter writer) {
     if (!writer.IsStyleSheetEmpty () && CssLocation == StyleSheetLocation.Internal) {
         bool requiresComments = (String)Device["requiresCommentInStyleElement"] == "true";
         writer.WriteLine();
         writer.WriteBeginTag("style");
         writer.Write(" type=\"text/css\">");
         writer.WriteLine();
         if (requiresComments) {
             writer.WriteLine("<!--");
         }
         writer.Write(writer.GetStyles());
         if (requiresComments) {
             writer.WriteLine("-->");
         }
         writer.WriteEndTag("style");
         writer.WriteLine(); 
     }
 }
コード例 #15
0
        /// <include file='doc\XhtmlBasicPageAdapter.uex' path='docs/doc[@for="XhtmlPageAdapter.Render"]/*' />
        public override void Render (XhtmlMobileTextWriter writer) {
            writer.BeginResponse ();
            if (Page.Request.Browser["requiresPragmaNoCacheHeader"] == "true") {
                Page.Response.AppendHeader("Pragma", "no-cache");
            }
            InitWriterState(writer);          
            writer.BeginCachedRendering ();
            // For consistency with HTML, we render the form style with body tag.
            RenderOpeningBodyElement(writer);
            // Certain WML 2.0 devices require that we write an onevent onenterforward setvar snippet.
            // We cannot know the relevant variables until after the form is rendered, so we mark this
            // position.  The setvar elements will be inserted into the cached rendering here.
            writer.MarkWmlOnEventLocation ();
            Page.ActiveForm.RenderControl(writer);
            RenderClosingBodyElement(writer);
            writer.ClearPendingBreak ();
            writer.EndCachedRendering ();

            // Note: first and third arguments are not used.
            writer.BeginFile (Page.Request.Url.ToString (), Page.Device.PreferredRenderingMime, Page.Response.Charset);
            String supportsXmlDeclaration = Device["supportsXmlDeclaration"];
            // Invariant culture not needed, included for best practices compliance.
            if (supportsXmlDeclaration == null ||
                !String.Equals(supportsXmlDeclaration, "false", StringComparison.OrdinalIgnoreCase)) {
                writer.WriteXmlDeclaration ();
            }
            writer.WriteDoctypeDeclaration(DocumentType);
            // Review: Hard coded xmlns.
            writer.WriteFullBeginTag ("html xmlns=\"http://www.w3.org/1999/xhtml\"");
            writer.WriteLine ();
            writer.WriteFullBeginTag ("head");
            writer.WriteLine ();
            writer.WriteFullBeginTag ("title");
            if (Page.ActiveForm.Title != null) {
                writer.WriteEncodedText(Page.ActiveForm.Title);
            }
            writer.WriteEndTag ("title");
            ConditionalRenderLinkElement (writer);
            ConditionalRenderStyleElement (writer);
            writer.WriteEndTag ("head");
            writer.WriteLine ();
            writer.WriteCachedMarkup (); // includes body tag.
            writer.WriteLine ();
            writer.WriteEndTag ("html");
            writer.EndFile ();
            if (!DoesDeviceRequireCssSuppression()) {
                if (CssLocation == StyleSheetLocation.ApplicationCache && !writer.IsStyleSheetEmpty()) {
                    // Recall that Page.Cache has application scope
                    Page.Cache.Insert(writer.CacheKey, writer.GetStyles (), null, DateTime.MaxValue, _cacheExpirationTime);
                }
                else if (CssLocation == StyleSheetLocation.SessionState && !writer.IsStyleSheetEmpty()) {
                    Page.Session[writer.SessionKey] = writer.GetStyles();
                }
            }

            writer.EndResponse ();
        }
コード例 #16
0
 /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderEndLink"]/*' />
 protected virtual void RenderEndLink(XhtmlMobileTextWriter writer)
 {
     writer.WriteEndTag("a");
 }
コード例 #17
0
        /// <include file='doc\XhtmlBasicPhoneCallAdapter.uex' path='docs/doc[@for="XhtmlPhoneCallAdapter.Render"]/*' />
        public override void Render(XhtmlMobileTextWriter writer)
        {
            ConditionalClearPendingBreak(writer);
            Style style = Style;
            StyleFilter filter = writer.CurrentStyleClass.GetFilter(style);
            if ((filter & XhtmlConstants.Layout) != 0) {
                ConditionalEnterLayout(writer, style);
            }
            if (Device.CanInitiateVoiceCall) {
                String text = Control.Text;
                String phoneNumber = Control.PhoneNumber;

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

                writer.WriteBeginTag("a");

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

                foreach (char ch in phoneNumber) {
                    if (ch >= '0' && ch <= '9' || ch == '#' || ch == '+') {
                        writer.Write(ch);
                    }
                }
                writer.Write("\"");
                ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
                String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
                if (CssLocation != StyleSheetLocation.PhysicalFile) {
                    String className = writer.GetCssFormatClassName(style);
                    if (className != null) {
                        writer.WriteAttribute ("class", className);
                    }
                }
                else if (cssClass != null && cssClass.Length > 0) {
                    writer.WriteAttribute ("class", cssClass, true /* encode */);
                }
                writer.Write(">");
                writer.WriteEncodedText(text);
                writer.WriteEndTag("a");
                ConditionalSetPendingBreakAfterInline(writer);
            }
            else {
                // Format the text string based on properties
                String text = String.Format(
                    CultureInfo.CurrentCulture,
                    Control.AlternateFormat,
                    Control.Text,
                    Control.PhoneNumber);
                String url = Control.AlternateUrl;

                // If URI specified, create a link.  Otherwise, only text is displayed.
                if (url != null && url.Length > 0) {
                    String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
                    String accessKey = GetCustomAttributeValue(XhtmlConstants.AccessKeyCustomAttribute);
                    RenderBeginLink(writer, url, accessKey, style, cssClass);
                    writer.WriteEncodedText(text);
                    RenderEndLink(writer);
                    ConditionalSetPendingBreakAfterInline(writer);
                }
                else {
                    writer.WritePendingBreak();
                    ConditionalEnterFormat(writer, style);
                    ConditionalRenderOpeningSpanElement(writer);
                    writer.WriteEncodedText(text);
                    ConditionalRenderClosingSpanElement(writer);
                    ConditionalExitFormat(writer, style);
                    ConditionalSetPendingBreak(writer);
                }
            }
            if ((filter & XhtmlConstants.Layout) != 0) {
                ConditionalExitLayout(writer, style);
            }
        }
コード例 #18
0
        private void RenderItemsListWithoutTableTags(XhtmlMobileTextWriter writer)
        {
            if (Control.VisibleItemCount == 0) {
                return;
            }

            ConditionalRenderOpeningDivElement(writer);
            int startIndex = Control.FirstVisibleItemIndex;
            int pageSize = Control.VisibleItemCount;
            ObjectListItemCollection items = Control.Items;
            IObjectListFieldCollection allFields = Control.AllFields;
            int count = allFields.Count;

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


            Style style = this.Style;
            Style labelStyle = Control.LabelStyle;
            String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
            String labelClass = GetCustomAttributeValue(XhtmlConstants.CssLabelClassCustomAttribute); 
            if (labelClass == null || labelClass.Length == 0) {
                labelClass = cssClass;
            }
            ConditionalEnterStyle(writer, labelStyle);
            bool requiresLabelClassSpan = CssLocation == StyleSheetLocation.PhysicalFile && labelClass != null && labelClass.Length > 0;
            if (requiresLabelClassSpan) {
                writer.WriteBeginTag("span");
                writer.WriteAttribute("class", labelClass, true);
                writer.Write(">");
            }
            writer.Write(Control.AllFields[labelFieldIndex].Title);
            writer.SetPendingBreak();
            if (requiresLabelClassSpan) {
                writer.WriteEndTag("span");
            }
            ConditionalExitStyle(writer, labelStyle);
            writer.WritePendingBreak();

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


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

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

                String accessKey = GetCustomAttributeValue(item, XhtmlConstants.AccessKeyCustomAttribute);
                String itemClass = GetCustomAttributeValue(item, XhtmlConstants.CssClassCustomAttribute);
                if (itemRequiresHyperlink) {

                    RenderPostBackEventAsAnchor(writer,
                        hasDefaultCommand ?
                        item.Index.ToString(CultureInfo.InvariantCulture) :
                        String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index),
                        item[labelFieldIndex], accessKey, Style, cssClass);
                }
                else {
                    bool requiresItemClassSpan = CssLocation == StyleSheetLocation.PhysicalFile && itemClass != null && itemClass.Length > 0;
                    if (requiresItemClassSpan) {
                        writer.WriteBeginTag("span");
                        writer.WriteAttribute("class", itemClass, true);
                        writer.Write(">");
                    }
                    writer.Write(item[labelFieldIndex]);
                    if (requiresItemClassSpan) {
                        writer.WriteEndTag("span");
                    }
                }

                if (itemRequiresMoreButton) {
                    String commandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute);
                    BooleanOption cachedItalic = subCommandStyle.Font.Italic;
                    subCommandStyle.Font.Italic = BooleanOption.False;
                    ConditionalEnterFormat(writer, subCommandStyle);
                    if ((String)Device[XhtmlConstants.BreaksOnInlineElements] != "true") {
                        writer.Write(" [");
                    }
                    ConditionalExitFormat(writer, subCommandStyle);
                    subCommandStyle.Font.Italic = cachedItalic;
                    ConditionalEnterFormat(writer, subCommandStyle);
                    String controlMT = Control.MoreText;
                    String moreText = (controlMT == null || controlMT.Length == 0) ?
                        GetDefaultLabel(MoreLabel) :
                        controlMT;
                    RenderPostBackEventAsAnchor(writer,
                        String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index), 
                        moreText, 
                        null /*accessKey*/,
                        subCommandStyle,
                        commandClass);
                    ConditionalExitFormat(writer, subCommandStyle);
                    subCommandStyle.Font.Italic = BooleanOption.False;
                    ConditionalEnterFormat(writer, subCommandStyle);
                    if ((String)Device[XhtmlConstants.BreaksOnInlineElements] != "true") {
                        writer.Write("]");
                    }
                    ConditionalExitFormat(writer, subCommandStyle);
                    subCommandStyle.Font.Italic = cachedItalic;
                }

                if (i < (nextStartIndex - 1)) {
                    writer.WriteBreak();            
                }
                else {
                    writer.SetPendingBreak();
                }
            }
            ConditionalExitStyle(writer, style);
            ConditionalRenderClosingDivElement(writer);
        }
コード例 #19
0
        void RenderInputElementSet (XhtmlMobileTextWriter writer) {
            string wrappingTag = Device.Tables ? "table" : 
                (((string)Device["usePOverDiv"]  == "true") ? "p" : "div");
            ListSelectType selectType = Control.SelectType;
            MobileListItemCollection items = Control.Items;
            // Review: We always render a table.  Should we optimize away the table tags when the alignment is left?
            String selectTypeString =
                (selectType == ListSelectType.Radio) ?
                "radio" :
                "checkbox";

            ClearPendingBreakIfDeviceBreaksOnBlockLevel(writer); // Since we are writing a block-level element in all cases.
            ConditionalEnterLayout(writer, Style);
            RenderOpeningListTag(writer, wrappingTag);
            for(int itemIndex = 0; itemIndex < items.Count; itemIndex++) {
                MobileListItem item = items[itemIndex];
                if (Device.Tables) {
                    writer.WriteFullBeginTag("tr");
                    writer.WriteFullBeginTag("td");
                }

                writer.WriteBeginTag("input");
                writer.WriteAttribute("type", selectTypeString);
                writer.WriteAttribute("name", Control.UniqueID);
                WriteItemValueAttribute(writer, itemIndex, item.Value);
                String accessKey = GetCustomAttributeValue(item, XhtmlConstants.AccessKeyCustomAttribute);
                if (accessKey != null && accessKey.Length > 0) {
                    writer.WriteAttribute("accesskey", accessKey, true);
                }
                // Assumption: Device.SupportsUncheck is always true for Xhtml devices.
                if (item.Selected && 
                    (Control.IsMultiSelect || itemIndex == Control.SelectedIndex)) {
                    writer.Write(" checked=\"checked\"/>");
                }
                else {
                    writer.Write("/>");
                }

                writer.WriteEncodedText(item.Text);
                if (Device.Tables) {
                    writer.WriteEndTag("td");
                }
                if((string)Device["usePOverDiv"]  == "true" || !Device.Tables) {
                    writer.Write("<br/>");
                }
                if (Device.Tables) {
                    writer.WriteEndTag("tr");
                }
            }
            RenderClosingListTag(writer, wrappingTag);
            ConditionalExitLayout(writer, Style);
        }
コード例 #20
0
 /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderClosingListTag"]/*' />
 protected virtual void RenderClosingListTag(XhtmlMobileTextWriter writer, String tagName) {
     if (CssLocation == StyleSheetLocation.PhysicalFile  && (String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true") {
         writer.WriteEndTag(tagName);
         ConditionalPopPhysicalCssClass(writer);
     }
     else if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true") {
         writer.ExitStyle(Style);
     }
     else {
         writer.WriteEndTag(tagName);
     }
 }
コード例 #21
0
        // Render the details view
        /// <include file='doc\XhtmlBasicObjectListAdapter.uex' path='docs/doc[@for="XhtmlObjectListAdapter.RenderItemDetails"]/*' />
        protected virtual void RenderItemDetails(XhtmlMobileTextWriter writer, ObjectListItem item) {
            if (Control.AllFields.Count == 0) {
                return;
            }
            if (!Device.Tables) {
                RenderItemDetailsWithoutTableTags(writer, item);
                return;
            }


            Style labelStyle = Control.LabelStyle;
            Style subCommandStyle = Control.CommandStyle;
            Style subCommandStyleNoItalic = (Style)subCommandStyle.Clone();
            subCommandStyleNoItalic.Font.Italic = BooleanOption.False;

            writer.ClearPendingBreak(); // we are writing a block level element in all cases.
            ConditionalEnterLayout(writer, Style);
            writer.WriteBeginTag ("table");
            ConditionalRenderClassAttribute(writer);
            writer.Write(">");
            writer.Write("<tr><td colspan=\"2\">");
            ConditionalEnterStyle(writer, labelStyle);
            writer.WriteEncodedText (item[Control.LabelFieldIndex]);
            ConditionalExitStyle(writer, labelStyle);
            writer.WriteLine("</td></tr>");
            Color foreColor = (Color)Style[Style.ForeColorKey, true];
            RenderRule (writer, foreColor, 2);
            RenderItemFieldsInDetailsView (writer, item);
            RenderRule (writer, foreColor, 2);
            ConditionalPopPhysicalCssClass(writer);
            writer.WriteEndTag("table");
            ConditionalExitLayout(writer, Style);

            ConditionalEnterStyle(writer, subCommandStyleNoItalic);
            writer.Write("[&nbsp;");

            ObjectListCommandCollection commands = Control.Commands;
            String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
            String subCommandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute);
            if (subCommandClass == null || subCommandClass.Length == 0) {
                subCommandClass = cssClass;
            }

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

            RenderPostBackEventAsAnchor(writer, BackToList, backCommandText, null /* accessKey */, subCommandStyle, subCommandClass);
            writer.Write("&nbsp;]");
            ConditionalExitStyle(writer, subCommandStyleNoItalic);
        }
コード例 #22
0
 // Render closing </span> in case the stylesheet location has been specified as a physical file.
 /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalRenderClosingSpanElement"]/*' />
 protected virtual void ConditionalRenderClosingSpanElement(XhtmlMobileTextWriter writer) {            
     String classAttribute = (String) Control.CustomAttributes[XhtmlConstants.CssClassCustomAttribute];
     if (_physicalSpanClassOpen) {
         Debug.Assert(_physicalCssClassPushed, "_physicalSpanClassOpen implies _physicalCssClassPushed");
         writer.WriteEndTag("span");
         writer.WriteLine();
         ConditionalPopPhysicalCssClass(writer); // resets _physicalCssClassPushed
         _physicalSpanClassOpen = false;
     }
 }
コード例 #23
0
        /// <include file='doc\XhtmlBasicFormAdapter.uex' path='docs/doc[@for="XhtmlFormAdapter.Render"]/*' />
        public override void Render (XhtmlMobileTextWriter writer) {
            // Note: <head>, <body> rendered by page adapter, as in HTML case.
            String formsAuthCookieName = FormsAuthentication.FormsCookieName;
            if(!Device.SupportsRedirectWithCookie)
            {
                if(formsAuthCookieName != null && formsAuthCookieName.Length > 0)
                {
                    HttpContext.Current.Response.Cookies.Remove(formsAuthCookieName);
                }
            }
            writer.WriteBeginTag ("form");
            writer.WriteAttribute ("id", Control.ClientID);
            writer.WriteAttribute ("method", Control.Method.ToString().ToLower(CultureInfo.CurrentCulture));
            writer.Write (" action=\"");
            RenderPostbackUrl(writer);
            if(Control.Action.Length > 0) {
                if(Control.Action.IndexOf("?", StringComparison.Ordinal) != -1) {
                    writer.Write("&");
                }
                else {
                    writer.Write("?");
                }
            }
            else {
                writer.Write("?");
            }
            writer.Write(Page.UniqueFilePathSuffix);

            if (Control.Method != FormMethod.Get &&
                Control.Action.Length == 0) {   // VSWhidbey 411176: We don't include QueryStringText if Action is explicitly set

                String queryStringText = PreprocessQueryString(Page.QueryStringText);
                if (queryStringText != null && queryStringText.Length > 0) {
                    String amp = (String)Device[XhtmlConstants.SupportsUrlAttributeEncoding] != "false"  ? "&amp;" : "&";
                    writer.Write(amp);
                    if((String)Device[XhtmlConstants.SupportsUrlAttributeEncoding] != "false") {
                        writer.WriteEncodedText(queryStringText);
                    }
                    else {
                        writer.Write(queryStringText);
                    }
                }
            }
            writer.WriteLine ("\">");
            bool needDivStyle = (String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true" &&
                (String)Device["supportsBodyClassAttribute"] == "false";
            if (!needDivStyle) {
                if((String)Device["usePOverDiv"] == "true")
                    writer.WriteFullBeginTag("p");
                else
                    writer.WriteFullBeginTag ("div");
            }
            else {
                if((String)Device["usePOverDiv"] == "true")
                    writer.EnterStyle(Style, "p");
                else
                    writer.EnterStyle (Style, "div");
            }
            RenderPostBackHeader (writer);
            // Renders hidden variables for IPostBackDataHandlers which are
            // not displayed due to pagination or secondary UI.
            RenderOffPageVariables(writer, Control, Control.CurrentPage);
            
            RenderChildren (writer);
            if (!needDivStyle) {
                if((String)Device["usePOverDiv"] == "true")
                    writer.WriteEndTag("p");
                else
                    writer.WriteEndTag ("div");
            }
            else {
                if((String)Device["usePOverDiv"] == "true")
                    writer.ExitStyle(Style);
                else
                    writer.ExitStyle (Style);
            }
            writer.WriteEndTag ("form");
        }
コード例 #24
0
        void RenderSelectElement (XhtmlMobileTextWriter writer) {
            
            if ((String)Device["supportsSelectFollowingTable"] == "false" && writer.CachedEndTag == "table") {
                writer.Write("&nbsp;");
            }

            ConditionalEnterStyle(writer, Style);
            writer.WriteBeginTag ("select");

            if (Control.SelectType == ListSelectType.MultiSelectListBox) {
                writer.WriteAttribute ("multiple", "multiple");
            }

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

            writer.WriteAttribute ("name", Control.UniqueID);
            ConditionalRenderClassAttribute(writer);
            writer.Write (">");

            for (int itemIndex = 0; itemIndex < Control.Items.Count; itemIndex++) {
                MobileListItem item = Control.Items[itemIndex];
                writer.WriteBeginTag ("option");
                WriteItemValueAttribute (writer, itemIndex, item.Value);
                if (item.Selected && (Control.IsMultiSelect || itemIndex == Control.SelectedIndex)) {
                    writer.Write (" selected=\"selected\">");
                }
                else {
                    writer.Write (">");
                }
                writer.WriteEncodedText (item.Text);
                writer.WriteLine ("</option>");
            }
            ConditionalSetPendingBreak(writer);
            writer.WriteEndTag ("select");            
            writer.WriteLine ();      
            ConditionalPopPhysicalCssClass(writer);
            ConditionalExitStyle(writer, Style);
        }
コード例 #25
0
        /// <include file='doc\XhtmlBasicFormAdapter.uex' path='docs/doc[@for="XhtmlFormAdapter.Render"]/*' />
        public override void Render(XhtmlMobileTextWriter writer)
        {
            // Note: <head>, <body> rendered by page adapter, as in HTML case.
            String formsAuthCookieName = FormsAuthentication.FormsCookieName;

            if (!Device.SupportsRedirectWithCookie)
            {
                if (formsAuthCookieName != null && formsAuthCookieName.Length > 0)
                {
                    HttpContext.Current.Response.Cookies.Remove(formsAuthCookieName);
                }
            }
            writer.WriteBeginTag("form");
            writer.WriteAttribute("id", Control.ClientID);
            writer.WriteAttribute("method", Control.Method.ToString().ToLower(CultureInfo.CurrentCulture));
            writer.Write(" action=\"");
            RenderPostbackUrl(writer);
            if (Control.Action.Length > 0)
            {
                if (Control.Action.IndexOf("?", StringComparison.Ordinal) != -1)
                {
                    writer.Write("&");
                }
                else
                {
                    writer.Write("?");
                }
            }
            else
            {
                writer.Write("?");
            }
            writer.Write(Page.UniqueFilePathSuffix);

            if (Control.Method != FormMethod.Get &&
                Control.Action.Length == 0)     // VSWhidbey 411176: We don't include QueryStringText if Action is explicitly set

            {
                String queryStringText = PreprocessQueryString(Page.QueryStringText);
                if (queryStringText != null && queryStringText.Length > 0)
                {
                    String amp = (String)Device[XhtmlConstants.SupportsUrlAttributeEncoding] != "false"  ? "&amp;" : "&";
                    writer.Write(amp);
                    if ((String)Device[XhtmlConstants.SupportsUrlAttributeEncoding] != "false")
                    {
                        writer.WriteEncodedText(queryStringText);
                    }
                    else
                    {
                        writer.Write(queryStringText);
                    }
                }
            }
            writer.WriteLine("\">");
            bool needDivStyle = (String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true" &&
                                (String)Device["supportsBodyClassAttribute"] == "false";

            if (!needDivStyle)
            {
                if ((String)Device["usePOverDiv"] == "true")
                {
                    writer.WriteFullBeginTag("p");
                }
                else
                {
                    writer.WriteFullBeginTag("div");
                }
            }
            else
            {
                if ((String)Device["usePOverDiv"] == "true")
                {
                    writer.EnterStyle(Style, "p");
                }
                else
                {
                    writer.EnterStyle(Style, "div");
                }
            }
            RenderPostBackHeader(writer);
            // Renders hidden variables for IPostBackDataHandlers which are
            // not displayed due to pagination or secondary UI.
            RenderOffPageVariables(writer, Control, Control.CurrentPage);

            RenderChildren(writer);
            if (!needDivStyle)
            {
                if ((String)Device["usePOverDiv"] == "true")
                {
                    writer.WriteEndTag("p");
                }
                else
                {
                    writer.WriteEndTag("div");
                }
            }
            else
            {
                if ((String)Device["usePOverDiv"] == "true")
                {
                    writer.ExitStyle(Style);
                }
                else
                {
                    writer.ExitStyle(Style);
                }
            }
            writer.WriteEndTag("form");
        }
コード例 #26
0
        /// <include file='doc\XhtmlBasicPhoneCallAdapter.uex' path='docs/doc[@for="XhtmlPhoneCallAdapter.Render"]/*' />
        public override void Render(XhtmlMobileTextWriter writer)
        {
            ConditionalClearPendingBreak(writer);
            Style       style  = Style;
            StyleFilter filter = writer.CurrentStyleClass.GetFilter(style);

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

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

                writer.WriteBeginTag("a");

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

                foreach (char ch in phoneNumber)
                {
                    if (ch >= '0' && ch <= '9' || ch == '#' || ch == '+')
                    {
                        writer.Write(ch);
                    }
                }
                writer.Write("\"");
                ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
                String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
                if (CssLocation != StyleSheetLocation.PhysicalFile)
                {
                    String className = writer.GetCssFormatClassName(style);
                    if (className != null)
                    {
                        writer.WriteAttribute("class", className);
                    }
                }
                else if (cssClass != null && cssClass.Length > 0)
                {
                    writer.WriteAttribute("class", cssClass, true /* encode */);
                }
                writer.Write(">");
                writer.WriteEncodedText(text);
                writer.WriteEndTag("a");
                ConditionalSetPendingBreakAfterInline(writer);
            }
            else
            {
                // Format the text string based on properties
                String text = String.Format(
                    CultureInfo.CurrentCulture,
                    Control.AlternateFormat,
                    Control.Text,
                    Control.PhoneNumber);
                String url = Control.AlternateUrl;

                // If URI specified, create a link.  Otherwise, only text is displayed.
                if (url != null && url.Length > 0)
                {
                    String cssClass  = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
                    String accessKey = GetCustomAttributeValue(XhtmlConstants.AccessKeyCustomAttribute);
                    RenderBeginLink(writer, url, accessKey, style, cssClass);
                    writer.WriteEncodedText(text);
                    RenderEndLink(writer);
                    ConditionalSetPendingBreakAfterInline(writer);
                }
                else
                {
                    writer.WritePendingBreak();
                    ConditionalEnterFormat(writer, style);
                    ConditionalRenderOpeningSpanElement(writer);
                    writer.WriteEncodedText(text);
                    ConditionalRenderClosingSpanElement(writer);
                    ConditionalExitFormat(writer, style);
                    ConditionalSetPendingBreak(writer);
                }
            }
            if ((filter & XhtmlConstants.Layout) != 0)
            {
                ConditionalExitLayout(writer, style);
            }
        }
コード例 #27
0
 /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderEndLink"]/*' />
 protected virtual void RenderEndLink(XhtmlMobileTextWriter writer) {
     writer.WriteEndTag("a");
 }
コード例 #28
0
        /// <include file='doc\XhtmlBasicPageAdapter.uex' path='docs/doc[@for="XhtmlPageAdapter.Render"]/*' />
        public override void Render(XhtmlMobileTextWriter writer)
        {
            writer.BeginResponse();
            if (Page.Request.Browser["requiresPragmaNoCacheHeader"] == "true")
            {
                Page.Response.AppendHeader("Pragma", "no-cache");
            }
            InitWriterState(writer);
            writer.BeginCachedRendering();
            // For consistency with HTML, we render the form style with body tag.
            RenderOpeningBodyElement(writer);
            // Certain WML 2.0 devices require that we write an onevent onenterforward setvar snippet.
            // We cannot know the relevant variables until after the form is rendered, so we mark this
            // position.  The setvar elements will be inserted into the cached rendering here.
            writer.MarkWmlOnEventLocation();
            Page.ActiveForm.RenderControl(writer);
            RenderClosingBodyElement(writer);
            writer.ClearPendingBreak();
            writer.EndCachedRendering();

            // Note: first and third arguments are not used.
            writer.BeginFile(Page.Request.Url.ToString(), Page.Device.PreferredRenderingMime, Page.Response.Charset);
            String supportsXmlDeclaration = Device["supportsXmlDeclaration"];

            // Invariant culture not needed, included for best practices compliance.
            if (supportsXmlDeclaration == null ||
                !String.Equals(supportsXmlDeclaration, "false", StringComparison.OrdinalIgnoreCase))
            {
                writer.WriteXmlDeclaration();
            }
            writer.WriteDoctypeDeclaration(DocumentType);
            // Review: Hard coded xmlns.
            writer.WriteFullBeginTag("html xmlns=\"http://www.w3.org/1999/xhtml\"");
            writer.WriteLine();
            writer.WriteFullBeginTag("head");
            writer.WriteLine();
            writer.WriteFullBeginTag("title");
            if (Page.ActiveForm.Title != null)
            {
                writer.WriteEncodedText(Page.ActiveForm.Title);
            }
            writer.WriteEndTag("title");
            ConditionalRenderLinkElement(writer);
            ConditionalRenderStyleElement(writer);
            writer.WriteEndTag("head");
            writer.WriteLine();
            writer.WriteCachedMarkup();  // includes body tag.
            writer.WriteLine();
            writer.WriteEndTag("html");
            writer.EndFile();
            if (!DoesDeviceRequireCssSuppression())
            {
                if (CssLocation == StyleSheetLocation.ApplicationCache && !writer.IsStyleSheetEmpty())
                {
                    // Recall that Page.Cache has application scope
                    Page.Cache.Insert(writer.CacheKey, writer.GetStyles(), null, DateTime.MaxValue, _cacheExpirationTime);
                }
                else if (CssLocation == StyleSheetLocation.SessionState && !writer.IsStyleSheetEmpty())
                {
                    Page.Session[writer.SessionKey] = writer.GetStyles();
                }
            }

            writer.EndResponse();
        }
コード例 #29
0
 // Render closing </div> in case the stylesheet location has been specified as a physical file.
 /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalRenderClosingDivElement"]/*' />
 protected virtual void ConditionalRenderClosingDivElement(XhtmlMobileTextWriter writer) {
     if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] == "true") {
         return;
     }
     String classAttribute = (String) Control.CustomAttributes[XhtmlConstants.CssClassCustomAttribute];
     if (CssLocation == StyleSheetLocation.PhysicalFile) {
         writer.WriteLine();
         if ((String)Device["usePOverDiv"] == "true") {
             writer.WriteEndTag("p");
         }
         else {
             writer.WriteEndTag("div");
         }
         writer.WriteLine();
         ConditionalPopPhysicalCssClass(writer);
     }
 }
コード例 #30
0
        // Render the details view
        /// <include file='doc\XhtmlBasicObjectListAdapter.uex' path='docs/doc[@for="XhtmlObjectListAdapter.RenderItemDetails"]/*' />
        protected virtual void RenderItemDetails(XhtmlMobileTextWriter writer, ObjectListItem item)
        {
            if (Control.AllFields.Count == 0)
            {
                return;
            }
            if (!Device.Tables)
            {
                RenderItemDetailsWithoutTableTags(writer, item);
                return;
            }


            Style labelStyle              = Control.LabelStyle;
            Style subCommandStyle         = Control.CommandStyle;
            Style subCommandStyleNoItalic = (Style)subCommandStyle.Clone();

            subCommandStyleNoItalic.Font.Italic = BooleanOption.False;

            writer.ClearPendingBreak(); // we are writing a block level element in all cases.
            ConditionalEnterLayout(writer, Style);
            writer.WriteBeginTag("table");
            ConditionalRenderClassAttribute(writer);
            writer.Write(">");
            writer.Write("<tr><td colspan=\"2\">");
            ConditionalEnterStyle(writer, labelStyle);
            writer.WriteEncodedText(item[Control.LabelFieldIndex]);
            ConditionalExitStyle(writer, labelStyle);
            writer.WriteLine("</td></tr>");
            Color foreColor = (Color)Style[Style.ForeColorKey, true];

            RenderRule(writer, foreColor, 2);
            RenderItemFieldsInDetailsView(writer, item);
            RenderRule(writer, foreColor, 2);
            ConditionalPopPhysicalCssClass(writer);
            writer.WriteEndTag("table");
            ConditionalExitLayout(writer, Style);

            ConditionalEnterStyle(writer, subCommandStyleNoItalic);
            writer.Write("[&nbsp;");

            ObjectListCommandCollection commands = Control.Commands;
            String cssClass        = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
            String subCommandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute);

            if (subCommandClass == null || subCommandClass.Length == 0)
            {
                subCommandClass = cssClass;
            }

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

            RenderPostBackEventAsAnchor(writer, BackToList, backCommandText, null /* accessKey */, subCommandStyle, subCommandClass);
            writer.Write("&nbsp;]");
            ConditionalExitStyle(writer, subCommandStyleNoItalic);
        }
コード例 #31
0
 // For Style/CssClass args, see ASURT 144034
 /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderPostBackEventAsAnchor2"]/*' />
 protected virtual void RenderPostBackEventAsAnchor (
     XhtmlMobileTextWriter writer,
     String argument,
     String linkText, 
     String accessKey,
     Style style,
     String cssClass) {            
     writer.WriteBeginTag("a");
     writer.Write(" href=\"");
     PageAdapter.RenderUrlPostBackEvent(writer, Control.UniqueID /* target */, argument);
     writer.Write("\" ");
     if (accessKey != null && accessKey.Length > 0) {
         writer.WriteAttribute("accesskey", accessKey);
     }
     if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true") {
         if (CssLocation != StyleSheetLocation.PhysicalFile) {
             String className = writer.GetCssFormatClassName(style);
             if (className != null) {
                 writer.WriteAttribute ("class", className);
             }
         }
         else if (cssClass != null && cssClass.Length > 0) {
             writer.WriteAttribute ("class", cssClass, true /* encode */);
         }
     }
     writer.Write(">");
     writer.WriteEncodedText(linkText);
     writer.WriteEndTag("a");
 }
コード例 #32
0
        private void RenderItemDetailsWithoutTableTags(XhtmlMobileTextWriter writer, ObjectListItem item)
        {
            if (Control.VisibleItemCount == 0)
            {
                return;
            }

            Style style                   = this.Style;
            Style labelStyle              = Control.LabelStyle;
            Style subCommandStyle         = Control.CommandStyle;
            Style subCommandStyleNoItalic = (Style)subCommandStyle.Clone();

            subCommandStyleNoItalic.Font.Italic = BooleanOption.False;

            ConditionalRenderOpeningDivElement(writer);

            String cssClass   = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
            String labelClass = GetCustomAttributeValue(XhtmlConstants.CssLabelClassCustomAttribute);

            if (labelClass == null || labelClass.Length == 0)
            {
                labelClass = cssClass;
            }
            ConditionalEnterStyle(writer, labelStyle);
            bool requiresLabelClassSpan = CssLocation == StyleSheetLocation.PhysicalFile && labelClass != null && labelClass.Length > 0;

            if (requiresLabelClassSpan)
            {
                writer.WriteBeginTag("span");
                writer.WriteAttribute("class", labelClass, true);
                writer.Write(">");
            }
            writer.Write(item[Control.LabelFieldIndex]);
            writer.SetPendingBreak();
            if (requiresLabelClassSpan)
            {
                writer.WriteEndTag("span");
            }
            ConditionalExitStyle(writer, labelStyle);
            writer.WritePendingBreak();

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

            ConditionalEnterStyle(writer, style);
            foreach (ObjectListField field in fields)
            {
                if (field.Visible)
                {
                    writer.Write(field.Title + ":");
                    writer.Write("&nbsp;");
                    writer.Write(item[fieldIndex]);
                    writer.WriteBreak();
                }
                fieldIndex++;
            }
            ConditionalExitStyle(writer, style);

            String commandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute);

            ConditionalEnterStyle(writer, subCommandStyleNoItalic);
            if ((String)Device[XhtmlConstants.BreaksOnInlineElements] != "true")
            {
                writer.Write("[&nbsp;");
            }
            ConditionalEnterStyle(writer, subCommandStyle);

            ObjectListCommandCollection commands = Control.Commands;

            foreach (ObjectListCommand command in commands)
            {
                RenderPostBackEventAsAnchor(writer, command.Name, command.Text);
                if ((String)Device[XhtmlConstants.BreaksOnInlineElements] != "true")
                {
                    writer.Write("&nbsp;|&nbsp;");
                }
            }
            String controlBCT      = Control.BackCommandText;
            String backCommandText = controlBCT == null || controlBCT.Length == 0 ?
                                     GetDefaultLabel(BackLabel) :
                                     Control.BackCommandText;

            RenderPostBackEventAsAnchor(writer, BackToList, backCommandText);
            ConditionalExitStyle(writer, subCommandStyle);
            if ((String)Device[XhtmlConstants.BreaksOnInlineElements] != "true")
            {
                writer.Write("&nbsp;]");
            }
            ConditionalExitStyle(writer, subCommandStyleNoItalic);

            ConditionalRenderClosingDivElement(writer);
        }
コード例 #33
0
        private void RenderItemDetailsWithoutTableTags(XhtmlMobileTextWriter writer, ObjectListItem item)
        {
            if (Control.VisibleItemCount == 0) {
                return;
            }
            
            Style style = this.Style;
            Style labelStyle = Control.LabelStyle;
            Style subCommandStyle = Control.CommandStyle;
            Style subCommandStyleNoItalic = (Style)subCommandStyle.Clone();
            subCommandStyleNoItalic.Font.Italic = BooleanOption.False;

            ConditionalRenderOpeningDivElement(writer);

            String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
            String labelClass = GetCustomAttributeValue(XhtmlConstants.CssLabelClassCustomAttribute); 
            if (labelClass == null || labelClass.Length == 0) {
                labelClass = cssClass;
            }
            ConditionalEnterStyle(writer, labelStyle);
            bool requiresLabelClassSpan = CssLocation == StyleSheetLocation.PhysicalFile && labelClass != null && labelClass.Length > 0;
            if (requiresLabelClassSpan) {
                writer.WriteBeginTag("span");
                writer.WriteAttribute("class", labelClass, true);
                writer.Write(">");
            }
            writer.Write(item[Control.LabelFieldIndex]);
            writer.SetPendingBreak();
            if (requiresLabelClassSpan) {
                writer.WriteEndTag("span");
            }
            ConditionalExitStyle(writer, labelStyle);
            writer.WritePendingBreak();

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

            ConditionalEnterStyle(writer, style);
            foreach (ObjectListField field in fields)
            {
                if (field.Visible) {
                    writer.Write(field.Title + ":");
                    writer.Write("&nbsp;");
                    writer.Write(item[fieldIndex]);
                    writer.WriteBreak();
                }
                fieldIndex++;
            }
            ConditionalExitStyle(writer, style);

            String commandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute);

            ConditionalEnterStyle(writer, subCommandStyleNoItalic);
            if ((String) Device[XhtmlConstants.BreaksOnInlineElements] != "true") {
                writer.Write("[&nbsp;");
            }
            ConditionalEnterStyle(writer, subCommandStyle);

            ObjectListCommandCollection commands = Control.Commands;
            foreach (ObjectListCommand command in commands)
            {
                RenderPostBackEventAsAnchor(writer, command.Name, command.Text);
                if ((String) Device[XhtmlConstants.BreaksOnInlineElements] != "true") {
                    writer.Write("&nbsp;|&nbsp;");
                }
            }
            String controlBCT = Control.BackCommandText;
            String backCommandText = controlBCT == null || controlBCT.Length == 0 ?
                GetDefaultLabel(BackLabel) :
                Control.BackCommandText;

            RenderPostBackEventAsAnchor(writer, BackToList, backCommandText);
            ConditionalExitStyle(writer, subCommandStyle);
            if ((String) Device[XhtmlConstants.BreaksOnInlineElements] != "true") {
                writer.Write("&nbsp;]");
            }
            ConditionalExitStyle(writer, subCommandStyleNoItalic);

            ConditionalRenderClosingDivElement(writer);
        }
コード例 #34
0
        private void RenderItemsListWithoutTableTags(XhtmlMobileTextWriter writer)
        {
            if (Control.VisibleItemCount == 0)
            {
                return;
            }

            ConditionalRenderOpeningDivElement(writer);
            int startIndex = Control.FirstVisibleItemIndex;
            int pageSize   = Control.VisibleItemCount;
            ObjectListItemCollection   items     = Control.Items;
            IObjectListFieldCollection allFields = Control.AllFields;
            int count = allFields.Count;

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


            Style  style      = this.Style;
            Style  labelStyle = Control.LabelStyle;
            String cssClass   = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
            String labelClass = GetCustomAttributeValue(XhtmlConstants.CssLabelClassCustomAttribute);

            if (labelClass == null || labelClass.Length == 0)
            {
                labelClass = cssClass;
            }
            ConditionalEnterStyle(writer, labelStyle);
            bool requiresLabelClassSpan = CssLocation == StyleSheetLocation.PhysicalFile && labelClass != null && labelClass.Length > 0;

            if (requiresLabelClassSpan)
            {
                writer.WriteBeginTag("span");
                writer.WriteAttribute("class", labelClass, true);
                writer.Write(">");
            }
            writer.Write(Control.AllFields[labelFieldIndex].Title);
            writer.SetPendingBreak();
            if (requiresLabelClassSpan)
            {
                writer.WriteEndTag("span");
            }
            ConditionalExitStyle(writer, labelStyle);
            writer.WritePendingBreak();

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

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


            Style subCommandStyle = Control.CommandStyle;

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

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

                String accessKey = GetCustomAttributeValue(item, XhtmlConstants.AccessKeyCustomAttribute);
                String itemClass = GetCustomAttributeValue(item, XhtmlConstants.CssClassCustomAttribute);
                if (itemRequiresHyperlink)
                {
                    RenderPostBackEventAsAnchor(writer,
                                                hasDefaultCommand ?
                                                item.Index.ToString(CultureInfo.InvariantCulture) :
                                                String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index),
                                                item[labelFieldIndex], accessKey, Style, cssClass);
                }
                else
                {
                    bool requiresItemClassSpan = CssLocation == StyleSheetLocation.PhysicalFile && itemClass != null && itemClass.Length > 0;
                    if (requiresItemClassSpan)
                    {
                        writer.WriteBeginTag("span");
                        writer.WriteAttribute("class", itemClass, true);
                        writer.Write(">");
                    }
                    writer.Write(item[labelFieldIndex]);
                    if (requiresItemClassSpan)
                    {
                        writer.WriteEndTag("span");
                    }
                }

                if (itemRequiresMoreButton)
                {
                    String        commandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute);
                    BooleanOption cachedItalic = subCommandStyle.Font.Italic;
                    subCommandStyle.Font.Italic = BooleanOption.False;
                    ConditionalEnterFormat(writer, subCommandStyle);
                    if ((String)Device[XhtmlConstants.BreaksOnInlineElements] != "true")
                    {
                        writer.Write(" [");
                    }
                    ConditionalExitFormat(writer, subCommandStyle);
                    subCommandStyle.Font.Italic = cachedItalic;
                    ConditionalEnterFormat(writer, subCommandStyle);
                    String controlMT = Control.MoreText;
                    String moreText  = (controlMT == null || controlMT.Length == 0) ?
                                       GetDefaultLabel(MoreLabel) :
                                       controlMT;
                    RenderPostBackEventAsAnchor(writer,
                                                String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index),
                                                moreText,
                                                null /*accessKey*/,
                                                subCommandStyle,
                                                commandClass);
                    ConditionalExitFormat(writer, subCommandStyle);
                    subCommandStyle.Font.Italic = BooleanOption.False;
                    ConditionalEnterFormat(writer, subCommandStyle);
                    if ((String)Device[XhtmlConstants.BreaksOnInlineElements] != "true")
                    {
                        writer.Write("]");
                    }
                    ConditionalExitFormat(writer, subCommandStyle);
                    subCommandStyle.Font.Italic = cachedItalic;
                }

                if (i < (nextStartIndex - 1))
                {
                    writer.WriteBreak();
                }
                else
                {
                    writer.SetPendingBreak();
                }
            }
            ConditionalExitStyle(writer, style);
            ConditionalRenderClosingDivElement(writer);
        }
コード例 #35
0
 private void RenderRule (XhtmlMobileTextWriter writer, Color foreColor, int columnSpan) {
     if (CssLocation == StyleSheetLocation.PhysicalFile || Device["requiresXhtmlCssSuppression"] == "true") {
         // Review: Since, if there is a physical stylesheet, we cannot know the intended foreColor,
         // do not render a rule.
         return;
     }
     writer.Write("<tr>");
     Style hruleStyle = new Style();
     // Rendering <td...> with background color equal to the style's forecolor renders a thin
     // rule with color forecolor, as intended.
     hruleStyle[Style.BackColorKey] = foreColor == Color.Empty ? Color.Black : foreColor;
     NameValueCollection additionalAttributes = new NameValueCollection();
     additionalAttributes["colspan"] = columnSpan.ToString(CultureInfo.InvariantCulture);              
     writer.EnterStyleInternal(hruleStyle, "td", StyleFilter.BackgroundColor, additionalAttributes);
     writer.ExitStyle(Style);
     writer.WriteEndTag("tr");            
 }
コード例 #36
0
        void RenderInputElementSet(XhtmlMobileTextWriter writer)
        {
            string wrappingTag = Device.Tables ? "table" :
                                 (((string)Device["usePOverDiv"] == "true") ? "p" : "div");
            ListSelectType           selectType = Control.SelectType;
            MobileListItemCollection items      = Control.Items;
            // Review: We always render a table.  Should we optimize away the table tags when the alignment is left?
            String selectTypeString =
                (selectType == ListSelectType.Radio) ?
                "radio" :
                "checkbox";

            ClearPendingBreakIfDeviceBreaksOnBlockLevel(writer); // Since we are writing a block-level element in all cases.
            ConditionalEnterLayout(writer, Style);
            RenderOpeningListTag(writer, wrappingTag);
            for (int itemIndex = 0; itemIndex < items.Count; itemIndex++)
            {
                MobileListItem item = items[itemIndex];
                if (Device.Tables)
                {
                    writer.WriteFullBeginTag("tr");
                    writer.WriteFullBeginTag("td");
                }

                writer.WriteBeginTag("input");
                writer.WriteAttribute("type", selectTypeString);
                writer.WriteAttribute("name", Control.UniqueID);
                WriteItemValueAttribute(writer, itemIndex, item.Value);
                String accessKey = GetCustomAttributeValue(item, XhtmlConstants.AccessKeyCustomAttribute);
                if (accessKey != null && accessKey.Length > 0)
                {
                    writer.WriteAttribute("accesskey", accessKey, true);
                }
                // Assumption: Device.SupportsUncheck is always true for Xhtml devices.
                if (item.Selected &&
                    (Control.IsMultiSelect || itemIndex == Control.SelectedIndex))
                {
                    writer.Write(" checked=\"checked\"/>");
                }
                else
                {
                    writer.Write("/>");
                }

                writer.WriteEncodedText(item.Text);
                if (Device.Tables)
                {
                    writer.WriteEndTag("td");
                }
                if ((string)Device["usePOverDiv"] == "true" || !Device.Tables)
                {
                    writer.Write("<br/>");
                }
                if (Device.Tables)
                {
                    writer.WriteEndTag("tr");
                }
            }
            RenderClosingListTag(writer, wrappingTag);
            ConditionalExitLayout(writer, Style);
        }