// Partial copy constructor
 public XhtmlStyleClass(Style source, StyleFilter filter)
 {
     _controlStyle = (Style)source.Clone();
     // Filter has bits set to zero for properties which don't need
     // to be written due to style inheritance from parent.
     _filter = filter;
 }
        /////////////////////////////////////////////////////////////////////////
        // 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);
            }
        }
    private void LoadDirectory(string directory)
    {
        if (Directory != directory)
        {
            Directory    = directory;
            Export       = new bool[0];
            Animations   = new MotionData[0];
            StyleFilters = new StyleFilter[0];
            string path = "Assets/" + Directory;
            if (AssetDatabase.IsValidFolder(path))
            {
                string[] files = AssetDatabase.FindAssets("t:MotionData", new string[1] {
                    path
                });
                Export     = new bool[files.Length];
                Animations = new MotionData[files.Length];
                for (int i = 0; i < files.Length; i++)
                {
                    Export[i]     = true;
                    Animations[i] = (MotionData)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(files[i]), typeof(MotionData));
                }

                StyleFilters = new StyleFilter[Animations[0].Styles.Length];
                for (int i = 0; i < StyleFilters.Length; i++)
                {
                    StyleFilters[i] = new StyleFilter(Animations[0].Styles[i], new int[1] {
                        i
                    });
                }
            }
        }
    }
Example #4
0
        // Please see ASURT 144034 for this device-specific issue.
        // Internal-only utility to return name of an XhtmlFormatStyleClass that represents the (format) diff of the
        // parameter from the current style. This does not push the style stack -it is used only for tags with
        // small content models such as <a>.
        internal String GetCssFormatClassName(Style style)
        {
            if (!_cachingRendering)
            {
                Debug.Fail("Only call when caching rendering");
                return(null);
            }
            if (style == null)
            {
                return(null); // caller should check for this return value.
            }
            // We need to write all non-default properties, so get the filter from the _defaultStyleClass.
            StyleFilter filter = _defaultStyleClass.GetFilter(style);

            filter &= XhtmlConstants.Format;
            if (filter == StyleFilter.None)
            {
                return(null);
            }
            XhtmlFormatStyleClass styleClass = new XhtmlFormatStyleClass(style, filter);
            // Value returned is a valid styleClass which can be added to the attributes of, e.g., an <a> element
            // to cause character formatting.  Please see 144034 for the device specific issue.
            XhtmlStyleClass hashStyleClass = EnsureXhtmlStyleClassInHashtable(styleClass);

            if (hashStyleClass == null)
            {
                return(null);
            }
            return(hashStyleClass.StyleClassName);
        }
Example #5
0
        /// <include file='doc\XhtmlMobileTextWriter.uex' path='docs/doc[@for="XhtmlMobileTextWriter.SetBodyStyle"]/*' />
        public virtual void SetBodyStyle(Style style)
        {
            // Filter is not strictly needed here, since default property values are not written anyway
            // but it is a good practice to provide a meaningful filter.
            StyleFilter filter = _defaultStyleClass.GetFilter(style);

            _bodyStyle         = new XhtmlStyleClass(style, filter);
            _isStyleSheetEmpty = filter == 0;
        }
Example #6
0
        /// <include file='doc\XhtmlMobileTextWriter.uex' path='docs/doc[@for="XhtmlMobileTextWriter.EnterLayout"]/*' />
        public override void EnterLayout(Style style)
        {
            StyleFilter filter = CurrentStyleClass.GetFilter(style);

            if (!SupportsNoWrapStyle)
            {
                filter &= ~StyleFilter.Wrapping;
            }
            EnterStyleInternal(new XhtmlLayoutStyleClass(style, filter), "div", null /* no additional attributes */, true /* force tag to be written */);
        }
        public override StyleFilter GetFilter(Style style)
        {
            StyleFilter returnValue = GetFilterInternal(style);

            // For a child control's style, there are no format properties
            // we can ignore due to style inheritance.
            returnValue |= XhtmlConstants.Format;
            // However, we can still ignore properties which are the same as the default.
            returnValue &= XhtmlConstants.DefaultStyleClass.GetFilter(style);
            return(returnValue);
        }
        // Given a Style, returns a filter with nonzero bits only at properties which have
        // to be written.
        public virtual StyleFilter GetFilter(Style style)
        {
            // Filter out any child elt style properties which do not have to be written due to style inheritance.
            StyleFilter inheritanceFilter = GetFilterInternal(style);

            // Filter out any child elt style properties which are unnecessary because they have default values.
            // Default values never cause a CSS style class property to be written.
            StyleFilter defaultFilter = XhtmlConstants.DefaultStyleClass.GetFilterInternal(style);

            return(inheritanceFilter & defaultFilter);
        }
