Beispiel #1
0
        public virtual string ToCss()
        {
            StringBuilder b = new StringBuilder();

            if (Foreground != null)
            {
                Color?c = Foreground.GetColor(null);
                if (c != null)
                {
                    b.AppendFormat(CultureInfo.InvariantCulture, "color: #{0:x2}{1:x2}{2:x2}; ", c.Value.R, c.Value.G, c.Value.B);
                }
            }
            if (Background != null)
            {
                Color?c = Background.GetColor(null);
                if (c != null)
                {
                    b.AppendFormat(CultureInfo.InvariantCulture, "background-color: #{0:x2}{1:x2}{2:x2}; ", c.Value.R, c.Value.G, c.Value.B);
                }
            }
            if (FontWeight != null)
            {
                b.Append("font-weight: ");
                b.Append(FontWeight.Value.ToString().ToLowerInvariant());
                b.Append("; ");
            }
            if (FontStyle != null)
            {
                b.Append("font-style: ");
                b.Append(FontStyle.Value.ToString().ToLowerInvariant());
                b.Append("; ");
            }
            if (Underline != null)
            {
                b.Append("text-decoration: ");
                b.Append(Underline.Value ? "underline" : "none");
                b.Append("; ");
            }
            if (Strikethrough != null)
            {
                if (Underline == null)
                {
                    b.Append("text-decoration:  ");
                }

                b.Remove(b.Length - 1, 1);
                b.Append(Strikethrough.Value ? " line-through" : " none");
                b.Append("; ");
            }
            return(b.ToString());
        }