/// <devdoc>
        ///    <para>
        ///       Adds a style to the CssStyleCollection.
        ///    </para>
        /// </devdoc>
        public void Add(string key, string value)
        {
            if (String.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException("key");
            }

            if (_table == null)
            {
                ParseString();
            }
            _table[key] = value;

            if (_intTable != null)
            {
                // Remove from the other table to avoid duplicates.
                HtmlTextWriterStyle style = CssTextWriter.GetStyleKey(key);
                if (style != (HtmlTextWriterStyle)(-1))
                {
                    _intTable.Remove(style);
                }
            }

            if (_state != null)
            {
                // keep style attribute synchronized
                _state["style"] = BuildString();
            }
            _style = null;
        }
Example #2
0
        private String GetStyleName(HtmlTextWriterStyle key)
        {
            String name = key.ToString();

            if (name.Contains("."))
            {
                name = name.Substring(name.LastIndexOf(".") + 1);
            }

            StringBuilder output = new StringBuilder();

            char[] cs = name.ToCharArray();
            for (int i = 0; i < cs.Length; i++)
            {
                if (Char.IsUpper(cs[i]) && i > 0)
                {
                    output.Append('-');
                    output.Append(cs[i]);
                }
                else
                {
                    output.Append(cs[i]);
                }
            }
            return(output.ToString());
        }
        public void Add(HtmlTextWriterStyle key, string value)
        {
            if (_intTable == null)
            {
                _intTable = new HybridDictionary();
            }
            _intTable[(int)key] = value;

            string name = CssTextWriter.GetStyleName(key);

            if (name.Length != 0)
            {
                // Remove from the other table to avoid duplicates.
                if (_table == null)
                {
                    ParseString();
                }

                _table.Remove(name);
            }

            if (_state != null)
            {
                // keep style attribute synchronized
                _state["style"] = BuildString();
            }
            _style = null;
        }
 public void Add(string key, string value)
 {
     if (string.IsNullOrEmpty(key))
     {
         throw new ArgumentNullException("key");
     }
     if (this._table == null)
     {
         this.ParseString();
     }
     this._table[key] = value;
     if (this._intTable != null)
     {
         HtmlTextWriterStyle styleKey = CssTextWriter.GetStyleKey(key);
         if (styleKey != ~HtmlTextWriterStyle.BackgroundColor)
         {
             this._intTable.Remove(styleKey);
         }
     }
     if (this._state != null)
     {
         this._state["style"] = this.BuildString();
     }
     this._style = null;
 }
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            string estilo = string.Empty;

            for (HtmlTextWriterStyle i = HtmlTextWriterStyle.Padding; i <= HtmlTextWriterStyle.PaddingTop; i++)
            {
                if (string.IsNullOrEmpty(estilo))
                {
                    estilo = Style[i];
                }
            }
            if (string.IsNullOrEmpty(estilo))
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "0");
            }
            estilo = string.Empty;
            for (HtmlTextWriterStyle i = HtmlTextWriterStyle.Margin; i <= HtmlTextWriterStyle.MarginTop; i++)
            {
                if (string.IsNullOrEmpty(estilo))
                {
                    estilo = Style[i];
                }
            }
            if (string.IsNullOrEmpty(estilo))
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Margin, "0");
            }

            //writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none")

            base.AddAttributesToRender(writer);
        }
Example #6
0
 public void AddStyleAttributeIfUndefined(HtmlTextWriterStyle attribute, string value)
 {
     if (!IsStyleAttributeDefined(attribute))
     {
         AddStyleAttribute(attribute, value);
     }
 }
 public static void AddStyleAttributeIfHave(this HtmlTextWriter writer, HtmlTextWriterStyle key, string value)
 {
     if (!string.IsNullOrEmpty(value))
     {
         writer.AddStyleAttribute(key, value);
     }
 }
 protected override bool OnStyleAttributeRender(string name, string value, HtmlTextWriterStyle key)
 {
     if ((key == HtmlTextWriterStyle.TextDecoration) && StringUtil.EqualsIgnoreCase("line-through", value))
     {
         return false;
     }
     return base.OnStyleAttributeRender(name, value, key);
 }
