Beispiel #1
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");
        }
Beispiel #2
0
            protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
            {
                base.FillStyleAttributes(attributes, urlResolver);

                attributes.Add("background-color", "transparent");
                attributes.Add("cursor", "text");
            }
Beispiel #3
0
 protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
 {
     base.FillStyleAttributes(attributes, urlResolver);
     // here are the additional CSS styles
     attributes.Add("float", "right");     // move it to the right in the toolbar
     attributes.Add("margin-left", "2px"); // ensure some left padding
 }
Beispiel #4
0
 protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
 {
     _popup._savedCSS = attributes.Value;
     attributes.Add(HtmlTextWriterStyle.Position, "absolute");
     attributes.Add(HtmlTextWriterStyle.Top, "-2000px");
     attributes.Add(HtmlTextWriterStyle.Left, "-2000px");
 }
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");
        }
    }
 protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
 {
     base.FillStyleAttributes(attributes, urlResolver);
     if (CheckBit((int)TreeNodeStyles.HorizontalPadding))
     {
         attributes.Add(HtmlTextWriterStyle.PaddingLeft, HorizontalPadding.ToString());
         attributes.Add(HtmlTextWriterStyle.PaddingRight, HorizontalPadding.ToString());
     }
     if (CheckBit((int)TreeNodeStyles.VerticalPadding))
     {
         attributes.Add(HtmlTextWriterStyle.PaddingTop, VerticalPadding.ToString());
         attributes.Add(HtmlTextWriterStyle.PaddingBottom, VerticalPadding.ToString());
     }
 }
Beispiel #7
0
 protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
 {
     base.FillStyleAttributes(attributes, urlResolver);
     if (IsSet(HORZ_PADD))
     {
         attributes.Add(HtmlTextWriterStyle.PaddingLeft, HorizontalPadding.ToString());
         attributes.Add(HtmlTextWriterStyle.PaddingRight, HorizontalPadding.ToString());
     }
     if (IsSet(VERT_PADD))
     {
         attributes.Add(HtmlTextWriterStyle.PaddingTop, VerticalPadding.ToString());
         attributes.Add(HtmlTextWriterStyle.PaddingBottom, VerticalPadding.ToString());
     }
 }
Beispiel #8
0
 private void AssureStyleKey(CssStyleCollection InStyle, string InKey, string InValue)
 {
     if (InStyle[InKey] == null)
     {
         InStyle.Add(InKey, InValue);
     }
 }
Beispiel #9
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);
 }
 public static void AddExisting(this CssStyleCollection collection,
                                CssStyleCollection existing)
 {
     foreach (string item in existing.Keys)
     {
         collection.Add(item, existing[item]);
     }
 }
Beispiel #11
0
    protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
    {
        base.FillStyleAttributes(attributes, urlResolver);

        if (!this.MinHeight.IsEmpty)
        {
            attributes.Add("min-height", this.MinHeight.ToString());
        }
    }
 protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
 {
     //.IE8fix
     //{
     //     z-index: 100;
     //}
     base.FillStyleAttributes(attributes, urlResolver);
     attributes.Add(HtmlTextWriterStyle.ZIndex, "100");
 }
Beispiel #13
0
        /// <summary>
        /// 将dictionary反序列化转换成特定类型的对象
        /// </summary>
        /// <param name="dictionary">要反序列化的数据</param>
        /// <param name="type">要反序列化的类型</param>
        /// <param name="serializer">JavaScriptSerializer对象</param>
        /// <returns>反序列化出的对象</returns>
        /// <remarks>将dictionary反序列化转换成特定类型的对象</remarks>
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, System.Web.Script.Serialization.JavaScriptSerializer serializer)
        {
            CssStyleCollection styles = (new AttributeCollection(null)).CssStyle;

            foreach (KeyValuePair <string, object> item in dictionary)
            {
                styles.Add(CastKey(item.Key), (string)item.Value);
            }

            return(styles);
        }
