Exemplo n.º 1
0
 /// <summary>
 /// 创建 Css21StyleSpecification 对象
 /// </summary>
 public Css21StyleSpecification()
 {
     StyleShorthandRules.Add(new StandardBoxShorthandRule("padding"));
     StyleShorthandRules.Add(new StandardBoxShorthandRule("margin"));
     StyleShorthandRules.Add(new StandardBoxShorthandRule("border-width"));
     StyleShorthandRules.Add(new StandardBoxShorthandRule("border-style"));
     StyleShorthandRules.Add(new StandardBoxShorthandRule("border-color"));
 }
Exemplo n.º 2
0
        /// <summary>
        /// 获取缩写形式的样式属性
        /// </summary>
        /// <param name="name">样式属性名</param>
        /// <param name="style">所有的样式设置</param>
        /// <returns>返回缩写形式,如果可能</returns>
        public CssStyleProperty TryGetShorthandProperty(string name, CssStyle style)
        {
            if (StyleShorthandRules.Contains(name))
            {
                var rule = StyleShorthandRules[name];
                return(rule.TryGetShorthandProperty(style));
            }

            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 展开 CSS 样式属性的缩写形式
        /// </summary>
        /// <param name="property">样式属性设置</param>
        /// <returns>展开后的形式,若该设置不是缩写形式,则原样返回</returns>
        protected virtual IEnumerable <CssStyleProperty> ExtractShorthand(CssStyleProperty property)
        {
            lock ( SyncRoot )
            {
                if (StyleShorthandRules.Contains(property.Name))
                {
                    return(StyleShorthandRules[property.Name].ExtractProperties(property.Value));
                }

                else
                {
                    return new[] { property }
                };
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 检查指定的样式属性是否为一个缩写形式
 /// </summary>
 /// <param name="name">指定的属性名</param>
 /// <returns>是否为缩写形式</returns>
 public bool IsShorthandStyle(string name)
 {
     return(StyleShorthandRules.Contains(name));
 }