Example #9
0
 protected virtual void AddStyleAttribute(string name, string value, HtmlTextWriterStyle key)
 {
     NextStyleStack();
     styles [styles_pos].name = name;
     value = HttpUtility.HtmlAttributeEncode(value);
     styles [styles_pos].value = value;
     styles [styles_pos].key   = key;
 }
Example #10
0
 /// <summary>
 /// Does not render any style attribute except mso-number-format
 /// </summary>
 /// <param name="name"></param>
 /// <param name="value"></param>
 /// <param name="key"></param>
 /// <returns></returns>
 protected override bool OnStyleAttributeRender(string name, string value, HtmlTextWriterStyle key)
 {
     if (name == "mso-number-format" || name == "border")
     {
         return(true);
     }
     return(false);
 }
Example #11
0
		protected override void AddStyleAttribute (string name, string value, HtmlTextWriterStyle key)
		{
			output.WriteLine ("{0:###0} AddStyleAttribute ({1}, {2}, {3}))", NextIndex (), name, value, key);
			if (full_trace)
				WriteTrace (new StackTrace ());

			base.AddStyleAttribute (name, value, key);
		}
 protected override bool OnStyleAttributeRender(string name, string value, HtmlTextWriterStyle key)
 {
     if ((key == HtmlTextWriterStyle.TextDecoration) && StringUtil.EqualsIgnoreCase("line-through", value))
     {
         return(false);
     }
     return(base.OnStyleAttributeRender(name, value, key));
 }
 public static string GetStyleName(HtmlTextWriterStyle styleKey)
 {
     if ((styleKey >= HtmlTextWriterStyle.BackgroundColor) && (styleKey < attrNameLookupArray.Length))
     {
         return(attrNameLookupArray[(int)styleKey].name);
     }
     return(string.Empty);
 }
 public static bool IsStyleEncoded(HtmlTextWriterStyle styleKey)
 {
     if ((styleKey >= HtmlTextWriterStyle.BackgroundColor) && (styleKey < attrNameLookupArray.Length))
     {
         return(attrNameLookupArray[(int)styleKey].encode);
     }
     return(true);
 }
        /// <devdoc>
        /// Returns the name of the attribute corresponding to the specified HtmlTextWriterStyle value.
        /// </devdoc>
        public static string GetStyleName(HtmlTextWriterStyle styleKey)
        {
            if ((int)styleKey >= 0 && (int)styleKey < attrNameLookupArray.Length)
            {
                return(attrNameLookupArray[(int)styleKey].name);
            }

            return(String.Empty);
        }
        /// <devdoc>
        /// Does the specified style key require attribute value encoding if the value is being
        /// rendered in a style attribute.
        /// </devdoc>
        public static bool IsStyleEncoded(HtmlTextWriterStyle styleKey)
        {
            if ((int)styleKey >= 0 && (int)styleKey < attrNameLookupArray.Length)
            {
                return(attrNameLookupArray[(int)styleKey].encode);
            }

            return(true);
        }
Example #17
0
 public bool TryAddStyleAttribute(HtmlTextWriterStyle key, out string value)
 {
     if (!IsStyleAttributeDefined(key, out value))
     {
         AddStyleAttribute(key, value);
         return(true);
     }
     return(false);
 }
        internal static void RegisterAttribute(string name, HtmlTextWriterStyle key, bool encode, bool isUrl)
        {
            string str = name.ToLower(CultureInfo.InvariantCulture);

            attrKeyLookupTable.Add(str, key);
            if (key < attrNameLookupArray.Length)
            {
                attrNameLookupArray[(int)key] = new AttributeInformation(name, encode, isUrl);
            }
        }
        protected override bool OnStyleAttributeRender(string name, string value, HtmlTextWriterStyle key)
        {
            output.WriteLine("{0:###0} OnStyleAttributeRender ({1}, {2}, {3})", NextIndex(), name, value, key);
            if (full_trace)
            {
                WriteTrace(new StackTrace());
            }

            return(base.OnStyleAttributeRender(name, value, key));
        }
        protected override void AddStyleAttribute(string name, string value, HtmlTextWriterStyle key)
        {
            output.WriteLine("{0:###0} AddStyleAttribute ({1}, {2}, {3}))", NextIndex(), name, value, key);
            if (full_trace)
            {
                WriteTrace(new StackTrace());
            }

            base.AddStyleAttribute(name, value, key);
        }