Beispiel #14
0
        protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
        {
            base.FillStyleAttributes(attributes, urlResolver);
            Color shadowColor = this.ShadowColor;

            if (!shadowColor.IsEmpty)
            {
                string str  = ColorTranslator.ToHtml(shadowColor);
                string str2 = "progid:DXImageTransform.Microsoft.Shadow(color='" + str + "', Direction=135, Strength=3)";
                attributes.Add(HtmlTextWriterStyle.Filter, str2);
            }
        }
        public void CssStyleCollection_BackgroundImage()
        {
            WebControl         c           = new WebControl(HtmlTextWriterTag.A);
            CssStyleCollection css         = c.Style;
            string             url         = "http://www.go-mono.com/space here?key1=val1&key2=val2";
            string             url_encoded = "http://www.go-mono.com/space%20here?key1=val1&key2=val2";

            css.Add(HtmlTextWriterStyle.BackgroundImage, url);

            Assert.AreEqual(url, css ["background-image"], "CssStyleCollection_BackgroundImage#1");
            Assert.AreEqual("background-image:url(" + url_encoded + ");", css.Value, "CssStyleCollection_BackgroundImage#3");
            Assert.AreEqual("background-image:url(" + url_encoded + ");", c.Attributes["style"], "CssStyleCollection_BackgroundImage#4");
        }
Beispiel #16
0
        protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
        {
            base.FillStyleAttributes(attributes, urlResolver);

            if (PaddingTop != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingTop, PaddingTop.ToString());
            }
            if (PaddingLeft != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingLeft, PaddingLeft.ToString());
            }
            if (PaddingRight != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingRight, PaddingRight.ToString());
            }
            if (PaddingBottom != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingBottom, PaddingBottom.ToString());
            }

            if (MarginTop != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginTop, MarginTop.ToString());
            }
            if (MarginLeft != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginLeft, MarginLeft.ToString());
            }
            if (MarginRight != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginRight, MarginRight.ToString());
            }
            if (MarginBottom != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginBottom, MarginBottom.ToString());
            }

            if (!String.IsNullOrEmpty(BackImageUrl))
            {
                attributes.Add(HtmlTextWriterStyle.BackgroundImage, String.Format("url({0})", urlResolver.ResolveClientUrl(BackImageUrl)));
            }
        }
Beispiel #17
0
 /// <summary>
 /// Merges this collection into a CssStyleCollection.
 /// </summary>
 /// <param name="dest">The destination collection.</param>
 /// <param name="overwrite">If true, will overwrite attributes of the same name.</param>
 public void MergeInto(CssStyleCollection dest, bool overwrite)
 {
     foreach (string name in this)
     {
         if (dest[name] == null)
         {
             dest.Add(name, this[name]);
         }
         else if (overwrite)
         {
             dest[name] = this[name];
         }
     }
 }
        protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
        {
            base.FillStyleAttributes(attributes, urlResolver);
            string backImageUrl = this.BackImageUrl;

            if (backImageUrl.Length != 0)
            {
                if (urlResolver != null)
                {
                    backImageUrl = urlResolver.ResolveClientUrl(backImageUrl);
                }
                attributes.Add(HtmlTextWriterStyle.BackgroundImage, backImageUrl);
            }
        }
        public NamedCssStyleCollection CopyFrom(CssStyleCollection coll)
        {
            if (coll == null)
            {
                return(this);
            }

            CssStyleCollection collection = Collection;

            foreach (string key in coll.Keys)
            {
                collection.Add(key, coll [key]);
            }

            return(this);
        }
Beispiel #20
0
 protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
 {
     if (BackColor.IsEmpty && ((_owner == null) || _owner.BackColor.IsEmpty))
     {
         attributes.Add(HtmlTextWriterStyle.BackgroundColor, "white");
     }
     attributes.Add(HtmlTextWriterStyle.Visibility, "hidden");
     attributes.Add(HtmlTextWriterStyle.Display, "none");
     attributes.Add(HtmlTextWriterStyle.Position, "absolute");
     attributes.Add(HtmlTextWriterStyle.Left, "0px");
     attributes.Add(HtmlTextWriterStyle.Top, "0px");
     base.FillStyleAttributes(attributes, urlResolver);
 }
