コード例 #1
0
            void IStyleSheet.CreateStyleRule(Style style, IUrlResolutionService urlResolver, string selector)
            {
                if (style == null)
                {
                    throw new ArgumentNullException("style");
                }
                if (selector.Length == 0)
                {
                    throw new ArgumentNullException("selector");
                }
                if (this._selectorStyles == null)
                {
                    this._selectorStyles = new ArrayList();
                }
                if (urlResolver == null)
                {
                    urlResolver = this;
                }
                SelectorStyleInfo info = new SelectorStyleInfo {
                    selector    = selector,
                    style       = style,
                    urlResolver = urlResolver
                };

                this._selectorStyles.Add(info);
                Page page = this._owner.Page;

                if (page.PartialCachingControlStack != null)
                {
                    foreach (BasePartialCachingControl control in page.PartialCachingControlStack)
                    {
                        control.RegisterStyleInfo(info);
                    }
                }
            }
コード例 #2
0
 public void Render(HtmlTextWriter writer)
 {
     if (((this._styles != null) || (this._selectorStyles != null)) || (this.CSSStyleString != null))
     {
         writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/css");
         writer.RenderBeginTag(HtmlTextWriterTag.Style);
         CssTextWriter cssWriter = new CssTextWriter(writer);
         if (this._styles != null)
         {
             for (int i = 0; i < this._styles.Count; i++)
             {
                 StyleInfo info = (StyleInfo)this._styles[i];
                 string    registeredCssClass = info.style.RegisteredCssClass;
                 if (registeredCssClass.Length != 0)
                 {
                     HtmlHead.RenderCssRule(cssWriter, "." + registeredCssClass, info.style, info.urlResolver);
                 }
             }
         }
         if (this._selectorStyles != null)
         {
             for (int j = 0; j < this._selectorStyles.Count; j++)
             {
                 SelectorStyleInfo info2 = (SelectorStyleInfo)this._selectorStyles[j];
                 HtmlHead.RenderCssRule(cssWriter, info2.selector, info2.style, info2.urlResolver);
             }
         }
         if (this.CSSStyleString != null)
         {
             writer.Write(this.CSSStyleString);
         }
         writer.RenderEndTag();
     }
 }
コード例 #3
0
            public void Render(HtmlTextWriter writer)
            {
                if ((_styles == null) && (_selectorStyles == null) && CSSStyleString == null)
                {
                    return;
                }

                writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/css");
                writer.RenderBeginTag(HtmlTextWriterTag.Style);

                CssTextWriter cssWriter = new CssTextWriter(writer);

                if (_styles != null)
                {
                    for (int i = 0; i < _styles.Count; i++)
                    {
                        StyleInfo si = (StyleInfo)_styles[i];

                        string cssClass = si.style.RegisteredCssClass;
                        if (cssClass.Length != 0)
                        {
                            RenderCssRule(cssWriter, "." + cssClass, si.style, si.urlResolver);
                        }
                    }
                }

                if (_selectorStyles != null)
                {
                    for (int i = 0; i < _selectorStyles.Count; i++)
                    {
                        SelectorStyleInfo si = (SelectorStyleInfo)_selectorStyles[i];
                        RenderCssRule(cssWriter, si.selector, si.style, si.urlResolver);
                    }
                }

                if (CSSStyleString != null)
                {
                    writer.Write(CSSStyleString);
                }

                writer.RenderEndTag();
            }
コード例 #4
0
            void IStyleSheet.CreateStyleRule(Style style, IUrlResolutionService urlResolver, string selector)
            {
                if (style == null)
                {
                    throw new ArgumentNullException("style");
                }

                if (selector.Length == 0)
                {
                    throw new ArgumentNullException("selector");
                }

                if (_selectorStyles == null)
                {
                    _selectorStyles = new ArrayList();
                }

                if (urlResolver == null)
                {
                    urlResolver = this;
                }

                SelectorStyleInfo styleInfo = new SelectorStyleInfo();

                styleInfo.selector    = selector;
                styleInfo.style       = style;
                styleInfo.urlResolver = urlResolver;

                _selectorStyles.Add(styleInfo);

                Page page = _owner.Page;

                // If there are any partial caching controls on the stack, forward the styleInfo to them
                if (page.PartialCachingControlStack != null)
                {
                    foreach (BasePartialCachingControl c in page.PartialCachingControlStack)
                    {
                        c.RegisterStyleInfo(styleInfo);
                    }
                }
            }
コード例 #5
0
    internal void RegisterStyleInfo(SelectorStyleInfo selectorInfo) {
        if (_registeredStyleInfo == null) {
            _registeredStyleInfo = new ArrayList();
        }

        _registeredStyleInfo.Add(selectorInfo);
    }
コード例 #6
0
            void IStyleSheet.CreateStyleRule(Style style, IUrlResolutionService urlResolver, string selector) {
                if (style == null) {
                    throw new ArgumentNullException("style");
                }

                if (selector.Length == 0) {
                    throw new ArgumentNullException("selector");
                }

                if (_selectorStyles == null) {
                    _selectorStyles = new ArrayList();
                }

                if (urlResolver == null) {
                    urlResolver = this;
                }

                SelectorStyleInfo styleInfo = new SelectorStyleInfo();
                styleInfo.selector = selector;
                styleInfo.style = style;
                styleInfo.urlResolver = urlResolver;

                _selectorStyles.Add(styleInfo);

                Page page = _owner.Page;

                // If there are any partial caching controls on the stack, forward the styleInfo to them
                if (page.PartialCachingControlStack != null) {
                    foreach (BasePartialCachingControl c in page.PartialCachingControlStack) {
                        c.RegisterStyleInfo(styleInfo);
                    }
                }
            }
コード例 #7
0
 void IStyleSheet.CreateStyleRule(Style style, IUrlResolutionService urlResolver, string selector)
 {
     if (style == null)
     {
         throw new ArgumentNullException("style");
     }
     if (selector.Length == 0)
     {
         throw new ArgumentNullException("selector");
     }
     if (this._selectorStyles == null)
     {
         this._selectorStyles = new ArrayList();
     }
     if (urlResolver == null)
     {
         urlResolver = this;
     }
     SelectorStyleInfo info = new SelectorStyleInfo {
         selector = selector,
         style = style,
         urlResolver = urlResolver
     };
     this._selectorStyles.Add(info);
     Page page = this._owner.Page;
     if (page.PartialCachingControlStack != null)
     {
         foreach (BasePartialCachingControl control in page.PartialCachingControlStack)
         {
             control.RegisterStyleInfo(info);
         }
     }
 }