Example #21
0
		public NamedCssStyleCollection RegisterStyle (HtmlTextWriterStyle key, string value, string styleName = null)
		{
			if (styleName == null)
				styleName = String.Empty;

			NamedCssStyleCollection style = GetStyle (styleName);
			style.Add (key, value);

			return style;
		}
 public HtmlTagBuilder MergeStyle(HtmlTextWriterStyle style, object value,
                                  bool replaceExisting = false)
 {
     Enforce.Argument(() => value);
     if (replaceExisting || !StyleValues.ContainsKey(style))
     {
         StyleValues[style] = value;
     }
     return(this);
 }
 public string this [HtmlTextWriterStyle key]
 {
     get
     {
         return(default(string));
     }
     set
     {
     }
 }
Example #24
0
 public string this[HtmlTextWriterStyle style]
 {
     get
     {
         return(this[new StyleConversion(style).CssStyleName]);
     }
     set
     {
         this[new StyleConversion(style).CssStyleName] = value;
     }
 }
Example #25
0
 public string this[HtmlTextWriterStyle style]
 {
     get
     {
         return this[new StyleConversion(style).CssStyleName];
     }
     set
     {
         this[new StyleConversion(style).CssStyleName] = value;
     }
 }
Example #26
0
 public string this [HtmlTextWriterStyle key]
 {
     get
     {
         return(style [HtmlTextWriter.StaticGetStyleName(key)] as string);
     }
     set
     {
         Add(HtmlTextWriter.StaticGetStyleName(key), value);
     }
 }
Example #27
0
        /// <summary>
        /// Removes the given CSS style from the <see cref="HtmlControl"/>.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="control"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static T RemoveCssStyle <T>(this T control, HtmlTextWriterStyle key)
            where T : HtmlControl
        {
            if (control == null)
            {
                throw new ArgumentNullException(nameof(control));
            }

            control.Style.Remove(key);

            return(control);
        }
 protected override bool OnStyleAttributeRender(string name, string value, HtmlTextWriterStyle key)
 {
     if (this._docType == XhtmlMobileDocType.XhtmlBasic)
     {
         return(false);
     }
     if (base.TagName.ToLower(CultureInfo.InvariantCulture).Equals("div") && name.ToLower(CultureInfo.InvariantCulture).Equals("border-collapse"))
     {
         return(false);
     }
     return(true);
 }
 /// <devdoc>
 /// Gets or sets the specified known CSS value.
 /// </devdoc>
 public string this[HtmlTextWriterStyle key] {
     get {
         if (_intTable == null)
         {
             return(null);
         }
         return((string)_intTable[(int)key]);
     }
     set {
         Add(key, value);
     }
 }
 public void Remove(HtmlTextWriterStyle key)
 {
     if (this._intTable != null)
     {
         this._intTable.Remove((int)key);
         if (this._state != null)
         {
             this._state["style"] = this.BuildString();
         }
         this._style = null;
     }
 }
Example #31
0
        /// <summary>
        /// Adds the given CSS style to the <see cref="HtmlControl"/>.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="control"></param>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static T AddCssStyle <T>(this T control, HtmlTextWriterStyle key, string value)
            where T : HtmlControl
        {
            if (control == null)
            {
                throw new ArgumentNullException(nameof(control));
            }

            control.Style.Add(key, value);

            return(control);
        }
        /// <summary>
        /// Appends the specified content.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="type">The type.</param>
        /// <param name="breakLine">if set to <c>true</c> [break line].</param>
        public void Append(String content, HtmlTextWriterStyle type, Boolean breakLine = false)
        {
            switch (type)
            {
            case HtmlTextWriterStyle.FontSize:
                _AppendLine(imbSciStringExtensions.ensureEndsWith(imbSciStringExtensions.add("font-size", ": ").a(content), ";"));
                break;

            default:
                _AppendLine(imbSciStringExtensions.ensureEndsWith(imbSciStringExtensions.add(type.ToString(), ": ").a(content), ";"));
                break;
            }
        }