Beispiel #21
0
        protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
        {
            base.FillStyleAttributes(attributes, urlResolver);

            if (PaddingTop != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingTop, PaddingTop.ToString());
            }
            if (PaddingLeft != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingLeft, PaddingLeft.ToString());
            }
            if (PaddingRight != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingRight, PaddingRight.ToString());
            }
            if (PaddingBottom != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingBottom, PaddingBottom.ToString());
            }

            if (MarginTop != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginTop, MarginTop.ToString());
            }
            if (MarginLeft != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginLeft, MarginLeft.ToString());
            }
            if (MarginRight != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginRight, MarginRight.ToString());
            }
            if (MarginBottom != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginBottom, MarginBottom.ToString());
            }
        }
		internal void FillStyleAttributes (CssStyleCollection attributes, bool alwaysRenderTextDecoration) {
			if (IsEmpty) {
				if(alwaysRenderTextDecoration)
					attributes.Add (HtmlTextWriterStyle.TextDecoration, "none");
				return;
			}

			string s;
			// Fonts are a bit weird
			s = String.Join (",", Names);
			if (s.Length > 0) {
				attributes.Add (HtmlTextWriterStyle.FontFamily, s);
			}

			if (_owner.CheckBit ((int) Style.Styles.FontBold)) {
				attributes.Add (HtmlTextWriterStyle.FontWeight, Bold ? "bold" : "normal");
			}

			if (_owner.CheckBit ((int) Style.Styles.FontItalic)) {
				attributes.Add (HtmlTextWriterStyle.FontStyle, Italic ? "italic" : "normal");
			}

			if (!Size.IsEmpty) {
				attributes.Add (HtmlTextWriterStyle.FontSize, Size.ToString ());
			}

			// These styles are munged into a attribute decoration
			s = string.Empty;
			bool hasTextDecoration = false;

			if (_owner.CheckBit ((int) Style.Styles.FontOverline)) {
				if (Overline)
					s += "overline ";
				hasTextDecoration = true;
			}

			if (_owner.CheckBit ((int) Style.Styles.FontStrikeout)) {
				if (Strikeout)
					s += "line-through ";
				hasTextDecoration = true;
			}

			if (_owner.CheckBit ((int) Style.Styles.FontUnderline)) {
				if (Underline)
					s += "underline ";
				hasTextDecoration = true;
			}

			s = (s.Length > 0) ? s.Trim () : (alwaysRenderTextDecoration || hasTextDecoration) ? "none" : "";
			if (s.Length > 0)
				attributes.Add (HtmlTextWriterStyle.TextDecoration, s);
		}
Beispiel #23
0
            protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
            {
                base.FillStyleAttributes(attributes, urlResolver);

                attributes.Add("width", "11px");
            }
