Beispiel #1
0
            protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
            {
                base.FillStyleAttributes(attributes, urlResolver);

                attributes.Remove(HtmlTextWriterStyle.BackgroundColor);
                attributes.Remove(HtmlTextWriterStyle.Width);
            }
Beispiel #2
0
        public void InitialBag1()
        {
            StateBag bag = new StateBag(true);
            AC       ac  = new AC(bag);

            Assert.AreEqual(0, ac.Count, "count");
            Assert.AreEqual(null, ac ["hola"], "item");
            Assert.AreEqual(0, ac.Keys.Count, "keys");
            ac.Add("notexists", "invalid");
            ac.Remove("notexists");
            ac.Remove("notexists");

            HtmlTextWriter writer = new HtmlTextWriter(new StringWriter());

            ac.AddAttributes(writer);
            ac.Render(writer);
            Assert.AreEqual(0, writer.InnerWriter.ToString().Length, "length");
            CssStyleCollection css = ac.CssStyle;

            Assert.AreEqual(0, css.Count, "csscount");
            Assert.AreEqual(null, css ["hola"], "cssitem");
            Assert.AreEqual(0, css.Keys.Count, "csskeys");
            css.Add("notexists", "invalid");
            css.Remove("notexists");
            css.Remove("notexists");
            css.Add("notexists", "invalid");
            css.Clear();
            Assert.AreEqual(0, css.Keys.Count, "csskeys2");
        }
            /// <summary>
            /// Fills Style attribute to the base.
            /// </summary>
            /// <param name="attributes"></param>
            /// <param name="urlResolver"></param>
            protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
            {
                base.FillStyleAttributes(attributes, urlResolver);

                attributes.Remove(HtmlTextWriterStyle.Height);
                // commented below line to fix the issue #25821
                //attributes.Remove(HtmlTextWriterStyle.BackgroundColor);
                attributes.Remove(HtmlTextWriterStyle.BackgroundImage);
            }
Beispiel #4
0
 public void Deny_Unrestricted()
 {
     Assert.AreEqual(0, css.Count, "Count");
     css ["mono"] = "monkey";
     Assert.AreEqual("monkey", css["mono"], "this[string]");
     Assert.IsNotNull(css.Keys, "Keys");
     css.Add("monkey", "mono");
     css.Remove("monkey");
     css.Clear();
     css[HtmlTextWriterStyle.Top] = "1";
     Assert.AreEqual("1", css[HtmlTextWriterStyle.Top], "this[HtmlTextWriterStyle]");
     Assert.IsNotNull(css.Value, "Value");
     css.Value = String.Empty;
     css.Add(HtmlTextWriterStyle.Left, "1");
     css.Remove(HtmlTextWriterStyle.Left);
 }
Beispiel #5
0
    public static void Visibility(this CssStyleCollection style, bool visibility)
    {
        style.Remove("visibility");

        if (visibility)
        {
            style.Add("visibility", "visible");
        }
        else
        {
            style.Add("visibility", "hidden");
        }
    }
Beispiel #6
0
    public static void Apply(this CssStyleCollection style, PrintSetting setting)
    {
        if (setting == null)
        {
            return;
        }

        if (string.IsNullOrEmpty(setting.Top))
        {
            style.Remove("top");
        }
        else
        {
            style.Add("top", setting.Top);
        }

        if (string.IsNullOrEmpty(setting.Left))
        {
            style.Remove("left");
        }
        else
        {
            style.Add("left", setting.Left);
        }

        if (string.IsNullOrEmpty(setting.Font))
        {
            style.Remove("font");
        }
        else
        {
            style.Add("font", setting.Font);
        }

        if (string.IsNullOrEmpty(setting.Size))
        {
            style.Remove("font-size");
        }
        else
        {
            style.Add("font-size", setting.Size);
        }

        if (string.IsNullOrEmpty(setting.Width))
        {
            style.Remove("width");
        }
        else
        {
            style.Add("width", setting.Width);
        }

        if (string.IsNullOrEmpty(setting.Height))
        {
            style.Remove("height");
        }
        else
        {
            style.Add("height", setting.Height);
        }
    }