Example #9
0
        // This internal overload can be used to enter style by setting the class element
        // on a caller-specified tag, such as <body> or <table>.
        internal void EnterStyle(Style style, String styleTag)
        {
            StyleFilter filter = CurrentStyleClass.GetFilter(style);

            if (filter == StyleFilter.None)
            {
                WriteFullBeginTag(styleTag);
                _styleStack.Push(new StylePair(styleTag, style, StyleFilter.None));
                return;
            }
            EnterStyleInternal(style, styleTag, filter);
        }
        /// <include file='doc\XhtmlBasicImageAdapter.uex' path='docs/doc[@for="XhtmlImageAdapter.Render"]/*' />
        public override void Render(XhtmlMobileTextWriter writer)
        {
            string target = Control.NavigateUrl;

            ConditionalClearPendingBreak(writer);
            Style       style  = Style;
            StyleFilter filter = writer.CurrentStyleClass.GetFilter(style);

            if ((filter & XhtmlConstants.Layout) != 0)
            {
                ConditionalEnterLayout(writer, style);
            }

            if (target != null && target.Length > 0)
            {
                String cssClass  = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
                String accessKey = GetCustomAttributeValue(XhtmlConstants.AccessKeyCustomAttribute);
                String title     = GetCustomAttributeValue(XhtmlConstants.TitleCustomAttribute);
                RenderBeginLink(writer, target, accessKey, style, cssClass, title);
            }
            else
            {
                ConditionalEnterFormat(writer, style);
                ConditionalRenderOpeningSpanElement(writer);
            }
            String controlIU = Control.ImageUrl;

            if (controlIU == null || controlIU.Length == 0)
            {
                writer.WriteEncodedText(Control.AlternateText);
            }
            else
            {
                RenderImage(writer);
            }
            ConditionalSetPendingBreakAfterInline(writer);
            if (target != null && target.Length > 0)
            {
                RenderEndLink(writer);
            }
            else
            {
                ConditionalRenderClosingSpanElement(writer);
                ConditionalExitFormat(writer, style);
            }
            if ((filter & XhtmlConstants.Layout) != 0)
            {
                ConditionalExitLayout(writer, style);
            }
        }
Example #11
0
        // Hiding inherited member works because dynamic type is same as static type.
        /// <include file='doc\XhtmlMobileTextWriter.uex' path='docs/doc[@for="XhtmlMobileTextWriter.EnterStyle"]/*' />
        public new void EnterStyle(Style style)
        {
            StyleFilter filter = CurrentStyleClass.GetFilter(style);

            if (!SupportsNoWrapStyle)
            {
                filter &= ~StyleFilter.Wrapping;
            }
            // We prefer span to div because span is inline.
            if ((filter & XhtmlConstants.Layout) == 0)
            {
                EnterStyleInternal(style, "span", filter);
            }
            else
            {
                EnterStyleInternal(new XhtmlStyleClass(style, filter), "div", null /*additional attributes */, true /* force tag to be written */);
            }
        }
        // The XhtmlStyleClass for a child control can filter out unnecessary properties
        // due to style inheritance.  This returns an optimized StyleFilter for child
        // controls with a given style.
        protected virtual StyleFilter GetFilterInternal(Style style)
        {
            StyleFilter returnValue = StyleFilter.None;

            if ((BooleanOption)_controlStyle [Style.BoldKey, true] != (BooleanOption)style [Style.BoldKey, true])
            {
                returnValue |= StyleFilter.Bold;
            }
            if ((BooleanOption)_controlStyle [Style.ItalicKey, true] != (BooleanOption)style [Style.ItalicKey, true])
            {
                returnValue |= StyleFilter.Italic;
            }
            if ((String)_controlStyle [Style.FontNameKey, true] != (String)style [Style.FontNameKey, true])
            {
                returnValue |= StyleFilter.FontName;
            }
            if ((FontSize)_controlStyle [Style.FontSizeKey, true] != (FontSize)style [Style.FontSizeKey, true])
            {
                returnValue |= StyleFilter.FontSize;
            }
            if ((Color)_controlStyle [Style.BackColorKey, true] != (Color)style [Style.BackColorKey, true])  // value comparison
            {
                returnValue |= StyleFilter.BackgroundColor;
            }
            if ((Color)_controlStyle [Style.ForeColorKey, true] != (Color)style [Style.ForeColorKey, true])  // value comparison
            {
                returnValue |= StyleFilter.ForegroundColor;
            }

            if ((Alignment)_controlStyle [Style.AlignmentKey, true] != (Alignment)style [Style.AlignmentKey, true])
            {
                returnValue |= StyleFilter.Alignment;
            }
            if ((Wrapping)_controlStyle [Style.WrappingKey, true] != (Wrapping)style [Style.WrappingKey, true])
            {
                returnValue |= StyleFilter.Wrapping;
            }
            return(returnValue);
        }
 // Partial copy constructor
 public XhtmlStyleClass (Style source, StyleFilter filter)  {
     _controlStyle = (Style) source.Clone();
     // Filter has bits set to zero for properties which don't need
     // to be written due to style inheritance from parent.
     _filter = filter;
 }