Beispiel #24
0
		protected virtual void FillStyleAttributes (CssStyleCollection attributes, IUrlResolutionService urlResolver)
		{
			Color		color;
			BorderStyle	bs;
			Unit		u;

			if (CheckBit ((int) Styles.BackColor))
			{
				color = (Color)viewstate["BackColor"];
				if (!color.IsEmpty)
					attributes.Add (HtmlTextWriterStyle.BackgroundColor, ColorTranslator.ToHtml(color));
			}

			if (CheckBit ((int) Styles.BorderColor)) 
			{
				color = (Color)viewstate["BorderColor"];
				if (!color.IsEmpty)
					attributes.Add (HtmlTextWriterStyle.BorderColor, ColorTranslator.ToHtml(color));
			}

			bool have_width = false;
			if (CheckBit ((int) Styles.BorderWidth)) {
				u = (Unit) viewstate ["BorderWidth"];
				if (!u.IsEmpty) {
					if (u.Value > 0)
						have_width = true;
					attributes.Add (HtmlTextWriterStyle.BorderWidth, u.ToString ());
				}
			}

			if (CheckBit ((int) Styles.BorderStyle)) {
				bs = (BorderStyle) viewstate ["BorderStyle"];
				if (bs != BorderStyle.NotSet)
					attributes.Add (HtmlTextWriterStyle.BorderStyle, bs.ToString ());
				else if (have_width)
						attributes.Add (HtmlTextWriterStyle.BorderStyle, "solid");
			}
			else if (have_width) {
				attributes.Add (HtmlTextWriterStyle.BorderStyle, "solid");
			}

			if (CheckBit ((int) Styles.ForeColor)) 
			{
				color = (Color)viewstate["ForeColor"];
				if (!color.IsEmpty)
					attributes.Add (HtmlTextWriterStyle.Color, ColorTranslator.ToHtml(color));
			}

			if (CheckBit ((int) Styles.Height)) 
			{
				u = (Unit)viewstate["Height"];
				if (!u.IsEmpty)
					attributes.Add (HtmlTextWriterStyle.Height, u.ToString());
			}

			if (CheckBit ((int) Styles.Width)) 
			{
				u = (Unit)viewstate["Width"];
				if (!u.IsEmpty)
					attributes.Add (HtmlTextWriterStyle.Width, u.ToString());
			}

			Font.FillStyleAttributes (attributes, AlwaysRenderTextDecoration);
		}
        protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
        {
            Color    color;
            Unit     unit2;
            StateBag viewState = base.ViewState;

            if (base.IsSet(8))
            {
                color = (Color)viewState["BackColor"];
                if (!color.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.BackgroundColor, ColorTranslator.ToHtml(color));
                }
            }
            if (base.IsSet(0x10))
            {
                color = (Color)viewState["BorderColor"];
                if (!color.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.BorderColor, ColorTranslator.ToHtml(color));
                }
            }
            BorderStyle borderStyle = base.BorderStyle;
            Unit        borderWidth = base.BorderWidth;

            if (!borderWidth.IsEmpty)
            {
                attributes.Add(HtmlTextWriterStyle.BorderWidth, borderWidth.ToString(CultureInfo.InvariantCulture));
                if (borderStyle == BorderStyle.NotSet)
                {
                    if (borderWidth.Value != 0.0)
                    {
                        attributes.Add(HtmlTextWriterStyle.BorderStyle, "solid");
                    }
                }
                else
                {
                    attributes.Add(HtmlTextWriterStyle.BorderStyle, Style.borderStyles[(int)borderStyle]);
                }
            }
            else if (borderStyle != BorderStyle.NotSet)
            {
                attributes.Add(HtmlTextWriterStyle.BorderStyle, Style.borderStyles[(int)borderStyle]);
            }
            if (base.IsSet(0x80))
            {
                unit2 = (Unit)viewState["Height"];
                if (!unit2.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.Height, unit2.ToString(CultureInfo.InvariantCulture));
                }
            }
            if (base.IsSet(0x100))
            {
                unit2 = (Unit)viewState["Width"];
                if (!unit2.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.Width, unit2.ToString(CultureInfo.InvariantCulture));
                }
            }
            if (!this.HorizontalPadding.IsEmpty || !this.VerticalPadding.IsEmpty)
            {
                Unit unit3 = this.VerticalPadding.IsEmpty ? Unit.Pixel(0) : this.VerticalPadding;
                Unit unit4 = this.HorizontalPadding.IsEmpty ? Unit.Pixel(0) : this.HorizontalPadding;
                attributes.Add(HtmlTextWriterStyle.Padding, string.Format(CultureInfo.InvariantCulture, "{0} {1} {0} {1}", new object[] { unit3.ToString(CultureInfo.InvariantCulture), unit4.ToString(CultureInfo.InvariantCulture) }));
            }
        }
