コード例 #1
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");
 }
コード例 #2
0
 /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderBeginLink"]/*' />
 protected virtual void RenderBeginLink(XhtmlMobileTextWriter writer, String target, String accessKey, Style style, String cssClass, String title)
 {
     writer.WriteBeginTag("a");
     writer.Write(" href=\"");
     RenderHrefValue(writer, target);
     writer.Write("\"");
     if (accessKey != null && accessKey.Length > 0)
     {
         writer.WriteAttribute("accesskey", accessKey, 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 */);
     }
     if (title != null && title.Length > 0)
     {
         writer.WriteAttribute("title", title, true /* encode */);
     }
     writer.WriteLine(">");
 }
コード例 #3
0
        private void RenderListViewTableHeader(XhtmlMobileTextWriter writer, int fieldCount, int[] fieldIndices, bool itemRequiresMoreButton)
        {
            String cssClass   = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
            String labelClass = GetCustomAttributeValue(XhtmlConstants.CssLabelClassCustomAttribute);

            if (labelClass == null || labelClass.Length == 0)
            {
                labelClass = cssClass;
            }
            writer.WriteLine("<tr>");
            for (int field = 0; field < fieldCount; field++)
            {
                writer.WriteBeginTag("td");
                if (CssLocation == StyleSheetLocation.PhysicalFile && labelClass != null && labelClass.Length > 0)
                {
                    writer.WriteAttribute("class", labelClass, true);
                }
                writer.Write(">");
                Style labelStyle = Control.LabelStyle;
                ConditionalEnterStyle(writer, labelStyle);
                writer.WriteEncodedText(Control.AllFields[fieldIndices[field]].Title);
                ConditionalExitStyle(writer, labelStyle);
                writer.Write("</td>");
            }
            if (itemRequiresMoreButton)
            {
                writer.WriteLine("<td/>");
            }
            writer.WriteLine();
            writer.WriteLine("</tr>");
        }
コード例 #4
0
        /// <include file='doc\XhtmlBasicTextBoxAdapter.uex' path='docs/doc[@for="XhtmlTextBoxAdapter.Render"]/*' />
        public override void Render(XhtmlMobileTextWriter writer)
        {
            ConditionalClearPendingBreak(writer);
            ConditionalEnterStyle(writer, Style);
            ConditionalRenderOpeningSpanElement(writer);

            if ((String)Device[XhtmlConstants.RequiresOnEnterForward] == "true")
            {
                writer.AddOnEnterForwardSetVar(Control.UniqueID, Control.Text);
            }

            writer.WriteBeginTag("input");

            writer.WriteAttribute("name", Control.UniqueID);

            ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
            String controlText = Control.Text;

            if (controlText != null && controlText.Length > 0 && !Control.Password)
            {
                writer.Write(" value=\"");
                writer.WriteEncodedText(controlText);
                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));
            }

            String requiresType = Device["requiresInputTypeAttribute"];

            if (Control.Password)
            {
                writer.WriteAttribute("type", "password");
            }
            // InvariantCulture not needed, but included for best practices.
            else if (requiresType != null && String.Equals(requiresType, "true", StringComparison.OrdinalIgnoreCase))
            {
                writer.WriteAttribute("type", "text");
            }


            writer.Write("/>");
            // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
            // ConditionalExitStyle may render a block element and clear the pending break.
            ConditionalSetPendingBreakAfterInline(writer);
            ConditionalRenderClosingSpanElement(writer);
            ConditionalExitStyle(writer, Style);
        }
コード例 #5
0
        /////////////////////////////////////////////////////////////////////////
        //  PAGINATION SUPPORT
        /////////////////////////////////////////////////////////////////////////
        /// <include file='doc\XhtmlBasicFormAdapter.uex' path='docs/doc[@for="XhtmlFormAdapter.RenderPager"]/*' />
        protected virtual void RenderPager(XhtmlMobileTextWriter writer)
        {
            PagerStyle pagerStyle = Control.PagerStyle;

            int pageCount = Control.PageCount;

            if (pageCount <= 1)
            {
                return;
            }
            int    page = Control.CurrentPage;
            String text = pagerStyle.GetPageLabelText(page, pageCount);

            if ((page > 1) || (text.Length > 0) || (page < pageCount))
            {
                writer.WritePendingBreak();
                ConditionalEnterStyle(writer, pagerStyle);
                ConditionalEnterPagerSpan(writer);
            }

            if (page > 1)
            {
                RenderPagerTag(writer, page - 1,
                               pagerStyle.GetPreviousPageText(page),
                               XhtmlConstants.PagerPreviousAccessKeyCustomAttribute);
                writer.Write(" ");
            }

            if (text.Length > 0)
            {
                writer.WriteEncodedText(text);
                writer.Write(" ");
            }

            if (page < pageCount)
            {
                RenderPagerTag(writer, page + 1,
                               pagerStyle.GetNextPageText(page),
                               XhtmlConstants.PagerNextAccessKeyCustomAttribute);
            }

            if ((page > 1) || (text.Length > 0) || (page < pageCount))
            {
                ConditionalExitPagerSpan(writer);
                ConditionalExitStyle(writer, pagerStyle);
                writer.SetPendingBreak();
            }
        }
コード例 #6
0
        /////////////////////////////////////////////////////////////////////////
        // SPECIALIZED UTILITY METHODS FOR LIST SELECTIONLIST OBJECTLIST
        /////////////////////////////////////////////////////////////////////////

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

            if (CssLocation == StyleSheetLocation.PhysicalFile && (String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true")
            {
                writer.WritePendingBreak();
                writer.WriteBeginTag(tagName);
                if (classAttribute != null &&
                    classAttribute.Length > 0 &&
                    writer.DiffersFromCurrentPhysicalCssClass(classAttribute))
                {
                    writer.WriteAttribute("class", classAttribute, true);
                    writer.PushPhysicalCssClass(classAttribute);
                    Debug.Assert(!_physicalCssClassPushed, "These calls should not be nested.");
                    _physicalCssClassPushed = true;
                }
                writer.Write(">");
            }
            else if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true")
            {
                writer.WritePendingBreak();
                StyleFilter filter = writer.CurrentStyleClass.GetFilter(Style);
                writer.EnterStyle(new XhtmlFormatStyleClass(Style, filter), tagName);
            }
            else
            {
                writer.WritePendingBreak();
                writer.WriteFullBeginTag(tagName);
            }
        }
コード例 #7
0
        // Render opening <div class=...> in case the stylesheet location has been specified as a physical file.
        /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalRenderOpeningDivElement"]/*' />
        protected virtual void ConditionalRenderOpeningDivElement(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.WriteBeginTag("p");
                }
                else
                {
                    writer.WriteBeginTag("div");
                }
                if (classAttribute != null &&
                    classAttribute.Length > 0 &&
                    writer.DiffersFromCurrentPhysicalCssClass(classAttribute))
                {
                    writer.WriteAttribute("class", classAttribute, true);
                    writer.PushPhysicalCssClass(classAttribute);
                    Debug.Assert(!_physicalCssClassPushed, "These calls should not be nested.");
                    _physicalCssClassPushed = true;
                }
                writer.Write(">");
            }
        }