Example #33
0
        public NamedCssStyleCollection RegisterStyle(HtmlTextWriterStyle key, string value, string styleName = null)
        {
            if (styleName == null)
            {
                styleName = String.Empty;
            }

            NamedCssStyleCollection style = GetStyle(styleName);

            style.Add(key, value);

            return(style);
        }
Example #34
0
        protected bool IsStyleAttributeDefined(HtmlTextWriterStyle key, out string value)
        {
            for (int i = 0; i <= styles_pos; i++)
            {
                if (styles [i].key == key)
                {
                    value = styles [i].value;
                    return(true);
                }
            }

            value = null;
            return(false);
        }
 public void Add(HtmlTextWriterStyle key, string value)
 {
     if (this._intTable == null)
     {
         this._intTable = new HybridDictionary();
     }
     this._intTable[(int) key] = value;
     string styleName = CssTextWriter.GetStyleName(key);
     if (styleName.Length != 0)
     {
         if (this._table == null)
         {
             this.ParseString();
         }
         this._table.Remove(styleName);
     }
     if (this._state != null)
     {
         this._state["style"] = this.BuildString();
     }
     this._style = null;
 }
Example #36
0
 public StyleAttribute(HtmlTextWriterStyle style, string value)
 {
     Value = value;
     StyleString = StyleToString(style);
 }