Beispiel #26
0
 //-------------------------------------------------------------------------------------------------------------
 public static void AddTDLine(CssStyleCollection css, int type, string strColor)
 {
     //css.Add("border-color", "red");
     switch (type)
     {
         case 1234:
             css.Add("border-left", "1px solid  " + strColor + " ");
             css.Add("border-top", "1px solid " + strColor + " ");
             css.Add("border-right", "1px solid " + strColor + " ");
             css.Add("border-bottom", "1px solid " + strColor + " ");
             break;
         case 123:
             css.Add("border-left", "1px solid " + strColor + "");
             css.Add("border-top", " 1px solid " + strColor + "");
             css.Add("border-right","1px solid " + strColor + "");
             break;
         case 234:
             css.Add("border-top", "1px solid  " + strColor + " ");
             css.Add("border-right", "1px solid  " + strColor + " ");
             css.Add("border-bottom", "1px solid  " + strColor + " ");
             break;
         case 124:
             css.Add("border-left", "1px solid  " + strColor + " ");
             css.Add("border-top", "1px solid  " + strColor + " ");
             css.Add("border-bottom", "1px solid " + strColor + "");
             break;
         case 134:
             css.Add("border-left", "1px solid  " + strColor + "");
             css.Add("border-right", "1px solid  " + strColor + "");
             css.Add("border-bottom", "1px solid  " + strColor + "");
             break;
         case 12:
             css.Add("border-left", "1px solid  " + strColor + "");
             css.Add("border-top", "1px solid  " + strColor + "");
             break;
         case 13:
             css.Add("border-left", "1px solid  " + strColor + "");
             css.Add("border-right", "1px solid  " + strColor + "");
             break;
         case 23:
             css.Add("border-top", "1px solid  " + strColor + "");
             css.Add("border-right", "1px solid  " + strColor + "");
             break;
         case 34:
             css.Add("border-right", "1px solid  " + strColor + "");
             css.Add("border-bottom", "1px solid " + strColor + " ");
             break;
         case 1:
             css.Add("border-left", "1px solid  " + strColor + "");
             break;
         case 2:
             css.Add("border-top", "1px solid  " + strColor + "");
             break;
         case 3:
             css.Add("border-right", "1px solid  " + strColor + "");
             break;
         case 4:
             css.Add("border-bottom", "1px solid  " + strColor + "");
             break;
         default:
             break;
     }
 }
        internal void FillStyleAttributes(CssStyleCollection attributes, bool alwaysRenderTextDecoration)
        {
            if (IsEmpty)
            {
                if (alwaysRenderTextDecoration)
                {
                    attributes.Add(HtmlTextWriterStyle.TextDecoration, "none");
                }
                return;
            }

            string s;

            // Fonts are a bit weird
            s = String.Join(",", Names);
            if (s.Length > 0)
            {
                attributes.Add(HtmlTextWriterStyle.FontFamily, s);
            }

            if (_owner.CheckBit((int)Style.Styles.FontBold))
            {
                attributes.Add(HtmlTextWriterStyle.FontWeight, Bold ? "bold" : "normal");
            }

            if (_owner.CheckBit((int)Style.Styles.FontItalic))
            {
                attributes.Add(HtmlTextWriterStyle.FontStyle, Italic ? "italic" : "normal");
            }

            if (!Size.IsEmpty)
            {
                attributes.Add(HtmlTextWriterStyle.FontSize, Size.ToString());
            }

            // These styles are munged into a attribute decoration
            s = String.Empty;
            bool hasTextDecoration = false;

            if (_owner.CheckBit((int)Style.Styles.FontOverline))
            {
                if (Overline)
                {
                    s += "overline ";
                }
                hasTextDecoration = true;
            }

            if (_owner.CheckBit((int)Style.Styles.FontStrikeout))
            {
                if (Strikeout)
                {
                    s += "line-through ";
                }
                hasTextDecoration = true;
            }

            if (_owner.CheckBit((int)Style.Styles.FontUnderline))
            {
                if (Underline)
                {
                    s += "underline ";
                }
                hasTextDecoration = true;
            }

            s = (s.Length > 0) ? s.Trim() : (alwaysRenderTextDecoration || hasTextDecoration) ? "none" : String.Empty;
            if (s.Length > 0)
            {
                attributes.Add(HtmlTextWriterStyle.TextDecoration, s);
            }
        }