コード例 #8
0
        private void RenderOpeningBodyElement(XhtmlMobileTextWriter writer)
        {
            Form  activeForm = Page.ActiveForm;
            Style formStyle  = ((ControlAdapter)activeForm.Adapter).Style;

            if (CssLocation == StyleSheetLocation.PhysicalFile)
            {
                String cssClass = (String)activeForm.CustomAttributes[XhtmlConstants.CssClassCustomAttribute];
                writer.WriteBeginTag("body");
                if (cssClass != null && (String)Device["supportsBodyClassAttribute"] != "false")
                {
                    writer.WriteAttribute("class", cssClass, true /* encode */);
                    writer.PushPhysicalCssClass(cssClass);
                    _pushedCssClassForBody = true;
                }
                writer.Write(">");
            }
            else if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true" &&
                     (String)Device[XhtmlConstants.SupportsBodyClassAttribute] != "false")
            {
                writer.EnterStyle(formStyle, "body");
            }
            else
            {
                writer.WriteFullBeginTag("body");
                if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true" &&
                    (String)Device[XhtmlConstants.SupportsBodyClassAttribute] == "false")
                {
                    writer.SetBodyStyle(formStyle);
                }
            }
        }
コード例 #9
0
        private void ConditionalRenderLinkElement(XhtmlMobileTextWriter writer)
        {
            if (DoesDeviceRequireCssSuppression())
            {
                return;
            }

            String cssLocation = (String)Page.ActiveForm.CustomAttributes[XhtmlConstants.StyleSheetLocationCustomAttribute];

            if (cssLocation != null &&
                cssLocation.Length != 0)
            {
                writer.WriteBeginTag("link");
                writer.WriteAttribute("type", "text/css");
                writer.WriteAttribute("rel", "stylesheet");
                writer.WriteAttribute("href", cssLocation, true);
                writer.WriteLine("/>");
            }
            else if (!writer.IsStyleSheetEmpty() && CssLocation != StyleSheetLocation.Internal)
            {
                writer.WriteLine();
                writer.WriteBeginTag("link");
                writer.WriteAttribute("type", "text/css");
                writer.WriteAttribute("rel", "stylesheet");
                String queryStringValue = GetCssQueryStringValue(writer);
                writer.Write(" href=\"" + XhtmlConstants.CssMappedFileName + "?" + XhtmlConstants.CssQueryStringName + "=" + queryStringValue + "\"/>");
                writer.WriteLine();
            }
        }
コード例 #10
0
        // Render a single ObjectListItem in list view.
        private void RenderListViewItem(XhtmlMobileTextWriter writer, ObjectListItem item, int fieldCount, int[] fieldIndices, bool itemRequiresMoreButton, bool itemRequiresHyperlink)
        {
            Style  style           = Style;
            Style  subCommandStyle = Control.CommandStyle;
            String accessKey       = GetCustomAttributeValue(item, XhtmlConstants.AccessKeyCustomAttribute);
            String cssClass        = GetCustomAttributeValue(item, XhtmlConstants.CssClassCustomAttribute);
            String subCommandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute);

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

            writer.WriteLine("<tr>");

            // Render fields.
            for (int field = 0; field < fieldCount; field++)
            {
                writer.Write("<td>");
                if (field == 0 && itemRequiresHyperlink)
                {
                    String eventArgument = HasDefaultCommand() ? item.Index.ToString(CultureInfo.InvariantCulture) : String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index.ToString(CultureInfo.InvariantCulture));
                    RenderPostBackEventAsAnchor(writer, eventArgument, item[fieldIndices[0]], accessKey, Style, cssClass);
                }
                else
                {
                    writer.WriteEncodedText(item[fieldIndices[field]]);
                }
                writer.WriteLine("</td>");
            }

            if (itemRequiresMoreButton)
            {
                writer.Write("<td>");
                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,
                                            subCommandClass);
                writer.WriteLine("</td>");
            }
            writer.WriteLine("</tr>");
        }
コード例 #11
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);
        }
コード例 #12
0
        /// <include file='doc\XhtmlBasicTextBoxAdapter.uex' path='docs/doc[@for="XhtmlTextBoxAdapter.Render"]/*' />
        public override void Render(XhtmlMobileTextWriter writer) {
            ConditionalClearPendingBreak(writer);
            ConditionalEnterStyle(writer, Style);
            ConditionalRenderOpeningSpanElement(writer);

            if ((String) Device[XhtmlConstants.RequiresOnEnterForward] == "true") {
                writer.AddOnEnterForwardSetVar(Control.UniqueID, Control.Text);
            }
            
            writer.WriteBeginTag("input");

            writer.WriteAttribute("name", Control.UniqueID);

            ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
            String controlText = Control.Text;
            if (controlText != null && controlText.Length > 0 && !Control.Password) {
                writer.Write(" value=\"");
                writer.WriteEncodedText(controlText);
                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));
            }

            String requiresType = Device["requiresInputTypeAttribute"];
            if (Control.Password) {
                writer.WriteAttribute("type", "password");
            }
            // InvariantCulture not needed, but included for best practices.
            else if (requiresType != null && String.Equals(requiresType, "true", StringComparison.OrdinalIgnoreCase)) {
                writer.WriteAttribute("type", "text");
            }


            writer.Write("/>");
            // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
            // ConditionalExitStyle may render a block element and clear the pending break.
            ConditionalSetPendingBreakAfterInline(writer);            
            ConditionalRenderClosingSpanElement(writer);
            ConditionalExitStyle(writer, Style);
        }
