Example #1
0
        public void Add(string aClass)
        {
            CssClass c = new CssClass(aClass);

            foreach (string cls in c.iList)
            {
                if (!iList.Contains(cls))
                {
                    iList.Add(cls);
                }
            }
        }
Example #2
0
        private void RenderControls(XmlDocument aDoc, string aType)
        {
            Component[] comps = iPageDef.GetComponents(aType);

            foreach (Component comp in comps)
            {
                // find the XML node for this component
                XmlNode compNode = aDoc.SelectSingleNode("//*[@id='" + comp.Id + "']");
                if (compNode == null)
                {
                    continue;
                }

                // get the current style attribute
                XmlNode styleNode = compNode.Attributes.GetNamedItem("style");

                CssStyle style = new CssStyle((styleNode != null) ? styleNode.Value : string.Empty);

                // set some style values
                if (!string.IsNullOrEmpty(comp.BackgroundImage))
                {
                    style.Set("background-image", "url(Resources/" + comp.BackgroundImage + ")");
                }
                if (!string.IsNullOrEmpty(comp.Top))
                {
                    style.Set("top", comp.Top);
                }
                if (!string.IsNullOrEmpty(comp.Left))
                {
                    style.Set("left", comp.Left);
                }

                // set the style attribute of the node
                string styleValue = style.ToString();
                if (!string.IsNullOrEmpty(styleValue))
                {
                    if (styleNode == null)
                    {
                        XmlAttribute styleAttr = aDoc.CreateAttribute("style");
                        compNode.Attributes.Append(styleAttr);
                        styleNode = styleAttr;
                    }

                    styleNode.Value = styleValue;
                }


                // get the current class attribute
                XmlNode classNode = compNode.Attributes.GetNamedItem("class");

                CssClass cls = new CssClass((classNode != null) ? classNode.Value : string.Empty);

                if (!string.IsNullOrEmpty(comp.Class))
                {
                    cls.Add(comp.Class);
                }

                // set the class attribute of the node
                string classValue = cls.ToString();
                if (!string.IsNullOrEmpty(classValue))
                {
                    if (classNode == null)
                    {
                        XmlAttribute classAttr = aDoc.CreateAttribute("class");
                        compNode.Attributes.Append(classAttr);
                        classNode = classAttr;
                    }

                    classNode.Value = classValue;
                }
            }
        }