Beispiel #28
0
        protected virtual void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
        {
            Color       color;
            BorderStyle bs;
            Unit        u;

            if (CheckBit((int)Styles.BackColor))
            {
                color = (Color)viewstate["BackColor"];
                if (!color.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.BackgroundColor, ColorTranslator.ToHtml(color));
                }
            }

            if (CheckBit((int)Styles.BorderColor))
            {
                color = (Color)viewstate["BorderColor"];
                if (!color.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.BorderColor, ColorTranslator.ToHtml(color));
                }
            }

            bool have_width = false;

            if (CheckBit((int)Styles.BorderWidth))
            {
                u = (Unit)viewstate ["BorderWidth"];
                if (!u.IsEmpty)
                {
                    if (u.Value > 0)
                    {
                        have_width = true;
                    }
                    attributes.Add(HtmlTextWriterStyle.BorderWidth, u.ToString());
                }
            }

            if (CheckBit((int)Styles.BorderStyle))
            {
                bs = (BorderStyle)viewstate ["BorderStyle"];
                if (bs != BorderStyle.NotSet)
                {
                    attributes.Add(HtmlTextWriterStyle.BorderStyle, bs.ToString());
                }
                else if (have_width)
                {
                    attributes.Add(HtmlTextWriterStyle.BorderStyle, "solid");
                }
            }
            else if (have_width)
            {
                attributes.Add(HtmlTextWriterStyle.BorderStyle, "solid");
            }

            if (CheckBit((int)Styles.ForeColor))
            {
                color = (Color)viewstate["ForeColor"];
                if (!color.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.Color, ColorTranslator.ToHtml(color));
                }
            }

            if (CheckBit((int)Styles.Height))
            {
                u = (Unit)viewstate["Height"];
                if (!u.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.Height, u.ToString());
                }
            }

            if (CheckBit((int)Styles.Width))
            {
                u = (Unit)viewstate["Width"];
                if (!u.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.Width, u.ToString());
                }
            }

            Font.FillStyleAttributes(attributes, AlwaysRenderTextDecoration);
        }
Beispiel #29
0
        protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
        {
            // The main style will be rendered on the container element, that does not contain the text.
            // The Hyperlink style will render the text styles
            // Copying the code from the base class, except for the part that deals with Font and ForeColor.
            StateBag viewState = ViewState;
            Color    c;

            // BackColor
            if (IsSet(PROP_BACKCOLOR))
            {
                c = (Color)viewState["BackColor"];
                if (!c.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.BackgroundColor, ColorTranslator.ToHtml(c));
                }
            }

            // BorderColor
            if (IsSet(PROP_BORDERCOLOR))
            {
                c = (Color)viewState["BorderColor"];
                if (!c.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.BorderColor, ColorTranslator.ToHtml(c));
                }
            }

            BorderStyle bs = this.BorderStyle;
            Unit        bu = this.BorderWidth;

            if (!bu.IsEmpty)
            {
                attributes.Add(HtmlTextWriterStyle.BorderWidth, bu.ToString(CultureInfo.InvariantCulture));
                if (bs == BorderStyle.NotSet)
                {
                    if (bu.Value != 0.0)
                    {
                        attributes.Add(HtmlTextWriterStyle.BorderStyle, "solid");
                    }
                }
                else
                {
                    attributes.Add(HtmlTextWriterStyle.BorderStyle, borderStyles[(int)bs]);
                }
            }
            else
            {
                if (bs != BorderStyle.NotSet)
                {
                    attributes.Add(HtmlTextWriterStyle.BorderStyle, borderStyles[(int)bs]);
                }
            }

            Unit u;

            // Height
            if (IsSet(PROP_HEIGHT))
            {
                u = (Unit)viewState["Height"];
                if (!u.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.Height, u.ToString(CultureInfo.InvariantCulture));
                }
            }

            // Width
            if (IsSet(PROP_WIDTH))
            {
                u = (Unit)viewState["Width"];
                if (!u.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.Width, u.ToString(CultureInfo.InvariantCulture));
                }
            }

            if (!HorizontalPadding.IsEmpty || !VerticalPadding.IsEmpty)
            {
                attributes.Add(HtmlTextWriterStyle.Padding, string.Format(CultureInfo.InvariantCulture,
                                                                          "{0} {1} {0} {1}",
                                                                          VerticalPadding.IsEmpty ? Unit.Pixel(0) : VerticalPadding,
                                                                          HorizontalPadding.IsEmpty ? Unit.Pixel(0) : HorizontalPadding));
            }
        }