コード例 #13
0
        // Writes the href value for RenderBeginLink, depending on whether the target is a new form on the
        // current page or a standard url (e.g., a new page).
        private void RenderHrefValue(XhtmlMobileTextWriter writer, String target)
        {
            bool appendCookielessDataDictionary = PageAdapter.PersistCookielessData &&
                                                  !target.StartsWith("http:", StringComparison.Ordinal) &&
                                                  !target.StartsWith("https:", StringComparison.Ordinal);
            bool queryStringWritten = false;

            // ASURT 144021
            if (target == null || target.Length == 0)
            {
                target = Page.Response.ApplyAppPathModifier(Control.TemplateSourceDirectory);
            }



            if (target.StartsWith(Constants.FormIDPrefix, StringComparison.Ordinal))
            {
                RenderFormNavigationHrefValue(writer, target);
                appendCookielessDataDictionary = false;
            }
            else
            {
                // For page adapter Control = null.
                if (Control != null)
                {
                    target = Control.ResolveUrl(target);
                }

                // ASURT 147179
                if ((String)Device["requiresAbsolutePostbackUrl"] == "true" &&
                    IsRelativeUrl(target))
                {
                    String templateSourceDirectory = Page.TemplateSourceDirectory;
                    String prefix = writer.EncodeUrlInternal(Page.Response.ApplyAppPathModifier(Page.TemplateSourceDirectory));
                    if (prefix[prefix.Length - 1] != '/')
                    {
                        prefix = prefix + '/';
                    }
                    target = prefix + target;
                }

                if ((String)Device[XhtmlConstants.SupportsUrlAttributeEncoding] != "false")
                {
                    writer.WriteEncodedText(target);
                }
                else
                {
                    writer.Write(target);
                }
                queryStringWritten = target.IndexOf('?') != -1;
            }

            if (appendCookielessDataDictionary)
            {
                RenderCookielessDataDictionaryInQueryString(writer, queryStringWritten);
            }
        }
コード例 #14
0
        // Called from RenderItemDetails.  (Extracted for intelligibility.)
        private void RenderItemFieldsInDetailsView(XhtmlMobileTextWriter writer, ObjectListItem item)
        {
            Style style = Style;
            IObjectListFieldCollection fields = Control.AllFields;

            foreach (ObjectListField field in fields)
            {
                if (field.Visible)
                {
                    writer.Write("<tr><td>");
                    ConditionalEnterStyle(writer, Style);
                    writer.WriteEncodedText(field.Title);
                    ConditionalExitStyle(writer, Style);
                    writer.Write("</td><td>");
                    ConditionalEnterStyle(writer, style);
                    writer.WriteEncodedText(item [fields.IndexOf(field)]);
                    ConditionalExitStyle(writer, style);
                    writer.WriteLine("</td></tr>");
                }
            }
        }
コード例 #15
0
        private void RenderListBody(XhtmlMobileTextWriter writer, String itemPrefix, String itemSuffix)
        {
            int pageStart = Control.FirstVisibleItemIndex;
            int pageSize  = Control.VisibleItemCount;

            for (int i = 0; i < pageSize; i++)
            {
                MobileListItem item = Control.Items[pageStart + i];
                writer.Write(itemPrefix);
                RenderListItem(writer, item);
                writer.WriteLine(itemSuffix);
            }
        }
コード例 #16
0
        /// <include file='doc\XhtmlBasicPageAdapter.uex' path='docs/doc[@for="XhtmlPageAdapter.RenderUrlPostBackEvent"]/*' />
        public virtual void RenderUrlPostBackEvent(XhtmlMobileTextWriter writer,
                                                   String target,
                                                   String argument)
        {
            String amp = (String)Device[XhtmlConstants.SupportsUrlAttributeEncoding] == "false"  ? "&" : "&amp;";

            if ((String)Device["requiresAbsolutePostbackUrl"] == "true")
            {
                writer.WriteEncodedUrl(Page.AbsoluteFilePath);
            }
            else
            {
                writer.WriteEncodedUrl(Page.RelativeFilePath);
            }
            writer.Write("?");

            // Encode ViewStateID=.....&__ET=controlid&__EA=value in URL
            // Note: the encoding needs to be agreed with the page
            // adapter which handles the post back info
            String pageState = Page.ClientViewState;

            if (pageState != null)
            {
                writer.WriteUrlParameter(MobilePage.ViewStateID, pageState);
                writer.Write(amp);
            }
            writer.WriteUrlParameter(EventSourceKey, target);
            writer.Write(amp);
            writer.WriteUrlParameter(EventArgumentKey, argument);
            RenderHiddenVariablesInUrl(writer);

            // Unique file path suffix is used for identify if query
            // string text is present.  Corresponding code needs to agree
            // on this.  Even if the query string is empty, we still need
            // to output the suffix to indicate this. (this corresponds
            // to the code that handles the postback)
            writer.Write(amp);
            writer.Write(Constants.UniqueFilePathSuffixVariable);

            String queryStringText = PreprocessQueryString(Page.QueryStringText);

            if (queryStringText != null && queryStringText.Length > 0)
            {
                writer.Write(amp);
                if ((String)Device[XhtmlConstants.SupportsUrlAttributeEncoding] != "false")
                {
                    writer.WriteEncodedAttributeValue(queryStringText);
                }
                else
                {
                    writer.Write(queryStringText);
                }
            }
        }
コード例 #17
0
 private void RenderHiddenVariablesInUrl(XhtmlMobileTextWriter writer)
 {
     if (Page.HasHiddenVariables())
     {
         String hiddenVariablePrefix = MobilePage.HiddenVariablePrefix;
         foreach (DictionaryEntry entry in Page.HiddenVariables)
         {
             writer.Write("&amp;");
             writer.WriteUrlParameter(hiddenVariablePrefix + (String)entry.Key,
                                      (String)entry.Value);
         }
     }
 }
コード例 #18
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();
     }
 }
コード例 #19
0
        private void ConditionalEnterPagerSpan(XhtmlMobileTextWriter writer)
        {
            String cssClass = GetCustomAttributeValue(XhtmlConstants.CssPagerClassCustomAttribute);

            if (CssLocation == StyleSheetLocation.PhysicalFile &&
                cssClass != null &&
                cssClass.Length > 0)
            {
                writer.WriteBeginTag("span");
                writer.WriteAttribute("class", cssClass, true);
                _pagerCssSpanWritten = true;
                writer.Write(">");
            }
        }
コード例 #20
0
        private void RenderCookielessDataDictionaryInQueryString(XhtmlMobileTextWriter writer, bool queryStringWritten)
        {
            IDictionary dictionary = PageAdapter.CookielessDataDictionary;

            if (dictionary != null)
            {
                foreach (String name in dictionary.Keys)
                {
                    if (queryStringWritten)
                    {
                        String amp = (String)Device[XhtmlConstants.SupportsUrlAttributeEncoding] != "false" ? "&amp;" : "&";
                        writer.Write(amp);
                    }
                    else
                    {
                        writer.Write('?');
                        queryStringWritten = true;
                    }
                    writer.Write(name);
                    writer.Write('=');
                    writer.Write(dictionary[name]);
                }
            }
        }
コード例 #21
0
        private void RenderAbsolutePostbackUrl(XhtmlMobileTextWriter writer)
        {
            String url = PreprocessQueryString(Control.Action);

            if (url.Length > 0)
            {
                // Not only do we need to resolve the URL, but we need to make it absolute.
                url = Page.MakePathAbsolute(Control.ResolveUrl(url));
                writer.Write(url);
            }
            else
            {
                writer.WriteEncodedUrl(Page.AbsoluteFilePath);
            }
        }