Example #37
0
 public string StyleToString(HtmlTextWriterStyle style)
 {
     return _stringStyleDictionary.First(x => x.Value.Equals(style)).Key;
 }
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        protected override bool OnStyleAttributeRender(string name,string value, HtmlTextWriterStyle key) {

            string s;
            if (Supports(FONT_AROUND_CONTENT)) {
                // tag supports downlevel fonts
                switch (key) {
                    case HtmlTextWriterStyle.FontFamily:
                        _fontFace = value;
                        _renderFontTag = true;
                        break;
                    case HtmlTextWriterStyle.Color:
                        _fontColor = value;
                        _renderFontTag = true;
                        break;
                    case HtmlTextWriterStyle.FontSize:
                        _fontSize = ConvertToHtmlFontSize(value);
                        if (_fontSize != null)
                            _renderFontTag = true;
                        break;
                    case HtmlTextWriterStyle.FontWeight:
                        if (StringUtil.EqualsIgnoreCase(value, "bold") && SupportsBold) {
                            AppendOtherTag("b");
                        }
                        break;
                    case HtmlTextWriterStyle.FontStyle:
                        if (!StringUtil.EqualsIgnoreCase(value, "normal") && SupportsItalic) {
                            AppendOtherTag("i");
                        }
                        break;
                    case HtmlTextWriterStyle.TextDecoration:
                        s = value.ToLower(CultureInfo.InvariantCulture);
                        if (s.IndexOf("underline", StringComparison.Ordinal) != -1) {
                            AppendOtherTag("u");
                        }
                        if (s.IndexOf("line-through", StringComparison.Ordinal) != -1) {
                            AppendOtherTag("strike");
                        }
                        break;
                }
            }
            else if (Supports(FONT_PROPAGATE)) {
                FontStackItem font = (FontStackItem)FontStack.Peek();

                switch (key) {
                    case HtmlTextWriterStyle.FontFamily:
                        font.name = value;
                        break;
                    case HtmlTextWriterStyle.Color:
                        font.color = value;
                        break;
                    case HtmlTextWriterStyle.FontSize:
                        font.size = ConvertToHtmlFontSize(value);
                        break;
                    case HtmlTextWriterStyle.FontWeight:
                        if (StringUtil.EqualsIgnoreCase(value, "bold")) {
                            font.bold = true;
                        }
                        break;
                    case HtmlTextWriterStyle.FontStyle:
                        if (!StringUtil.EqualsIgnoreCase(value, "normal")) {
                            font.italic = true;
                        }
                        break;
                    case HtmlTextWriterStyle.TextDecoration:
                        s = value.ToLower(CultureInfo.InvariantCulture);
                        if (s.IndexOf("underline", StringComparison.Ordinal) != -1) {
                            font.underline = true;
                        }
                        if (s.IndexOf("line-through", StringComparison.Ordinal) != -1) {
                            font.strikeout = true;
                        }
                        break;
                }
            }

            if (Supports(SUPPORTS_BORDER) && key == HtmlTextWriterStyle.BorderWidth) {
                s = ConvertToHtmlSize(value);
                if (s != null)
                    AddAttribute(HtmlTextWriterAttribute.Border,s);
            }

            if (Supports(SUPPORTS_NOWRAP) && key == HtmlTextWriterStyle.WhiteSpace) {
                AddAttribute(HtmlTextWriterAttribute.Nowrap, value);
            }

            if (Supports(SUPPORTS_HEIGHT_WIDTH)) {
                switch (key) {
                    case HtmlTextWriterStyle.Height :
                        s = ConvertToHtmlSize(value);
                        if (s != null)
                            AddAttribute(HtmlTextWriterAttribute.Height,s);
                        break;
                    case HtmlTextWriterStyle.Width :
                        s = ConvertToHtmlSize(value);
                        if (s != null)
                            AddAttribute(HtmlTextWriterAttribute.Width,s);
                        break;
                }
            }

            if (Supports(TABLE_ATTRIBUTES) || Supports(TABLE_AROUND_CONTENT)) {
                // tag supports downlevel table attributes
                switch (key) {
                    case HtmlTextWriterStyle.BorderColor:
                        switch (TagKey) {
                            case HtmlTextWriterTag.Div:
                                if (ShouldPerformDivTableSubstitution) {
                                    AddAttribute(HtmlTextWriterAttribute.Bordercolor, value);
                                }
                                break;
                        }
                        break;
                    case HtmlTextWriterStyle.BackgroundColor :
                        switch (TagKey) {
                            case HtmlTextWriterTag.Table :
                            case HtmlTextWriterTag.Tr :
                            case HtmlTextWriterTag.Td :
                            case HtmlTextWriterTag.Th :
                            case HtmlTextWriterTag.Body :
                                AddAttribute(HtmlTextWriterAttribute.Bgcolor,value);
                                break;
                                // div->table substitution.
                            case HtmlTextWriterTag.Div:
                                if (ShouldPerformDivTableSubstitution) {
                                    AddAttribute(HtmlTextWriterAttribute.Bgcolor,value);
                                }
                                break;
                        }
                        break;
                    case HtmlTextWriterStyle.BackgroundImage :
                        switch (TagKey) {
                            case HtmlTextWriterTag.Table :
                            case HtmlTextWriterTag.Td :
                            case HtmlTextWriterTag.Th :
                            case HtmlTextWriterTag.Body :
                                // strip url(...) from value
                                if (StringUtil.StringStartsWith(value, "url("))
                                    value = value.Substring(4,value.Length-5);
                                AddAttribute(HtmlTextWriterAttribute.Background,value);
                                break;
                                // div->table substitution.
                            case HtmlTextWriterTag.Div:
                                if (ShouldPerformDivTableSubstitution) {
                                    if (StringUtil.StringStartsWith(value, "url("))
                                        value = value.Substring(4,value.Length-5);
                                    AddAttribute(HtmlTextWriterAttribute.Background,value);
                                }
                                break;
                        }
                        break;
                }
            }

            switch (key) {
                case HtmlTextWriterStyle.ListStyleType:
                    switch (value) {
                        case "decimal":
                            AddAttribute(HtmlTextWriterAttribute.Type, "1");
                            break;
                        case "lower-alpha":
                            AddAttribute(HtmlTextWriterAttribute.Type, "a");
                            break;
                        case "upper-alpha":
                            AddAttribute(HtmlTextWriterAttribute.Type, "A");
                            break;
                        case "lower-roman":
                            AddAttribute(HtmlTextWriterAttribute.Type, "i");
                            break;
                        case "upper-roman":
                            AddAttribute(HtmlTextWriterAttribute.Type, "I");
                            break;
                        case "disc":
                        case "circle":
                        case "square":
                            AddAttribute(HtmlTextWriterAttribute.Type, value);
                            break;
                        default:
                            AddAttribute(HtmlTextWriterAttribute.Type, "disc");
                            Debug.Assert(false, "Invalid BulletStyle for HTML32.");
                            break;
                    }
                    break;
                case HtmlTextWriterStyle.TextAlign:
                    AddAttribute(HtmlTextWriterAttribute.Align, value);
                    break;
                case HtmlTextWriterStyle.VerticalAlign:
                    AddAttribute(HtmlTextWriterAttribute.Valign, value);
                    break;
                // Netscape 4.72 can properly handle the Display style attribute, so allow it
                // to be rendered.
                case HtmlTextWriterStyle.Display:
                    return true;
            }

            return false;
        }
 public void Add (HtmlTextWriterStyle key, string value)
 {
 }
 /// <devdoc>
 /// Render out the specified style attribute and value.
 /// </devdoc>
 public void WriteAttribute(HtmlTextWriterStyle key, string value) {
     WriteAttribute(_writer, key, GetStyleName(key), value);
 }
 public HtmlAttributeManager Style(HtmlTextWriterStyle key, string value)
 {
     Writer.AddStyleAttribute(key, value);
     return this;
 }
 protected string GetStyleName(HtmlTextWriterStyle styleKey) {
     return CssTextWriter.GetStyleName(styleKey);
 }
 /// <internalonly/>
 /// <devdoc>
 /// Registers the specified style attribute to create a mapping between a string representation
 /// and the corresponding HtmlTextWriterStyle value.
 /// </devdoc>
 internal static void RegisterAttribute(string name, HtmlTextWriterStyle key, bool encode) {
     RegisterAttribute(name, key, encode, false);
 }
 public virtual void AddStyleAttribute(HtmlTextWriterStyle key, string value) {
     AddStyleAttribute(CssTextWriter.GetStyleName(key), value, key);
 }
        protected virtual void AddStyleAttribute(string name, string value, HtmlTextWriterStyle key) {
            if(_styleList == null) {
                _styleList = new RenderStyle[20];
            }
            else if (_styleCount > _styleList.Length) {
                RenderStyle[] newArray = new RenderStyle[_styleList.Length * 2];
                Array.Copy(_styleList, newArray, _styleList.Length);
                _styleList = newArray;
            }

            RenderStyle style;

            style.name = name;
            style.key = key;

            string attributeValue = value;
            if (CssTextWriter.IsStyleEncoded(key)) {
                // note that only css attributes in an inline style value need to be attribute encoded
                // since CssTextWriter is used to render both embedded stylesheets and style attributes
                // the attribute encoding is done here.
                attributeValue = HttpUtility.HtmlAttributeEncode(value);
            }
            style.value = attributeValue;

            _styleList[_styleCount] = style;
            _styleCount++;
        }
 protected static void RegisterStyle(string name, HtmlTextWriterStyle key) {
     CssTextWriter.RegisterAttribute(name, key);
 }
 public string this [HtmlTextWriterStyle key]
 {
   get
   {
     return default(string);
   }
   set
   {
   }
 }
 public void Remove (HtmlTextWriterStyle key)
 {
 }
        /// <devdoc>
        /// Returns the name of the attribute corresponding to the specified HtmlTextWriterStyle value.
        /// </devdoc>
        public static string GetStyleName(HtmlTextWriterStyle styleKey) {
            if ((int)styleKey >= 0 && (int)styleKey < attrNameLookupArray.Length) {
                return attrNameLookupArray[(int)styleKey].name;
            }

            return String.Empty;
        }
 protected bool IsStyleAttributeDefined(HtmlTextWriterStyle key) {
     for (int i = 0; i < _styleCount; i++) {
         if (_styleList[i].key == key) {
             return true;
         }
     }
     return false;
 }
        /// <devdoc>
        /// Does the specified style key require attribute value encoding if the value is being
        /// rendered in a style attribute.
        /// </devdoc>
        public static bool IsStyleEncoded(HtmlTextWriterStyle styleKey) {
            if ((int)styleKey >= 0 && (int)styleKey < attrNameLookupArray.Length) {
                return attrNameLookupArray[(int)styleKey].encode;
            }

            return true;
        }
 protected bool IsStyleAttributeDefined(HtmlTextWriterStyle key, out string value) {
     value = null;
     for (int i = 0; i < _styleCount; i++) {
         if (_styleList[i].key == key) {
             value = _styleList[i].value;
             return true;
         }
     }
     return false;
 }
 /// <internalonly/>
 /// <devdoc>
 /// Registers the specified style attribute to create a mapping between a string representation
 /// and the corresponding HtmlTextWriterStyle value.
 /// In addition, the mapping can include additional information about the attribute type
 /// such as whether it is a URL.
 /// </devdoc>
 internal static void RegisterAttribute(string name, HtmlTextWriterStyle key, bool encode, bool isUrl) {
     string nameLCase = name.ToLower(CultureInfo.InvariantCulture);
     
     attrKeyLookupTable.Add(nameLCase, key);
     if ((int)key < attrNameLookupArray.Length) {
         attrNameLookupArray[(int)key] = new AttributeInformation(name, encode, isUrl);
     }
 }
 protected virtual bool OnStyleAttributeRender(string name, string value, HtmlTextWriterStyle key) {
     return true;
 }
        /// <devdoc>
        /// Render the specified style attribute into the specified TextWriter.
        /// This method contains all the logic for rendering a CSS name/value pair.
        /// </devdoc>
        private static void WriteAttribute(TextWriter writer, HtmlTextWriterStyle key, string name, string value) {
            writer.Write(name);
            writer.Write(':');

            bool isUrl = false;
            if (key != (HtmlTextWriterStyle)(-1)) {
                isUrl = attrNameLookupArray[(int)key].isUrl;
            }

            if (isUrl == false) {
                writer.Write(value);
            }
            else {
                WriteUrlAttribute(writer, value);
            }

            writer.Write(';');
        }
        public void Remove(HtmlTextWriterStyle key) {
            if (_intTable == null) {
                return;
            }
            _intTable.Remove((int)key);

            if (_state != null) {
                // keep style attribute synchronized
                _state["style"] = BuildString();
            }
            _style = null;
        }
 public StyleBlockStyles AddStyle(HtmlTextWriterStyle styleName, string value)
 {
     this._styles.Add(styleName, value);
     return this;
 }
        public void Add(HtmlTextWriterStyle key, string value) {
            if (_intTable == null) {
                _intTable = new HybridDictionary();
            }
            _intTable[(int)key] = value;

            string name = CssTextWriter.GetStyleName(key);
            if (name.Length != 0) {
                // Remove from the other table to avoid duplicates.
                if (_table == null)
                    ParseString();

                _table.Remove(name);
            }

            if (_state != null) {
                // keep style attribute synchronized
                _state["style"] = BuildString();
            }
            _style = null;
        }
		protected override bool OnStyleAttributeRender (string name, string value, HtmlTextWriterStyle key)
		{
                        return base.OnStyleAttributeRender (name, value, key);
		}
 /// <devdoc>
 /// Gets or sets the specified known CSS value.
 /// </devdoc>
 public string this[HtmlTextWriterStyle key] {
     get {
         if (_intTable == null) {
             return null;
         }
         return (string)_intTable[(int)key];
     }
     set {
         Add(key, value);
     }
 }