Beispiel #30
0
        protected virtual void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
        {
            StateBag viewState = ViewState;

            Color c;

            // ForeColor
            if (IsSet(PROP_FORECOLOR))
            {
                c = (Color)viewState["ForeColor"];
                if (!c.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.Color, ColorTranslator.ToHtml(c));
                }
            }

            // BackColor
            if (IsSet(PROP_BACKCOLOR))
            {
                c = (Color)viewState["BackColor"];
                if (!c.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.BackgroundColor, ColorTranslator.ToHtml(c));
                }
            }

            // BorderColor
            if (IsSet(PROP_BORDERCOLOR))
            {
                c = (Color)viewState["BorderColor"];
                if (!c.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.BorderColor, ColorTranslator.ToHtml(c));
                }
            }

            BorderStyle bs = this.BorderStyle;
            Unit        bu = this.BorderWidth;

            if (!bu.IsEmpty)
            {
                attributes.Add(HtmlTextWriterStyle.BorderWidth, bu.ToString(CultureInfo.InvariantCulture));
                if (bs == BorderStyle.NotSet)
                {
                    if (bu.Value != 0.0)
                    {
                        attributes.Add(HtmlTextWriterStyle.BorderStyle, "solid");
                    }
                }
                else
                {
                    attributes.Add(HtmlTextWriterStyle.BorderStyle, borderStyles[(int)bs]);
                }
            }
            else
            {
                if (bs != BorderStyle.NotSet)
                {
                    attributes.Add(HtmlTextWriterStyle.BorderStyle, borderStyles[(int)bs]);
                }
            }

            // need to call the property get in case we have font properties from view state and have not
            // created the font object
            FontInfo font = Font;

            // Font.Names
            string[] names = font.Names;
            if (names.Length > 0)
            {
                attributes.Add(HtmlTextWriterStyle.FontFamily, Style.FormatStringArray(names, ','));
            }

            // Font.Size
            FontUnit fu = font.Size;

            if (fu.IsEmpty == false)
            {
                attributes.Add(HtmlTextWriterStyle.FontSize, fu.ToString(CultureInfo.InvariantCulture));
            }

            // Font.Bold
            if (IsSet(PROP_FONT_BOLD))
            {
                if (font.Bold)
                {
                    attributes.Add(HtmlTextWriterStyle.FontWeight, "bold");
                }
                else
                {
                    attributes.Add(HtmlTextWriterStyle.FontWeight, "normal");
                }
            }

            // Font.Italic
            if (IsSet(PROP_FONT_ITALIC))
            {
                if (font.Italic == true)
                {
                    attributes.Add(HtmlTextWriterStyle.FontStyle, "italic");
                }
                else
                {
                    attributes.Add(HtmlTextWriterStyle.FontStyle, "normal");
                }
            }

            //
            string textDecoration = String.Empty;

            if (font.Underline)
            {
                textDecoration = "underline";
            }
            if (font.Overline)
            {
                textDecoration += " overline";
            }
            if (font.Strikeout)
            {
                textDecoration += " line-through";
            }
            if (textDecoration.Length > 0)
            {
                attributes.Add(HtmlTextWriterStyle.TextDecoration, textDecoration);
            }
            else
            {
                if (IsSet(PROP_FONT_UNDERLINE) || IsSet(PROP_FONT_OVERLINE) || IsSet(PROP_FONT_STRIKEOUT))
                {
                    attributes.Add(HtmlTextWriterStyle.TextDecoration, "none");
                }
            }

            Unit u;

            // Height
            if (IsSet(PROP_HEIGHT))
            {
                u = (Unit)viewState["Height"];
                if (!u.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.Height, u.ToString(CultureInfo.InvariantCulture));
                }
            }

            // Width
            if (IsSet(PROP_WIDTH))
            {
                u = (Unit)viewState["Width"];
                if (!u.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.Width, u.ToString(CultureInfo.InvariantCulture));
                }
            }
        }
        protected override sealed void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
        {
            Debug.Assert(_owner != null);

            StateBag viewState = ViewState;

            Color c;

            // ForeColor
            if (_owner.IsSet(PROP_FORECOLOR))
            {
                c = _owner.ForeColor;
                if (!c.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.Color, ColorTranslator.ToHtml(c));
                }
            }
            // Not defaulting to black anymore for not entirely satisfying but reasonable reasons (VSWhidbey 356729)

            // need to call the property get in case we have font properties from view state and have not
            // created the font object
            FontInfo font = _owner.Font;

            // Font.Names
            string[] names = font.Names;
            if (names.Length > 0)
            {
                attributes.Add(HtmlTextWriterStyle.FontFamily, String.Join(",", names));
            }

            // Font.Size
            FontUnit fu = font.Size;

            if (fu.IsEmpty == false)
            {
                attributes.Add(HtmlTextWriterStyle.FontSize, fu.ToString(CultureInfo.InvariantCulture));
            }

            // Font.Bold
            if (_owner.IsSet(PROP_FONT_BOLD))
            {
                if (font.Bold)
                {
                    attributes.Add(HtmlTextWriterStyle.FontWeight, "bold");
                }
                else
                {
                    attributes.Add(HtmlTextWriterStyle.FontWeight, "normal");
                }
            }

            // Font.Italic
            if (_owner.IsSet(PROP_FONT_ITALIC))
            {
                if (font.Italic == true)
                {
                    attributes.Add(HtmlTextWriterStyle.FontStyle, "italic");
                }
                else
                {
                    attributes.Add(HtmlTextWriterStyle.FontStyle, "normal");
                }
            }

            string textDecoration = String.Empty;

            if (font.Underline)
            {
                textDecoration = "underline";
            }
            if (font.Overline)
            {
                textDecoration += " overline";
            }
            if (font.Strikeout)
            {
                textDecoration += " line-through";
            }
            if (textDecoration.Length > 0)
            {
                attributes.Add(HtmlTextWriterStyle.TextDecoration, textDecoration);
            }
            else
            {
                if (!DoNotRenderDefaults)
                {
                    attributes.Add(HtmlTextWriterStyle.TextDecoration, "none");
                }
            }
            // Removing the border with an inline style if the class name was set
            if (_owner.IsSet(PROP_CSSCLASS))
            {
                attributes.Add(HtmlTextWriterStyle.BorderStyle, "none");
            }
        }