コード例 #22
0
 private void RenderAsInputTypeImage(XhtmlMobileTextWriter writer) {
     ConditionalEnterStyle(writer, Style);
     writer.WriteBeginTag("input");
     writer.WriteAttribute("type", "image");
     writer.WriteAttribute("name", Control.UniqueID);
     writer.WriteAttribute("src", Control.ResolveUrl(Control.ImageUrl), true);
     writer.WriteAttribute("alt", Control.Text, true);
     ConditionalRenderClassAttribute(writer);
     ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
     writer.Write("/>");
     // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
     // ConditionalExitStyle may render a block element and clear the pending break.
     ConditionalSetPendingBreakAfterInline(writer);
     ConditionalExitStyle(writer, Style);
 }
コード例 #23
0
 private void RenderAsInputTypeSubmit(XhtmlMobileTextWriter writer)
 {
     ConditionalEnterStyle(writer, Style);
     writer.WriteBeginTag("input");
     writer.WriteAttribute("type", "submit");
     writer.WriteAttribute("name", Control.UniqueID);
     writer.WriteAttribute("value", Control.Text, true);
     ConditionalRenderClassAttribute(writer);
     ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
     writer.Write("/>");
     // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
     // ConditionalExitStyle may render a block element and clear the pending break.
     ConditionalSetPendingBreakAfterInline(writer);
     ConditionalPopPhysicalCssClass(writer);
     ConditionalExitStyle(writer, Style);
 }
コード例 #24
0
 private void RenderAsInputTypeImage(XhtmlMobileTextWriter writer)
 {
     ConditionalEnterStyle(writer, Style);
     writer.WriteBeginTag("input");
     writer.WriteAttribute("type", "image");
     writer.WriteAttribute("name", Control.UniqueID);
     writer.WriteAttribute("src", Control.ResolveUrl(Control.ImageUrl), true);
     writer.WriteAttribute("alt", Control.Text, true);
     ConditionalRenderClassAttribute(writer);
     ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
     writer.Write("/>");
     // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
     // ConditionalExitStyle may render a block element and clear the pending break.
     ConditionalSetPendingBreakAfterInline(writer);
     ConditionalExitStyle(writer, Style);
 }
コード例 #25
0
 private void RenderPostbackUrl(XhtmlMobileTextWriter writer)
 {
     if ((String)Device["requiresAbsolutePostbackUrl"] == "true")
     {
         RenderAbsolutePostbackUrl(writer);
         return;
     }
     if (Control.Action.Length > 0)
     {
         String url = Control.ResolveUrl(PreprocessQueryString(Control.Action));
         writer.Write(url);
     }
     else
     {
         writer.WriteEncodedUrl(Page.RelativeFilePath);
     }
 }
コード例 #26
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");
        }
コード例 #27
0
        /// <include file='doc\XhtmlBasicImageAdapter.uex' path='docs/doc[@for="XhtmlImageAdapter.RenderImage"]/*' />
        protected virtual void RenderImage(XhtmlMobileTextWriter writer)
        {
            String source = Control.ImageUrl;

            writer.WriteBeginTag("img");
            if (source != null && source.Length > 0)
            {
                source = Page.Server.UrlPathEncode(Control.ResolveUrl(source.Trim()));
                writer.WriteAttribute("src", source, true);
                writer.AddResource(source);
            }

            String alternateText = Control.AlternateText;

            if (alternateText == null || alternateText.Length == 0)
            {
                alternateText = " "; // ASURT 143759 and VSWhidbey 78593
            }
            writer.WriteAttribute("alt", alternateText, true);

            // Review: Html adapter writes border=0 attribute, but don't need this here?
            writer.Write(" />");
        }
コード例 #28
0
        /// <include file='doc\XhtmlBasicFormAdapter.uex' path='docs/doc[@for="XhtmlFormAdapter.RenderPagerTag"]/*' />
        protected virtual void RenderPagerTag(
            XhtmlMobileTextWriter writer,
            int pageToNavigate,
            String text,
            String accessKeyCustomAttribute)
        {
            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);
            ConditionalRenderCustomAttribute(writer, accessKeyCustomAttribute, XhtmlConstants.AccessKeyCustomAttribute);
            writer.Write("/>");
        }
コード例 #29
0
        // Render a single ObjectListItem in list view.
        private void RenderListViewItem (XhtmlMobileTextWriter writer, ObjectListItem item, int fieldCount, int[] fieldIndices, bool itemRequiresMoreButton, bool itemRequiresHyperlink) {
            Style style = Style;
            Style subCommandStyle = Control.CommandStyle;
            String accessKey = GetCustomAttributeValue(item, XhtmlConstants.AccessKeyCustomAttribute);
            String cssClass = GetCustomAttributeValue(item, XhtmlConstants.CssClassCustomAttribute);
            String subCommandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute);
            if (subCommandClass == null || subCommandClass.Length == 0) {
                subCommandClass = cssClass;
            }

            writer.WriteLine("<tr>");

            // Render fields.
            for (int field = 0; field < fieldCount; field++) {
                writer.Write("<td>");
                if (field == 0 && itemRequiresHyperlink) {
                    String eventArgument = HasDefaultCommand() ? item.Index.ToString(CultureInfo.InvariantCulture) : String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index.ToString(CultureInfo.InvariantCulture));
                    RenderPostBackEventAsAnchor(writer, eventArgument, item[fieldIndices[0]], accessKey, Style, cssClass);
                }
                else {
                    writer.WriteEncodedText (item[fieldIndices[field]]);
                }
                writer.WriteLine("</td>");
            }

            if (itemRequiresMoreButton) {
                writer.Write("<td>");
                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,
                    subCommandClass);
                writer.WriteLine("</td>");
            }
            writer.WriteLine("</tr>");
        }
コード例 #30
0
 // Called from RenderItemDetails.  (Extracted for intelligibility.)
 private void RenderItemFieldsInDetailsView (XhtmlMobileTextWriter writer, ObjectListItem item) {
     Style style = Style;
     IObjectListFieldCollection fields = Control.AllFields;
     foreach (ObjectListField field in fields) {
         if (field.Visible) {
             writer.Write("<tr><td>");
             ConditionalEnterStyle(writer, Style);
             writer.WriteEncodedText (field.Title);
             ConditionalExitStyle(writer, Style);
             writer.Write("</td><td>");
             ConditionalEnterStyle(writer, style);
             writer.WriteEncodedText (item [fields.IndexOf (field)]);
             ConditionalExitStyle(writer, style);
             writer.WriteLine("</td></tr>");
         }
     }
 }