Example #14
0
        /// <include file='doc\XhtmlMobileTextWriter.uex' path='docs/doc[@for="XhtmlMobileTextWriter.EnterFormat"]/*' />
        public override void EnterFormat(Style style)
        {
            StyleFilter filter = CurrentStyleClass.GetFilter(style);

            EnterStyleInternal(new XhtmlFormatStyleClass(style, filter), "span", null /* no additional attributes */);
        }
 protected virtual void SetFilter(StyleFilter arg)
 {
     _filter = arg;
 }
 public XhtmlLayoutStyleClass (Style source, StyleFilter filter) : base (source, filter){
     SetFilter (Filter & XhtmlConstants.Layout);
 }
 internal void EnterStyleInternal (Style style, String styleTag, StyleFilter filter, NameValueCollection additionalAttributes) {
     EnterStyleInternal(new XhtmlStyleClass(style, filter), styleTag, additionalAttributes, false /* force tag to be written */);
 }
Example #18
0
 internal StylePair(String styleTag, Style style, StyleFilter filter)
 {
     Tag   = styleTag;
     Class = new XhtmlStyleClass(style, filter);
 }
 public XhtmlLayoutStyleClass(Style source, string className, StyleFilter filter) : base(source, className, filter)
 {
 }
 public XhtmlFormatStyleClass(Style source, StyleFilter filter) : base(source, filter)
 {
     SetFilter(Filter & XhtmlConstants.Format);
 }
 public XhtmlStyleClass (Style source, string className, StyleFilter filter) : this (source, filter){
     StyleClassName = className;
 }
Example #22
0
 // StyleTag is the tag used for the class attribute.  Possible values are div, span,
 // p, or any elt.  Div and span are preferred over p, since p can only contain inline elements.
 internal void EnterStyleInternal(Style style, String styleTag, StyleFilter filter)
 {
     EnterStyleInternal(style, styleTag, filter, null);
 }
 public XhtmlLayoutStyleClass (Style source, string className, StyleFilter filter) : base (source, className, filter){}
Example #24
0
 internal void EnterStyleInternal(Style style, String styleTag, StyleFilter filter, NameValueCollection additionalAttributes)
 {
     EnterStyleInternal(new XhtmlStyleClass(style, filter), styleTag, additionalAttributes, false /* force tag to be written */);
 }
 public XhtmlStyleClass(Style source, string className, StyleFilter filter) : this(source, filter)
 {
     StyleClassName = className;
 }
 public XhtmlLayoutStyleClass(Style source, StyleFilter filter) : base(source, filter)
 {
     SetFilter(Filter & XhtmlConstants.Layout);
 }
 protected virtual void SetFilter(StyleFilter arg) {
     _filter = arg;
 }
 // StyleTag is the tag used for the class attribute.  Possible values are div, span,
 // p, or any elt.  Div and span are preferred over p, since p can only contain inline elements.
 internal void EnterStyleInternal (Style style, String styleTag, StyleFilter filter) {
     EnterStyleInternal(style, styleTag, filter, null);
 }
Example #29
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);
            }
        }
 internal StylePair (String styleTag, Style style, StyleFilter filter) {
     Tag = styleTag;
     Class = new XhtmlStyleClass (style, filter);
 }
 public XhtmlFormatStyleClass (Style source, StyleFilter filter) : base (source, filter){
     SetFilter (Filter & XhtmlConstants.Format);
 }