Beispiel #32
0
 //-------------------------------------------------------------------------------------------------------------
 public static void AddTDLine(CssStyleCollection css, int type)
 {
     switch (type)
     {
         case 1234:
             css.Add("border-left", "1px solid windowtext");
             css.Add("border-top", "1px solid windowtext");
             css.Add("border-right", "1px solid windowtext");
             css.Add("border-bottom", "1px solid windowtext");
             break;
         case 123:
             css.Add("border-left", "1px solid windowtext");
             css.Add("border-top", "1px solid windowtext");
             css.Add("border-right", "1px solid windowtext");
             break;
         case 234:
             css.Add("border-top", "1px solid windowtext");
             css.Add("border-right", "1px solid windowtext");
             css.Add("border-bottom", "1px solid windowtext");
             break;
         case 124:
             css.Add("border-left", "1px solid windowtext");
             css.Add("border-top", "1px solid windowtext");
             css.Add("border-bottom", "1px solid windowtext");
             break;
         case 134:
             css.Add("border-left", "1px solid windowtext");
             css.Add("border-right", "1px solid windowtext");
             css.Add("border-bottom", "1px solid windowtext");
             break;
         case 12:
             css.Add("border-left", "1px solid windowtext");
             css.Add("border-top", "1px solid windowtext");
             break;
         case 13:
             css.Add("border-left", "1px solid windowtext");
             css.Add("border-right", "1px solid windowtext");
             break;
         case 23:
             css.Add("border-top", "1px solid windowtext");
             css.Add("border-right", "1px solid windowtext");
             break;
         case 34:
             css.Add("border-right", "1px solid windowtext");
             css.Add("border-bottom", "1px solid windowtext");
             break;
         case 1:
             css.Add("border-left", "1px solid windowtext");
             break;
         case 2:
             css.Add("border-top", "1px solid windowtext");
             break;
         case 3:
             css.Add("border-right", "1px solid windowtext");
             break;
         case 4:
             css.Add("border-bottom", "1px solid windowtext");
             break;
         default:
             break;
     }
 }
Beispiel #33
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);
        }
    }
 protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
 {
     base.FillStyleAttributes(attributes, urlResolver);
     // here are the additional CSS styles
     attributes.Add("float", "right"); // move it to the right in the toolbar
     attributes.Add("margin-left", "2px"); // ensure some left padding
 }
 public StyleBlockStyles AddStyle(HtmlTextWriterStyle styleName, string value)
 {
     _styles.Add(styleName, value);
     return(this);
 }