コード例 #31
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);
        }
コード例 #32
0
        /////////////////////////////////////////////////////////////////////////
        // SPECIALIZED UTILITY METHODS FOR LIST SELECTIONLIST OBJECTLIST
        /////////////////////////////////////////////////////////////////////////

        // tagname can be any of table, ul, ol.  See the list adapters for examples.
        /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderOpeningListTag"]/*' />
        protected virtual void RenderOpeningListTag(XhtmlMobileTextWriter writer, String tagName) {            
            String classAttribute = (String) Control.CustomAttributes[XhtmlConstants.CssClassCustomAttribute];
            if (CssLocation == StyleSheetLocation.PhysicalFile && (String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true") {
                writer.WritePendingBreak();
                writer.WriteBeginTag(tagName);            
                if (classAttribute != null && 
                    classAttribute.Length > 0 &&
                    writer.DiffersFromCurrentPhysicalCssClass(classAttribute)) {
                    writer.WriteAttribute("class", classAttribute, true);
                    writer.PushPhysicalCssClass(classAttribute);
                    Debug.Assert(!_physicalCssClassPushed, "These calls should not be nested.");
                    _physicalCssClassPushed = true;
                }
                writer.Write(">");
            }
            else if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true") {
                writer.WritePendingBreak();
                StyleFilter filter = writer.CurrentStyleClass.GetFilter(Style);
                writer.EnterStyle(new XhtmlFormatStyleClass(Style, filter), tagName);
            }
            else {
                writer.WritePendingBreak();
                writer.WriteFullBeginTag(tagName);
            }
        }
コード例 #33
0
 private void RenderCookielessDataDictionaryInQueryString (XhtmlMobileTextWriter writer, bool queryStringWritten) {
     IDictionary dictionary = PageAdapter.CookielessDataDictionary;
     if (dictionary != null) {
         foreach (String name in dictionary.Keys) {
             if (queryStringWritten) {
                 String amp = (String)Device[XhtmlConstants.SupportsUrlAttributeEncoding] != "false" ? "&amp;" : "&";
                 writer.Write(amp);
             }
             else {
                 writer.Write ('?');
                 queryStringWritten = true;
             }
             writer.Write (name);
             writer.Write ('=');
             writer.Write (dictionary[name]);
         }
     }
 }
コード例 #34
0
 /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderBeginLink"]/*' />
 protected virtual void RenderBeginLink(XhtmlMobileTextWriter writer, String target, String accessKey, Style style, String cssClass, String title) {
     writer.WriteBeginTag("a");
     writer.Write(" href=\"");
     RenderHrefValue (writer, target);
     writer.Write("\"");
     if (accessKey != null && accessKey.Length > 0) {
         writer.WriteAttribute("accesskey", accessKey, 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 */);
     }
     if (title != null && title.Length > 0) {
         writer.WriteAttribute("title", title, true /* encode */);
     }
     writer.WriteLine(">");            
 }
コード例 #35
0
 private void RenderPostbackUrl(XhtmlMobileTextWriter writer) {
     if ((String)Device["requiresAbsolutePostbackUrl"] == "true") {
         RenderAbsolutePostbackUrl (writer);
         return;
     }
     if (Control.Action.Length > 0) {
         String url = Control.ResolveUrl(PreprocessQueryString(Control.Action));
         writer.Write(url);
     }
     else {
         writer.WriteEncodedUrl(Page.RelativeFilePath);
     }
 }
コード例 #36
0
 private void RenderAsInputTypeSubmit(XhtmlMobileTextWriter writer){
     ConditionalEnterStyle(writer, Style);
     writer.WriteBeginTag("input");
     writer.WriteAttribute("type", "submit");
     writer.WriteAttribute("name", Control.UniqueID);
     writer.WriteAttribute("value", Control.Text, true);
     ConditionalRenderClassAttribute(writer);
     ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
     writer.Write("/>");
     // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
     // ConditionalExitStyle may render a block element and clear the pending break.
     ConditionalSetPendingBreakAfterInline(writer);
     ConditionalPopPhysicalCssClass(writer);
     ConditionalExitStyle(writer, Style);
 }
コード例 #37
0
        /// <include file='doc\XhtmlBasicImageAdapter.uex' path='docs/doc[@for="XhtmlImageAdapter.RenderImage"]/*' />
        protected virtual void RenderImage(XhtmlMobileTextWriter writer) {
            String source = Control.ImageUrl;
            writer.WriteBeginTag("img");
            if(source != null && source.Length > 0) {
                source = Page.Server.UrlPathEncode(Control.ResolveUrl(source.Trim()));
                writer.WriteAttribute("src", source, true);
                writer.AddResource(source);
            }

            String alternateText = Control.AlternateText;
            if (alternateText == null || alternateText.Length == 0) {
                alternateText = " "; // ASURT 143759 and VSWhidbey 78593
            }
            writer.WriteAttribute("alt", alternateText, true);
            
            // Review: Html adapter writes border=0 attribute, but don't need this here?
            writer.Write(" />");
        }
コード例 #38
0
        /// <include file='doc\XhtmlBasicCalendarAdapter.uex' path='docs/doc[@for="XhtmlCalendarAdapter.Render"]/*' />
        public override void Render(XhtmlMobileTextWriter writer)
        {
            ArrayList          arr;
            DateTime           tempDate;
            DateTimeFormatInfo currentDateTimeInfo        = DateTimeFormatInfo.CurrentInfo;
            String             abbreviatedMonthDayPattern = AbbreviateMonthPattern(currentDateTimeInfo.MonthDayPattern);

            _threadCalendar = currentDateTimeInfo.Calendar;

            ConditionalClearPendingBreak(writer);
            ConditionalEnterStyle(writer, Style);
            // Use div (rather than span) with all secondaryUIModes for consistency across secondary UI.
            // If span is used in secondary ui, no alignment is possible.  If span is used in FirstPrompt
            // and div for secondary ui, alignment will not be consistent.
            ConditionalRenderOpeningDivElement(writer);

            Debug.Assert(NotSecondaryUI == NotSecondaryUIInit);
            switch (SecondaryUIMode)
            {
            case FirstPrompt:
                String promptText = Control.CalendarEntryText;
                if (promptText == null || promptText.Length == 0)
                {
                    promptText = SR.GetString(SR.CalendarAdapterFirstPrompt);
                }

                // Link to input option selection screen
                RenderPostBackEventAsAnchor(writer,
                                            OptionPrompt.ToString(CultureInfo.InvariantCulture),
                                            promptText);

                // We should honor BreakAfter property here as the first
                // UI is shown with other controls on the same form.
                // For other secondary UI, it is not necessary.
                ConditionalSetPendingBreakAfterInline(writer);
                break;

            // Render the first secondary page that provides differnt
            // options to select a date.
            case OptionPrompt:
                writer.Write(SR.GetString(SR.CalendarAdapterOptionPrompt));
                writer.WriteBreak();

                arr = new ArrayList();

                // Option to select the default date
                arr.Add(Control.VisibleDate.ToString(
                            currentDateTimeInfo.ShortDatePattern, CultureInfo.CurrentCulture));

                // Option to another page that can enter a date by typing
                arr.Add(SR.GetString(SR.CalendarAdapterOptionType));

                // Options to a set of pages for selecting a date, a week
                // or a month by picking month/year, week and day
                // accordingly.  Available options are determined by
                // SelectionMode.
                arr.Add(SR.GetString(SR.CalendarAdapterOptionChooseDate));

                if (Control.SelectionMode == WebControls.CalendarSelectionMode.DayWeek ||
                    Control.SelectionMode == WebControls.CalendarSelectionMode.DayWeekMonth)
                {
                    arr.Add(SR.GetString(SR.CalendarAdapterOptionChooseWeek));

                    if (Control.SelectionMode == WebControls.CalendarSelectionMode.DayWeekMonth)
                    {
                        arr.Add(SR.GetString(SR.CalendarAdapterOptionChooseMonth));
                    }
                }
                DataBindAndRender(writer, _optionList, arr);
                break;

            // Render a title and textbox to capture a date entered by user
            case TypeDate:
                if (_textBoxErrorMessage != null)
                {
                    writer.Write(_textBoxErrorMessage);
                    writer.WriteBreak();
                }

                if (_selectList.Visible)
                {
                    writer.Write(SR.GetString(SR.CalendarAdapterOptionEra));
                    writer.WriteBreak();
                    _selectList.RenderControl(writer);
                }

                String numericDateFormat = GetNumericDateFormat();

                writer.Write(SR.GetString(SR.CalendarAdapterOptionType));
                writer.Write(":");
                writer.WriteBreak();
                writer.Write("(");
                writer.Write(numericDateFormat.ToUpper(CultureInfo.InvariantCulture));
                writer.Write(")");

                if (!_selectList.Visible)
                {
                    writer.Write(GetEra(Control.VisibleDate));
                }
                writer.WriteBreak();

                _textBox.Numeric   = true;
                _textBox.Size      = numericDateFormat.Length;
                _textBox.MaxLength = numericDateFormat.Length;
                _textBox.Text      = Control.VisibleDate.ToString(numericDateFormat, CultureInfo.CurrentCulture);
                _textBox.Visible   = true;
                _textBox.RenderControl(writer);

                // Command button for sending the textbox value back to the server
                _command.Text    = GetDefaultLabel(OKLabel);
                _command.Visible = true;
                _command.RenderControl(writer);

                break;

            // Render a paged list for choosing a month
            case ChooseMonth:
                writer.Write(SR.GetString(SR.CalendarAdapterOptionChooseMonth));
                writer.Write(":");
                writer.WriteBreak();

                tempDate = Control.VisibleDate;

                String abbreviatedYearMonthPattern = AbbreviateMonthPattern(currentDateTimeInfo.YearMonthPattern);

                // This is to be consistent with ASP.NET Calendar control
                // on handling YearMonthPattern:
                // Some cultures have a comma in their YearMonthPattern,
                // which does not look right in a calendar.  Here we
                // strip the comma off.
                int indexComma = abbreviatedYearMonthPattern.IndexOf(',');
                if (indexComma >= 0)
                {
                    abbreviatedYearMonthPattern =
                        abbreviatedYearMonthPattern.Remove(indexComma, 1);
                }

                arr = new ArrayList();
                for (int i = 0; i < _monthsToDisplay; i++)
                {
                    arr.Add(tempDate.ToString(abbreviatedYearMonthPattern, CultureInfo.CurrentCulture));
                    tempDate = _threadCalendar.AddMonths(tempDate, 1);
                }
                arr.Add(GetDefaultLabel(NextLabel));
                arr.Add(GetDefaultLabel(PreviousLabel));

                DataBindAndRender(writer, _monthList, arr);
                break;

            // Based on the month selected in case ChooseMonth above, render a list of
            // availabe weeks of the month.
            case ChooseWeek:
                String monthFormat = (GetNumericDateFormat()[0] == 'y') ? "yyyy/M" : "M/yyyy";
                writer.Write(SR.GetString(SR.CalendarAdapterOptionChooseWeek));
                writer.Write(" (");
                writer.Write(Control.VisibleDate.ToString(monthFormat, CultureInfo.CurrentCulture));
                writer.Write("):");
                writer.WriteBreak();

                // List weeks of days of the selected month.  May include
                // days from the previous and the next month to fill out
                // all six week choices.  This is consistent with the
                // ASP.NET Calendar control.

                // Note that the event handling code of this list control
                // should be implemented according to the index content
                // generated here.

                tempDate = FirstCalendarDay(Control.VisibleDate);

                arr = new ArrayList();
                String weekDisplay;
                for (int i = 0; i < 6; i++)
                {
                    weekDisplay  = tempDate.ToString(abbreviatedMonthDayPattern, CultureInfo.CurrentCulture);
                    weekDisplay += DaySeparator;
                    tempDate     = _threadCalendar.AddDays(tempDate, 6);
                    weekDisplay += tempDate.ToString(abbreviatedMonthDayPattern, CultureInfo.CurrentCulture);
                    arr.Add(weekDisplay);
                    tempDate = _threadCalendar.AddDays(tempDate, 1);
                }

                DataBindAndRender(writer, _weekList, arr);
                break;

            // Based on the month and week selected in case ChooseMonth and ChooseWeek above,
            // render a list of the dates in the week.
            case ChooseDay:
                writer.Write(SR.GetString(SR.CalendarAdapterOptionChooseDate));
                writer.Write(":");
                writer.WriteBreak();

                tempDate = Control.VisibleDate;

                arr = new ArrayList();
                String        date;
                String        dayName;
                StringBuilder dayDisplay   = new StringBuilder();
                bool          dayNameFirst = (GetNumericDateFormat()[0] != 'y');

                for (int i = 0; i < 7; i++)
                {
                    date = tempDate.ToString(abbreviatedMonthDayPattern, CultureInfo.CurrentCulture);

                    if (Control.ShowDayHeader)
                    {
                        // Use the short format for displaying day name
                        dayName           = GetAbbreviatedDayName(tempDate);
                        dayDisplay.Length = 0;

                        if (dayNameFirst)
                        {
                            dayDisplay.Append(dayName);
                            dayDisplay.Append(Space);
                            dayDisplay.Append(date);
                        }
                        else
                        {
                            dayDisplay.Append(date);
                            dayDisplay.Append(Space);
                            dayDisplay.Append(dayName);
                        }
                        arr.Add(dayDisplay.ToString());
                    }
                    else
                    {
                        arr.Add(date);
                    }
                    tempDate = _threadCalendar.AddDays(tempDate, 1);
                }

                DataBindAndRender(writer, _dayList, arr);
                break;

            default:
                Debug.Assert(false, "Unexpected Secondary UI Mode");
                break;
            }
            ConditionalRenderClosingDivElement(writer);
            ConditionalExitStyle(writer, Style);
        }
コード例 #39
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);
        }
コード例 #40
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");            
 }
コード例 #41
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);
        }
コード例 #42
0
        private void ConditionalRenderLinkElement (XhtmlMobileTextWriter writer) {
            if (DoesDeviceRequireCssSuppression()) {
                return;
            }

            String cssLocation = (String) Page.ActiveForm.CustomAttributes[XhtmlConstants.StyleSheetLocationCustomAttribute];
            if (cssLocation != null &&
                cssLocation.Length != 0) {
                writer.WriteBeginTag ("link");
                writer.WriteAttribute ("type", "text/css");
                writer.WriteAttribute ("rel", "stylesheet");
                writer.WriteAttribute("href", cssLocation, true);
                writer.WriteLine("/>");
            }
            else if (!writer.IsStyleSheetEmpty () && CssLocation!=StyleSheetLocation.Internal) {
                writer.WriteLine ();
                writer.WriteBeginTag ("link");
                writer.WriteAttribute ("type", "text/css");
                writer.WriteAttribute ("rel", "stylesheet");
                String queryStringValue = GetCssQueryStringValue(writer);
                writer.Write(" href=\"" + XhtmlConstants.CssMappedFileName + "?" + XhtmlConstants.CssQueryStringName + "=" + queryStringValue + "\"/>");
                writer.WriteLine();
            }
        }
コード例 #43
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");
        }
コード例 #44
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(); 
     }
 }
コード例 #45
0
 private void RenderAbsolutePostbackUrl(XhtmlMobileTextWriter writer) {
     String url = PreprocessQueryString(Control.Action);
     if (url.Length > 0) {
         // Not only do we need to resolve the URL, but we need to make it absolute.
         url = Page.MakePathAbsolute(Control.ResolveUrl(url));
         writer.Write(url);
     }
     else {
         writer.WriteEncodedUrl(Page.AbsoluteFilePath);
     }
 }
コード例 #46
0
 private void RenderHiddenVariablesInUrl(XhtmlMobileTextWriter writer) {
     if (Page.HasHiddenVariables()) {
         String hiddenVariablePrefix = MobilePage.HiddenVariablePrefix;
         foreach (DictionaryEntry entry in Page.HiddenVariables) {
             writer.Write("&amp;");
             writer.WriteUrlParameter(hiddenVariablePrefix + (String)entry.Key,
                 (String)entry.Value);
         }
     }
 }
コード例 #47
0
        // Writes the href value for RenderBeginLink, depending on whether the target is a new form on the 
        // current page or a standard url (e.g., a new page).
        private void RenderHrefValue (XhtmlMobileTextWriter writer, String target) {
            bool appendCookielessDataDictionary = PageAdapter.PersistCookielessData  && 
                !target.StartsWith("http:", StringComparison.Ordinal) && 
                !target.StartsWith("https:", StringComparison.Ordinal);
            bool queryStringWritten = false;

            // ASURT 144021
            if (target == null || target.Length == 0) {
                target = Page.Response.ApplyAppPathModifier(Control.TemplateSourceDirectory);
            }



            if (target.StartsWith(Constants.FormIDPrefix, StringComparison.Ordinal)) {
                RenderFormNavigationHrefValue (writer, target);
                appendCookielessDataDictionary = false;
            }
            else {
                // For page adapter Control = null.
                if (Control != null) {
                    target = Control.ResolveUrl(target);
                }
                
                // ASURT 147179
                if ((String)Device["requiresAbsolutePostbackUrl"] == "true"
                    && IsRelativeUrl(target)) {
                    String templateSourceDirectory = Page.TemplateSourceDirectory;
                    String prefix = writer.EncodeUrlInternal(Page.Response.ApplyAppPathModifier(Page.TemplateSourceDirectory));
                    if (prefix[prefix.Length - 1] != '/') {
                        prefix = prefix + '/';
                    }
                    target = prefix + target;
                }

                if ((String)Device[XhtmlConstants.SupportsUrlAttributeEncoding] != "false") {
                    writer.WriteEncodedText (target);
                }
                else {
                    writer.Write (target);                
                }
                queryStringWritten = target.IndexOf ('?') != -1;
            }

            if (appendCookielessDataDictionary) {
                RenderCookielessDataDictionaryInQueryString (writer, queryStringWritten);
            }
        }
コード例 #48
0
 private void RenderOpeningBodyElement(XhtmlMobileTextWriter writer) {
     Form activeForm = Page.ActiveForm;
     Style formStyle = ((ControlAdapter)activeForm.Adapter).Style;
     if (CssLocation == StyleSheetLocation.PhysicalFile) {
         String cssClass = (String) activeForm.CustomAttributes[XhtmlConstants.CssClassCustomAttribute];
         writer.WriteBeginTag("body");
         if (cssClass != null  && (String)Device["supportsBodyClassAttribute"] != "false") {
             writer.WriteAttribute("class", cssClass, true /* encode */);
             writer.PushPhysicalCssClass(cssClass);
             _pushedCssClassForBody = true;
         }
         writer.Write(">");
     }
     else if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true" &&
         (String)Device[XhtmlConstants.SupportsBodyClassAttribute] != "false") {
         writer.EnterStyle(formStyle, "body");
     }
     else {
         writer.WriteFullBeginTag("body");    
         if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true" &&
             (String)Device[XhtmlConstants.SupportsBodyClassAttribute] == "false") {
             writer.SetBodyStyle(formStyle);
         }
     }
 }
コード例 #49
0
 // Render opening <div class=...> in case the stylesheet location has been specified as a physical file.
 /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalRenderOpeningDivElement"]/*' />
 protected virtual void ConditionalRenderOpeningDivElement(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.WriteBeginTag("p");
         }
         else {
             writer.WriteBeginTag("div");
         }
         if (classAttribute != null && 
             classAttribute.Length > 0 &&
             writer.DiffersFromCurrentPhysicalCssClass(classAttribute)) {
             writer.WriteAttribute("class", classAttribute, true);
             writer.PushPhysicalCssClass(classAttribute);
             Debug.Assert(!_physicalCssClassPushed, "These calls should not be nested.");
             _physicalCssClassPushed = true;
         }
         writer.Write(">");
     }
 }
コード例 #50
0
        /// <include file='doc\XhtmlBasicPageAdapter.uex' path='docs/doc[@for="XhtmlPageAdapter.RenderUrlPostBackEvent"]/*' />
        public virtual void RenderUrlPostBackEvent (XhtmlMobileTextWriter writer,
            String target, 
            String argument) {

            String amp = (String)Device[XhtmlConstants.SupportsUrlAttributeEncoding] == "false"  ? "&" : "&amp;";
            
            if ((String)Device["requiresAbsolutePostbackUrl"] == "true") {
                writer.WriteEncodedUrl(Page.AbsoluteFilePath);
            }
            else {
                writer.WriteEncodedUrl(Page.RelativeFilePath);
            }
            writer.Write ("?");

            // Encode ViewStateID=.....&__ET=controlid&__EA=value in URL
            // Note: the encoding needs to be agreed with the page
            // adapter which handles the post back info
            String pageState = Page.ClientViewState;
            if (pageState != null) {
                writer.WriteUrlParameter (MobilePage.ViewStateID, pageState);
                writer.Write (amp);
            }
            writer.WriteUrlParameter (EventSourceKey, target);
            writer.Write (amp);
            writer.WriteUrlParameter (EventArgumentKey, argument);
            RenderHiddenVariablesInUrl (writer);

            // Unique file path suffix is used for identify if query
            // string text is present.  Corresponding code needs to agree
            // on this.  Even if the query string is empty, we still need
            // to output the suffix to indicate this. (this corresponds
            // to the code that handles the postback)
            writer.Write(amp);
            writer.Write(Constants.UniqueFilePathSuffixVariable);

            String queryStringText = PreprocessQueryString(Page.QueryStringText);

            if (queryStringText != null && queryStringText.Length > 0) {
                writer.Write (amp);
                if ((String)Device[XhtmlConstants.SupportsUrlAttributeEncoding] != "false") {
                    writer.WriteEncodedAttributeValue(queryStringText);
                }
                else {
                    writer.Write (queryStringText);
                }
            }
        }
コード例 #51
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");
 }
コード例 #52
0
        /////////////////////////////////////////////////////////////////////////
        //  PAGINATION SUPPORT
        /////////////////////////////////////////////////////////////////////////
        /// <include file='doc\XhtmlBasicFormAdapter.uex' path='docs/doc[@for="XhtmlFormAdapter.RenderPager"]/*' />
        protected virtual void RenderPager (XhtmlMobileTextWriter writer) {
            PagerStyle pagerStyle = Control.PagerStyle;

            int pageCount = Control.PageCount;
            if (pageCount <= 1) {
                return;
            }
            int page = Control.CurrentPage;
            String text = pagerStyle.GetPageLabelText(page, pageCount);

            if((page > 1) || (text.Length > 0) || (page < pageCount)) {
                writer.WritePendingBreak();
                ConditionalEnterStyle(writer, pagerStyle);
                ConditionalEnterPagerSpan(writer);
            }

            if (page > 1) {
                RenderPagerTag(writer, page - 1,
                    pagerStyle.GetPreviousPageText(page),
                    XhtmlConstants.PagerPreviousAccessKeyCustomAttribute);
                writer.Write(" ");
            }

            if (text.Length > 0) {
                writer.WriteEncodedText(text);
                writer.Write(" ");
            }

            if (page < pageCount) {
                RenderPagerTag(writer, page + 1,
                    pagerStyle.GetNextPageText(page),
                    XhtmlConstants.PagerNextAccessKeyCustomAttribute);
            }

            if((page > 1) || (text.Length > 0) || (page < pageCount)) {
                ConditionalExitPagerSpan(writer);
                ConditionalExitStyle(writer, pagerStyle);
                writer.SetPendingBreak();
            }
        }
コード例 #53
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);
        }
コード例 #54
0
 private void ConditionalEnterPagerSpan(XhtmlMobileTextWriter writer) {
     String cssClass = GetCustomAttributeValue(XhtmlConstants.CssPagerClassCustomAttribute);
     if (CssLocation == StyleSheetLocation.PhysicalFile &&
         cssClass != null && 
         cssClass.Length > 0) {
         writer.WriteBeginTag ("span");
         writer.WriteAttribute("class", cssClass, true);
         _pagerCssSpanWritten = true;
         writer.Write(">");
     }
 }
コード例 #55
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);
        }
コード例 #56
0
        /// <include file='doc\XhtmlBasicFormAdapter.uex' path='docs/doc[@for="XhtmlFormAdapter.RenderPagerTag"]/*' />
        protected virtual void RenderPagerTag(
            XhtmlMobileTextWriter writer,
            int pageToNavigate,
            String text,
            String accessKeyCustomAttribute) {
            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);
            ConditionalRenderCustomAttribute(writer, accessKeyCustomAttribute, XhtmlConstants.AccessKeyCustomAttribute);
            writer.Write("/>");
        }
コード例 #57
0
 private void RenderListViewTableHeader (XhtmlMobileTextWriter writer, int fieldCount, int[] fieldIndices, bool itemRequiresMoreButton){
     String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
     String labelClass = GetCustomAttributeValue(XhtmlConstants.CssLabelClassCustomAttribute); 
     if (labelClass == null || labelClass.Length == 0) {
         labelClass = cssClass;
     }
     writer.WriteLine("<tr>");
     for (int field = 0; field < fieldCount; field++) {
         writer.WriteBeginTag("td");
         if (CssLocation == StyleSheetLocation.PhysicalFile && labelClass != null && labelClass.Length > 0) {
             writer.WriteAttribute("class", labelClass, true);
         }
         writer.Write(">");
         Style labelStyle = Control.LabelStyle;
         ConditionalEnterStyle(writer, labelStyle);
         writer.WriteEncodedText(Control.AllFields[fieldIndices[field]].Title);
         ConditionalExitStyle(writer, labelStyle);
         writer.Write("</td>");
     }
     if (itemRequiresMoreButton) {
         writer.WriteLine("<td/>");
     }
     writer.WriteLine();
     writer.WriteLine("</tr>");
 }
コード例 #58
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);
        }
コード例 #59
0
        private void RenderListBody (XhtmlMobileTextWriter writer, String itemPrefix, String itemSuffix) {
            int pageStart = Control.FirstVisibleItemIndex;
            int pageSize = Control.VisibleItemCount;

            for (int i = 0; i < pageSize; i++) {
                MobileListItem item = Control.Items[pageStart + i];
                writer.Write (itemPrefix);
                RenderListItem (writer, item);
                writer.WriteLine(itemSuffix);
            }        
        }
コード例 #60
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);
            }
        }