Ejemplo n.º 1
0
        void RunFontUnit_IFormatProviderToString_Tests()
        {
            MyFormatProvider mfp = new MyFormatProvider();

            FontUnit f1 = new FontUnit(FontSize.Large);

            Assert.AreEqual("Large", f1.ToString(mfp), "T1");

            f1 = new FontUnit(FontSize.AsUnit);
            Assert.AreEqual("10pt", f1.ToString(mfp), "T2");

            f1 = new FontUnit(15);
            Assert.AreEqual("15pt", f1.ToString(mfp), "T3");

            f1 = new FontUnit(null);
            Assert.AreEqual("", f1.ToString(mfp), "T4");

            f1 = new FontUnit("");
            Assert.AreEqual("", f1.ToString(mfp), "T5");

            f1 = new FontUnit(2.5);
            Assert.AreEqual("2.5pt", f1.ToString(mfp), "T6");

            f1 = new FontUnit(5.0, UnitType.Percentage);
            Assert.AreEqual("5%", f1.ToString(mfp), "T7");
        }
Ejemplo n.º 2
0
        public void FontUnitConstructors_Enum5()
        {
            FontUnit fu = new FontUnit("Smaller");

            Assert.AreEqual(FontSize.Smaller, fu.Type, "Smaller");
            Assert.IsTrue(fu.Unit.IsEmpty, "Smaller.IsEmpty");
            Assert.AreEqual("Smaller", fu.ToString(), "Smaller.ToString");
        }
Ejemplo n.º 3
0
        public void FontUnitConstructors_Enum12()
        {
            FontUnit fu = new FontUnit("XX-Large");

            Assert.AreEqual(FontSize.XXLarge, fu.Type, "XX-Large");
            Assert.IsTrue(fu.Unit.IsEmpty, "XX-Large.IsEmpty");
            Assert.AreEqual("XX-Large", fu.ToString(), "XX-Large.ToString");
        }
Ejemplo n.º 4
0
        public void FontUnitConstructors_Enum14()
        {
            FontUnit fu = new FontUnit("XX-Small");

            Assert.AreEqual(FontSize.XXSmall, fu.Type, "XX-Small");
            Assert.IsTrue(fu.Unit.IsEmpty, "XX-Small.IsEmpty");
            Assert.AreEqual("XX-Small", fu.ToString(), "XX-Small.ToString");
        }
Ejemplo n.º 5
0
        public void FontUnitConstructors_Enum3()
        {
            FontUnit fu = new FontUnit("Medium");

            Assert.AreEqual(FontSize.Medium, fu.Type, "Medium");
            Assert.IsTrue(fu.Unit.IsEmpty, "Medium.IsEmpty");
            Assert.AreEqual("Medium", fu.ToString(), "Medium.ToString");
        }
Ejemplo n.º 6
0
        public void FontUnitConstructors_Pixel()
        {
            FontUnit f1 = new FontUnit("10px");

            Assert.AreEqual(FontSize.AsUnit, f1.Type, "#1");
            Assert.AreEqual(UnitType.Pixel, f1.Unit.Type, "#2");
            Assert.AreEqual(10, f1.Unit.Value, "#3");
            Assert.AreEqual("10px", f1.ToString(), "#4");
        }
Ejemplo n.º 7
0
        internal static void AddStyleFontAttribute(HtmlTextWriter writer, FontInfo fontInfo)
        {
            string[] fontNames = fontInfo.Names;
            if ((int)fontNames.Length > 0)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontFamily, FormatStringArray(fontNames, ','));
            }

            FontUnit fontUnit = fontInfo.Size;

            if (!fontUnit.IsEmpty)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontSize, fontUnit.ToString(CultureInfo.InvariantCulture));
            }
            bool bold = fontInfo.Bold;

            if (bold)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontWeight, "bold");
            }
            bool italic = fontInfo.Italic;

            if (italic)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontStyle, "italic");
            }
            bool   underline      = fontInfo.Underline;
            bool   overline       = fontInfo.Overline;
            bool   strikeout      = fontInfo.Strikeout;
            string textDecoration = string.Empty;

            if (underline)
            {
                textDecoration = "underline";
            }

            if (overline)
            {
                textDecoration = String.Concat(textDecoration, " overline");
            }

            if (strikeout)
            {
                textDecoration = String.Concat(textDecoration, " line-through");
            }

            if (textDecoration.Length > 0)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.TextDecoration, textDecoration);
            }
        }
Ejemplo n.º 8
0
        public void FontUnitConstructors_Point()
        {
            CultureInfo originalCulture = CultureInfo.CurrentCulture;

            Thread.CurrentThread.CurrentCulture = new CultureInfo("nl-BE");
            try {
                FontUnit f1 = new FontUnit("12,5pt");
                Assert.AreEqual(FontSize.AsUnit, f1.Type, "Type");
                Assert.AreEqual(UnitType.Point, f1.Unit.Type, "Unit.Type");
                Assert.AreEqual(12.5, f1.Unit.Value, "Unit.Value");
                Assert.AreEqual("12,5pt", f1.ToString(), "ToString");
            } finally {
                // restore original culture
                Thread.CurrentThread.CurrentCulture = originalCulture;
            }
        }
Ejemplo n.º 9
0
        public void FontUnitConstructors_Em()
        {
            CultureInfo originalCulture = CultureInfo.CurrentCulture;

            Thread.CurrentThread.CurrentCulture = new CultureInfo("nl-BE");
            try {
                FontUnit fu = new FontUnit("4,5em");
                Assert.AreEqual(FontSize.AsUnit, fu.Type, "#1");
                Assert.AreEqual(UnitType.Em, fu.Unit.Type, "#2");
                Assert.AreEqual(4.5, fu.Unit.Value, "#3");
                Assert.AreEqual("4,5em", fu.ToString(), "#4");
            } finally {
                // restore original culture
                Thread.CurrentThread.CurrentCulture = originalCulture;
            }
        }
        private IDictionary ConvertFontInfoToCss(FontInfo font)
        {
            IDictionary dictionary = new HybridDictionary();
            string      name       = font.Name;

            if (name.Length != 0)
            {
                dictionary["font-family"] = HttpUtility.HtmlEncode(name);
            }
            FontUnit size = font.Size;

            if (size != FontUnit.Empty)
            {
                dictionary["font-size"] = size.ToString(CultureInfo.CurrentCulture);
            }
            if (font.Bold)
            {
                dictionary["font-weight"] = "bold";
            }
            if (font.Italic)
            {
                dictionary["font-style"] = "italic";
            }
            string str2 = string.Empty;

            if (font.Underline)
            {
                str2 = str2 + "underline ";
            }
            if (font.Strikeout)
            {
                str2 = str2 + "line-through";
            }
            if (font.Overline)
            {
                str2 = str2 + "overline";
            }
            if (str2.Length > 0)
            {
                dictionary["text-decoration"] = str2.Trim();
            }
            return(dictionary);
        }
 protected virtual void AddDesignTimeCssAttributes(IDictionary styleAttributes)
 {
     if (base.IsWebControl)
     {
         WebControl viewControl = base.ViewControl as WebControl;
         Unit       width       = viewControl.Width;
         if (!width.IsEmpty && (width.Value != 0.0))
         {
             styleAttributes["width"] = width.ToString(CultureInfo.InvariantCulture);
         }
         Unit height = viewControl.Height;
         if (!height.IsEmpty && (height.Value != 0.0))
         {
             styleAttributes["height"] = height.ToString(CultureInfo.InvariantCulture);
         }
         string str = ColorTranslator.ToHtml(viewControl.BackColor);
         if (str.Length > 0)
         {
             styleAttributes["background-color"] = str;
         }
         str = ColorTranslator.ToHtml(viewControl.ForeColor);
         if (str.Length > 0)
         {
             styleAttributes["color"] = str;
         }
         str = ColorTranslator.ToHtml(viewControl.BorderColor);
         if (str.Length > 0)
         {
             styleAttributes["border-color"] = str;
         }
         Unit borderWidth = viewControl.BorderWidth;
         if (!borderWidth.IsEmpty && (borderWidth.Value != 0.0))
         {
             styleAttributes["border-width"] = borderWidth.ToString(CultureInfo.InvariantCulture);
         }
         BorderStyle borderStyle = viewControl.BorderStyle;
         if (borderStyle != BorderStyle.NotSet)
         {
             styleAttributes["border-style"] = borderStyle;
         }
         else if (!borderWidth.IsEmpty && (borderWidth.Value != 0.0))
         {
             styleAttributes["border-style"] = BorderStyle.Solid;
         }
         string name = viewControl.Font.Name;
         if (name.Length != 0)
         {
             styleAttributes["font-family"] = HttpUtility.HtmlEncode(name);
         }
         FontUnit size = viewControl.Font.Size;
         if (size != FontUnit.Empty)
         {
             styleAttributes["font-size"] = size.ToString(CultureInfo.InvariantCulture);
         }
         if (viewControl.Font.Bold)
         {
             styleAttributes["font-weight"] = "bold";
         }
         if (viewControl.Font.Italic)
         {
             styleAttributes["font-style"] = "italic";
         }
         string str3 = string.Empty;
         if (viewControl.Font.Underline)
         {
             str3 = str3 + "underline ";
         }
         if (viewControl.Font.Strikeout)
         {
             str3 = str3 + "line-through";
         }
         if (viewControl.Font.Overline)
         {
             str3 = str3 + "overline";
         }
         if (str3.Length > 0)
         {
             styleAttributes["text-decoration"] = str3.Trim();
         }
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Renders ToolbarItem attributes.
        /// </summary>
        /// <param name="writer">The HtmlTextWriter to receive markup.</param>
        protected override void WriteItemAttributes(HtmlTextWriter writer)
        {
            base.WriteItemAttributes(writer);

            string css = CssClass;

            if (css.Length > 0)
            {
                writer.WriteAttribute("class", css);
            }

            string style = String.Empty;

            Color color = ForeColor;

            if (!color.IsEmpty)
            {
                style += "color:" + ColorTranslator.ToHtml(color) + ";";
            }

            color = BackColor;
            if (!color.IsEmpty)
            {
                style += "background-color:" + ColorTranslator.ToHtml(color) + ";";
            }

#if false
            color = BorderColor;
            if (!color.IsEmpty)
            {
                style += "border-color:" + ColorTranslator.ToHtml(color) + ";";
            }

            BorderStyle bs   = BorderStyle;
            Unit        unit = BorderWidth;

            if (bs != BorderStyle.NotSet)
            {
                style += "border-style:" + Enum.Format(typeof(BorderStyle), bs, "G") + ";";
            }

            if (!unit.IsEmpty)
            {
                style += "border-width:" + unit.ToString(CultureInfo.InvariantCulture) + ";";

                if ((bs == BorderStyle.NotSet) && (unit.Value != 0.0))
                {
                    style += "border-style:solid;";
                }
            }
#endif

            FontInfo font = Font;

            string[] names = font.Names;
            if (names.Length > 0)
            {
                style += "font-family:";
                for (int i = 0; i < names.Length; i++)
                {
                    if (i > 0)
                    {
                        style += ",";
                    }
                    style += names[i];
                }
                style += ";";
            }

            FontUnit fu = font.Size;
            if (!fu.IsEmpty)
            {
                style += "font-size:" + fu.ToString(CultureInfo.InvariantCulture) + ";";
            }

            if (font.Bold)
            {
                style += "font-weight:bold;";
            }
            if (font.Italic)
            {
                style += "font-style:italic;";
            }

            bool   underline = font.Underline;
            bool   overline  = font.Overline;
            bool   strikeout = font.Strikeout;
            string td        = String.Empty;

            if (underline)
            {
                td = "underline";
            }
            if (overline)
            {
                td += " overline";
            }
            if (strikeout)
            {
                td += " line-through";
            }
            if (td.Length > 0)
            {
                style += "text-decoration:" + td + ";";
            }

#if false
            unit = Height;
            if (!unit.IsEmpty)
            {
                style += "height:" + unit.ToString(CultureInfo.InvariantCulture) + ";";
            }
#endif

            Unit unit = Width;
            if (!unit.IsEmpty)
            {
                style += "width:" + unit.ToString(CultureInfo.InvariantCulture) + ";";
            }

            style += Style.CssText;

            writer.WriteAttribute("style", style);

            if (Enabled)
            {
                string script = "if ((event.propertyName!=null)&&(event.propertyName.toLowerCase()=='selectedindex')){window.document.all." + HelperID + ".value=options[selectedIndex].value;";

                Toolbar parent = ParentToolbar;
                if (AutoPostBack && (parent != null))
                {
                    script += "if (" + parent.ClientID + ".getAttribute('_submitting') == null){" + parent.ClientID + ".setAttribute('_submitting', 'true');window.setTimeout('" + parent.Page.GetPostBackEventReference(_List).Replace("'", "\\'") + "', 0, 'JScript');}";
                }

                script += "}";

                writer.WriteAttribute("onpropertychange", script);
            }
        }
Ejemplo n.º 13
0
        /// <include file='doc\ReadWriteControlDesigner.uex' path='docs/doc[@for="ReadWriteControlDesigner.OnBehaviorAttached"]/*' />
        /// <devdoc>
        ///    Notification that is fired upon the designer being attached to the behavior.
        /// </devdoc>
        protected override void OnBehaviorAttached() {
            base.OnBehaviorAttached();

            if (!IsWebControl) {
                return;
            }
            
            WebControl control = (WebControl)Component;
            string colorValue;
                
            colorValue = System.Drawing.ColorTranslator.ToHtml((System.Drawing.Color)control.BackColor);
            if (colorValue.Length > 0) {
                MapPropertyToStyle("BackColor", colorValue);
            }
            
            colorValue = System.Drawing.ColorTranslator.ToHtml((System.Drawing.Color)control.ForeColor);
            if (colorValue.Length > 0) {
                MapPropertyToStyle("ForeColor", colorValue);
            }
            
            colorValue = System.Drawing.ColorTranslator.ToHtml((System.Drawing.Color)control.BorderColor);
            if (colorValue.Length > 0) {
                MapPropertyToStyle("BorderColor", colorValue);
            }
            
            BorderStyle borderStyle = control.BorderStyle;
            if (borderStyle != BorderStyle.NotSet) {
                MapPropertyToStyle("BorderStyle", borderStyle);
            }
            
            Unit borderWidth = control.BorderWidth;
            if (borderWidth.IsEmpty == false && borderWidth.Value != 0) {
                MapPropertyToStyle("BorderWidth", borderWidth.ToString());
            }
        
            Unit width = control.Width;
            if (!width.IsEmpty && width.Value != 0) {
                MapPropertyToStyle("Width", width.ToString());
            }
            
            Unit height = control.Height;
            if (!height.IsEmpty && height.Value != 0) {
                MapPropertyToStyle("Height", height.ToString());
            }

            string fontName = control.Font.Name;
            if (fontName.Length != 0) {
                MapPropertyToStyle("Font.Name", fontName);
            }

            FontUnit fontSize = control.Font.Size;
            if (fontSize != FontUnit.Empty) {
                MapPropertyToStyle("Font.Size", fontSize.ToString());
            }

            bool boolValue = control.Font.Bold;
            if (boolValue) {
                MapPropertyToStyle("Font.Bold", boolValue);
            }

            boolValue = control.Font.Italic;
            if (boolValue) {
                MapPropertyToStyle("Font.Italic", boolValue);
            }

            boolValue = control.Font.Underline;
            if (boolValue) {
                MapPropertyToStyle("Font.Underline", boolValue);
            }

            boolValue = control.Font.Strikeout;
            if (boolValue) {
                MapPropertyToStyle("Font.Strikeout", boolValue);
            }

            boolValue = control.Font.Overline;
            if (boolValue) {
                MapPropertyToStyle("Font.Overline", boolValue);
            }
        }
        private string StyleToCss(Style style)
        {
            StringBuilder builder   = new StringBuilder();
            Color         foreColor = style.ForeColor;

            if (!foreColor.IsEmpty)
            {
                builder.Append("color:");
                builder.Append(ColorTranslator.ToHtml(foreColor));
                builder.Append(";");
            }
            foreColor = style.BackColor;
            if (!foreColor.IsEmpty)
            {
                builder.Append("background-color:");
                builder.Append(ColorTranslator.ToHtml(foreColor));
                builder.Append(";");
            }
            FontInfo font = style.Font;
            string   name = font.Name;

            if (name.Length != 0)
            {
                builder.Append("font-family:'");
                builder.Append(name);
                builder.Append("';");
            }
            if (font.Bold)
            {
                builder.Append("font-weight:bold;");
            }
            if (font.Italic)
            {
                builder.Append("font-style:italic;");
            }
            name = string.Empty;
            if (font.Underline)
            {
                name = name + "underline";
            }
            if (font.Strikeout)
            {
                name = name + " line-through";
            }
            if (font.Overline)
            {
                name = name + " overline";
            }
            if (name.Length != 0)
            {
                builder.Append("text-decoration:");
                builder.Append(name);
                builder.Append(';');
            }
            FontUnit size = font.Size;

            if (!size.IsEmpty)
            {
                builder.Append("font-size:");
                builder.Append(size.ToString(CultureInfo.InvariantCulture));
            }
            return(builder.ToString());
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Opens the downlevel table.
        /// </summary>
        /// <param name="writer">The HtmlTextWriter object that receives the control content.</param>
        /// <param name="isDesignMode">Indicates whether this is design mode.</param>
        private void RenderBeginTable(HtmlTextWriter writer, bool isDesignMode)
        {
            bool resetBorderWidth = false;
            bool resetBorderStyle = false;
            bool resetBorderColor = false;

            if ((BackColor == Color.Empty) && (GetStyle("background-color") == null))
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, "#D0D0D0");
            }

            if (!isDesignMode &&
                (Width == Unit.Empty) && (GetStyle("width") == null) &&
                (String.Compare(GetStyle("position"), "absolute", true) != 0))

            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
            }

            if ((BorderWidth == Unit.Empty) && NotExistBorder("width"))
            {
                Style["border-width"] = "1";
                resetBorderWidth      = true;
            }

            if ((BorderStyle == BorderStyle.NotSet) && NotExistBorder("style"))
            {
                Style["border-style"] = "solid";
                resetBorderStyle      = true;
            }

            if ((BorderColor == Color.Empty) && NotExistBorder("color"))
            {
                Style["border-top-color"]    = "#FFFFFF";
                Style["border-left-color"]   = "#FFFFFF";
                Style["border-bottom-color"] = "#999999";
                Style["border-right-color"]  = "#999999";
                resetBorderColor             = true;
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");

            string padding = Util.ExtractNumberString(GetStyle("padding"));

            if (padding == String.Empty)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "1");
            }
            else
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, padding);
            }

            AddAttributesToRender(writer);
            writer.RenderBeginTag(HtmlTextWriterTag.Table);
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            if (DefaultStyle["border-width"] == null)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Border, "1");
            }
            else
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Border, DefaultStyle["border-width"]);
            }

            padding = Util.ExtractNumberString(DefaultStyle["padding"]);
            if (padding == String.Empty)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "1");
            }
            else
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, padding);
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Style, "border-width:0");

            FontInfo font = Font;

            string[] names = font.Names;
            if (names.Length > 0)
            {
                string fontNames = String.Empty;
                for (int i = 0; i < names.Length; i++)
                {
                    if (i > 0)
                    {
                        fontNames += ",";
                    }
                    fontNames += names[i];
                }
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontFamily, fontNames);
            }

            FontUnit fu = font.Size;

            if (!fu.IsEmpty)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontSize, fu.ToString(CultureInfo.InvariantCulture));
            }

            if (font.Bold)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontWeight, "bold");
            }
            if (font.Italic)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontStyle, "italic");
            }

            bool   underline = font.Underline;
            bool   overline  = font.Overline;
            bool   strikeout = font.Strikeout;
            string td        = String.Empty;

            if (underline)
            {
                td = "underline";
            }
            if (overline)
            {
                td += " overline";
            }
            if (strikeout)
            {
                td += " line-through";
            }
            if (td.Length > 0)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.TextDecoration, td);
            }

            writer.RenderBeginTag(HtmlTextWriterTag.Table);
            if (Orientation == Orientation.Horizontal)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            }

            if (resetBorderWidth)
            {
                Style.Remove("border-width");
            }

            if (resetBorderStyle)
            {
                Style.Remove("border-style");
            }

            if (resetBorderColor)
            {
                Style.Remove("border-top-color");
                Style.Remove("border-left-color");
                Style.Remove("border-bottom-color");
                Style.Remove("border-right-color");
            }
        }
        private string StyleToCss(Style style)
        {
            Debug.Assert(style != null);

            StringBuilder sb = new StringBuilder();
            Color         c;

            c = style.ForeColor;
            if (!c.IsEmpty)
            {
                sb.Append("color:");
                sb.Append(ColorTranslator.ToHtml(c));
                sb.Append(";");
            }
            c = style.BackColor;
            if (!c.IsEmpty)
            {
                sb.Append("background-color:");
                sb.Append(ColorTranslator.ToHtml(c));
                sb.Append(";");
            }

            FontInfo fi = style.Font;
            string   s;

            s = fi.Name;
            if (s.Length != 0)
            {
                sb.Append("font-family:'");
                sb.Append(s);
                sb.Append("';");
            }
            if (fi.Bold)
            {
                sb.Append("font-weight:bold;");
            }
            if (fi.Italic)
            {
                sb.Append("font-style:italic;");
            }

            s = String.Empty;
            if (fi.Underline)
            {
                s += "underline";
            }
            if (fi.Strikeout)
            {
                s += " line-through";
            }
            if (fi.Overline)
            {
                s += " overline";
            }
            if (s.Length != 0)
            {
                sb.Append("text-decoration:");
                sb.Append(s);
                sb.Append(';');
            }

            FontUnit unit = fi.Size;

            if (unit.IsEmpty == false)
            {
                sb.Append("font-size:");
                sb.Append(unit.ToString());
            }

            return(sb.ToString());
        }
Ejemplo n.º 17
0
        public void RegisterClientScriptBlock(Page page)
        {
            page.ClientScript.RegisterClientScriptBlock(this.GetType(), "gfx_toolbarstyle_" + _name, @"
<script language=""javascript"">
var " + _name + @"_OverImage = new Image();
" + _name + @"_OverImage.src = '" + page.ResolveUrl(_buttonPath) + _buttonStyle.OverBackgroundImage + _buttonExtension + @"';
var " + _name + @"_DownImage = new Image(); 
" + _name + @"_DownImage.src = '" + page.ResolveUrl(_buttonPath) + _buttonStyle.DownBackgroundImage + _buttonExtension + @"';
</script>
<style>
td." + _name + @"_StartTabOn {
	font-size: "     + _fontSize.ToString() + @";
	padding:1px;
	border-left: 1 solid "     + ColorTranslator.ToHtml(this.GutterBackColor) + @";
	border-right: 1 solid "     + ColorTranslator.ToHtml(this.GutterBorderColorLight) + @";
	border-top: 1 solid "     + ColorTranslator.ToHtml(this.GutterBorderColorDark) + @";
	border-bottom: 1 solid "     + ColorTranslator.ToHtml(this.GutterBackColor) + @";
	background-color: "     + ColorTranslator.ToHtml(this.GutterBackColor) + @";
}
td." + _name + @"_StartTabOff {
	font-size: "     + _fontSize.ToString() + @";
	padding:1px;
	border-left: 1 solid "     + ColorTranslator.ToHtml(this.GutterBackColor) + @";
	border-right: 1 solid "     + ColorTranslator.ToHtml(this.GutterBorderColorDark) + @";
	border-top: 1 solid "     + ColorTranslator.ToHtml(this.GutterBorderColorDark) + @";
	border-bottom: 1 solid "     + ColorTranslator.ToHtml(this.GutterBackColor) + @";
	background-color: "     + ColorTranslator.ToHtml(this.GutterBackColor) + @";
}
td." + _name + @"_TabOn {
	font-size: "     + _fontSize.ToString() + @";
	padding:1px;
	padding-left:5px;
	padding-right:5px;
	border-left: 1 solid "     + ColorTranslator.ToHtml(this._gutterBorderColorLight) + @";
	border-right: 1 solid "     + ColorTranslator.ToHtml(this._gutterBorderColorDark) + @";
	border-top: 1 solid "     + ColorTranslator.ToHtml(this._backColor) + @";
	border-bottom: 1 solid "     + ColorTranslator.ToHtml(this._gutterBorderColorDark) + @";
	background-color: "     + ColorTranslator.ToHtml(this._backColor) + @";
}
td." + _name + @"_TabOffRight {
	font-size: "     + _fontSize.ToString() + @";
	padding:1px;
	padding-left:5px;
	padding-right:5px;
	border-left: 1 solid "     + ColorTranslator.ToHtml(this._gutterBorderColorDark) + @";
	border-right: 1 solid "     + ColorTranslator.ToHtml(this._gutterBorderColorDark) + @";
	border-top: 1 solid "     + ColorTranslator.ToHtml(this._gutterBorderColorDark) + @";
	border-bottom: 1 solid "     + ColorTranslator.ToHtml(this._gutterBackColor) + @";
	background-color: "     + ColorTranslator.ToHtml(this._gutterBackColor) + @";
}
td." + _name + @"_TabOffLeft {
	font-size: "     + _fontSize.ToString() + @";
	padding:1px;
	padding-left:5px;
	padding-right:5px;
	border-left: 1 solid "     + ColorTranslator.ToHtml(this._gutterBorderColorDark) + @";
	border-right: 1 solid "     + ColorTranslator.ToHtml(this._gutterBorderColorLight) + @";
	border-top: 1 solid "     + ColorTranslator.ToHtml(this._gutterBorderColorDark) + @";
	border-bottom: 1 solid "     + ColorTranslator.ToHtml(this._backColor) + @";
	background-color: "     + ColorTranslator.ToHtml(this._gutterBackColor) + @";
}
td." + _name + @"_EndTab {
	font-size: "     + _fontSize.ToString() + @";
	width: 100%;
	padding:1px;
	border-left: 1 solid "     + ColorTranslator.ToHtml(this._gutterBackColor) + @";
	border-right: 1 solid "     + ColorTranslator.ToHtml(this._gutterBackColor) + @";
	border-top: 1 solid "     + ColorTranslator.ToHtml(this._gutterBorderColorDark) + @";
	border-bottom: 1 solid "     + ColorTranslator.ToHtml(this._gutterBackColor) + @";
	background-color: "     + ColorTranslator.ToHtml(this._gutterBackColor) + @";
}
td." + _name + @"_None {
}
td." + _name + @"_ButtonNormal {
	"     + ((_backColor != Color.Empty) ? "border: 1 solid " + ColorTranslator.ToHtml(_backColor) + ";" : "padding: 1px;") + @"
	"     + ((_backColor != Color.Empty) ? "background-color:  " + ColorTranslator.ToHtml(_backColor) + ";" : "") + @"
	font-family: MS Sans Serif;
	font-size: "     + _fontSize.ToString() + @";
}
td." + _name + @"_ButtonOver {
	border-top: 1 solid "     + ColorTranslator.ToHtml(ButtonStyle.OverBorderColorLight) + @";	
	border-left: 1 solid "     + ColorTranslator.ToHtml(ButtonStyle.OverBorderColorLight) + @";
	border-right: 1 solid "     + ColorTranslator.ToHtml(ButtonStyle.OverBorderColorDark) + @";
	border-bottom: 1 solid "     + ColorTranslator.ToHtml(ButtonStyle.OverBorderColorDark) + @";
	"     + ((ButtonStyle.OverBackColor != Color.Empty) ? "background-color: " + ColorTranslator.ToHtml(_buttonStyle.OverBackColor) + ";" : "") + @"
	font-family: MS Sans Serif;
	font-size: "     + _fontSize.ToString() + @";
}
td." + _name + @"_ButtonDown {
	border-top: 1 solid "     + ColorTranslator.ToHtml(ButtonStyle.DownBorderColorLight) + @";	
	border-left: 1 solid "     + ColorTranslator.ToHtml(ButtonStyle.DownBorderColorLight) + @";
	border-right: 1 solid "     + ColorTranslator.ToHtml(ButtonStyle.DownBorderColorDark) + @";
	border-bottom: 1 solid "     + ColorTranslator.ToHtml(ButtonStyle.DownBorderColorDark) + @";
	"     + ((ButtonStyle.DownBackColor != Color.Empty) ? "background-color: " + ColorTranslator.ToHtml(_buttonStyle.DownBackColor) + ";" : "") + @"
	font-family: MS Sans Serif;
	font-size: "     + _fontSize.ToString() + @";
}
div." + _name + @"_Toolbar {
	margin-bottom: 1px;
	margin-right: 2px;
	float: left;
	"     + ((_backgroundImage) ?
             "background-image: url(" + page.ResolveUrl(_buttonPath) + "toolbar.background." + _buttonExtension + ");" :
             "background-color: " + ColorTranslator.ToHtml(BackColor) + ";")
                                                        + @"
}
</style>");
        }
 protected override void OnBehaviorAttached()
 {
     base.OnBehaviorAttached();
     if (base.IsWebControl)
     {
         WebControl component    = (WebControl)base.Component;
         string     varPropValue = ColorTranslator.ToHtml(component.BackColor);
         if (varPropValue.Length > 0)
         {
             this.MapPropertyToStyle("BackColor", varPropValue);
         }
         varPropValue = ColorTranslator.ToHtml(component.ForeColor);
         if (varPropValue.Length > 0)
         {
             this.MapPropertyToStyle("ForeColor", varPropValue);
         }
         varPropValue = ColorTranslator.ToHtml(component.BorderColor);
         if (varPropValue.Length > 0)
         {
             this.MapPropertyToStyle("BorderColor", varPropValue);
         }
         BorderStyle borderStyle = component.BorderStyle;
         if (borderStyle != BorderStyle.NotSet)
         {
             this.MapPropertyToStyle("BorderStyle", borderStyle);
         }
         Unit borderWidth = component.BorderWidth;
         if (!borderWidth.IsEmpty && (borderWidth.Value != 0.0))
         {
             this.MapPropertyToStyle("BorderWidth", borderWidth.ToString(CultureInfo.InvariantCulture));
         }
         Unit width = component.Width;
         if (!width.IsEmpty && (width.Value != 0.0))
         {
             this.MapPropertyToStyle("Width", width.ToString(CultureInfo.InvariantCulture));
         }
         Unit height = component.Height;
         if (!height.IsEmpty && (height.Value != 0.0))
         {
             this.MapPropertyToStyle("Height", height.ToString(CultureInfo.InvariantCulture));
         }
         string name = component.Font.Name;
         if (name.Length != 0)
         {
             this.MapPropertyToStyle("Font.Name", name);
         }
         FontUnit size = component.Font.Size;
         if (size != FontUnit.Empty)
         {
             this.MapPropertyToStyle("Font.Size", size.ToString(CultureInfo.InvariantCulture));
         }
         bool bold = component.Font.Bold;
         if (bold)
         {
             this.MapPropertyToStyle("Font.Bold", bold);
         }
         bold = component.Font.Italic;
         if (bold)
         {
             this.MapPropertyToStyle("Font.Italic", bold);
         }
         bold = component.Font.Underline;
         if (bold)
         {
             this.MapPropertyToStyle("Font.Underline", bold);
         }
         bold = component.Font.Strikeout;
         if (bold)
         {
             this.MapPropertyToStyle("Font.Strikeout", bold);
         }
         bold = component.Font.Overline;
         if (bold)
         {
             this.MapPropertyToStyle("Font.Overline", bold);
         }
     }
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Renders ToolbarItem attributes.
        /// </summary>
        /// <param name="writer">The HtmlTextWriter to receive markup.</param>
        protected override void WriteItemAttributes(HtmlTextWriter writer)
        {
            base.WriteItemAttributes(writer);

            string css = CssClass;

            if (css.Length > 0)
            {
                writer.WriteAttribute("class", css);
            }

            string style = String.Empty;

            Color color = ForeColor;

            if (!color.IsEmpty)
            {
                style += "color:" + ColorTranslator.ToHtml(color) + ";";
            }

            color = BackColor;
            if (!color.IsEmpty)
            {
                style += "background-color:" + ColorTranslator.ToHtml(color) + ";";
            }

            color = BorderColor;
            if (!color.IsEmpty)
            {
                style += "border-color:" + ColorTranslator.ToHtml(color) + ";";
            }

            BorderStyle bs   = BorderStyle;
            Unit        unit = BorderWidth;

            if (bs != BorderStyle.NotSet)
            {
                style += "border-style:" + Enum.Format(typeof(BorderStyle), bs, "G") + ";";
            }

            if (!unit.IsEmpty)
            {
                style += "border-width:" + unit.ToString(CultureInfo.InvariantCulture) + ";";

                if ((bs == BorderStyle.NotSet) && (unit.Value != 0.0))
                {
                    style += "border-style:solid;";
                }
            }

            FontInfo font = Font;

            string[] names = font.Names;
            if (names.Length > 0)
            {
                style += "font-family:";
                for (int i = 0; i < names.Length; i++)
                {
                    if (i > 0)
                    {
                        style += ",";
                    }
                    style += names[i];
                }
                style += ";";
            }

            FontUnit fu = font.Size;

            if (!fu.IsEmpty)
            {
                style += "font-size:" + fu.ToString(CultureInfo.InvariantCulture) + ";";
            }

            if (font.Bold)
            {
                style += "font-weight:bold;";
            }
            if (font.Italic)
            {
                style += "font-style:italic;";
            }

            bool   underline = font.Underline;
            bool   overline  = font.Overline;
            bool   strikeout = font.Strikeout;
            string td        = String.Empty;

            if (underline)
            {
                td = "underline";
            }
            if (overline)
            {
                td += " overline";
            }
            if (strikeout)
            {
                td += " line-through";
            }
            if (td.Length > 0)
            {
                style += "text-decoration:" + td + ";";
            }

            unit = Height;
            if (!unit.IsEmpty)
            {
                style += "height:" + unit.ToString(CultureInfo.InvariantCulture) + ";";
            }

            unit = Width;
            if (!unit.IsEmpty)
            {
                style += "width:" + unit.ToString(CultureInfo.InvariantCulture) + ";";
            }

            style += Style.CssText;

            writer.WriteAttribute("style", style);

            writer.WriteAttribute("type", (TextMode == ToolbarTextBoxMode.Password) ? "password" : "text");

            if (Columns > 0)
            {
                writer.WriteAttribute("size", Columns.ToString());
            }
            if (MaxLength > 0)
            {
                writer.WriteAttribute("maxlength", MaxLength.ToString());
            }
            if (ReadOnly)
            {
                writer.WriteAttribute("readonly", ReadOnly.ToString());
            }
            if ((Text != String.Empty) && (TextMode != ToolbarTextBoxMode.Password))
            {
                writer.WriteAttribute("value", Text, true);
            }

            if (Enabled)
            {
                writer.WriteAttribute("onpropertychange", "window.document.all." + HelperID + ".value=value");
                writer.WriteAttribute("onchange", "window.document.all." + HelperID + ".value=" + ParentToolbar.ClientID + ".getItem(" + Index + ").getAttribute('value')");
                writer.WriteAttribute("onkeyup", "window.document.all." + HelperID + ".value=" + ParentToolbar.ClientID + ".getItem(" + Index + ").getAttribute('value')");
            }
            else
            {
                writer.WriteAttribute("disabled", "true");
            }

            Toolbar parent = ParentToolbar;
            string  script = "if (event.keyCode==13){event.returnValue=false;";

            if (Enabled && (parent != null) && (parent.Page != null))
            {
                string postBackRef = "if (" + parent.ClientID + ".getAttribute('_submitting') == null){" + parent.ClientID + ".setAttribute('_submitting', 'true');window.setTimeout('" + parent.Page.GetPostBackEventReference(_TextBox).Replace("'", "\\'") + "', 0, 'JScript');}";
                if (AutoPostBack)
                {
                    // Blur will cause a postback when AutoPostBack is true
                    script += "blur();";

                    // Add the blur postback handler
                    writer.WriteAttribute("_origVal", (TextMode != ToolbarTextBoxMode.Password) ? Text : String.Empty, true);
                    writer.WriteAttribute("onblur", "JScript:if (value != _origVal)" + postBackRef);
                }
                else
                {
                    // Do the postback
                    script += postBackRef + ";";
                }
            }
            script += "}";
            writer.WriteAttribute("onkeydown", script);
        }
Ejemplo n.º 20
0
        public static string ToStyleString(this Style style)
        {
            StringBuilder sb = new StringBuilder(256);

            if (style == null)
            {
                return("");
            }

            Color c;

            c = style.ForeColor;
            if (!c.IsEmpty)
            {
                sb.Append("color:");
                sb.Append(ColorTranslator.ToHtml(c));
                sb.Append(";");
            }
            else
            {
                sb.Append("color:black;");
            }

            FontInfo fi = style.Font;
            string   s;

            s = fi.Name;
            if (s.Length != 0)
            {
                sb.Append("font-family:'");
                sb.Append(s);
                sb.Append("';");
            }
            if (fi.Bold)
            {
                sb.Append("font-weight:bold;");
            }
            else
            {
                sb.Append("font-weight:normal;");
            }

            if (fi.Italic)
            {
                sb.Append("font-style:italic;");
            }
            else
            {
                sb.Append("font-style:normal;");
            }

            s = String.Empty;
            if (fi.Underline)
            {
                s += "underline";
            }

            if (fi.Strikeout)
            {
                s += " line-through";
            }

            if (fi.Overline)
            {
                s += " overline";
            }

            if (s.Length != 0)
            {
                sb.Append("text-decoration:");
                sb.Append(s);
                sb.Append(';');
            }
            else
            {
                sb.Append("text-decoration:none;");
            }

            FontUnit fu = fi.Size;

            if (fu.IsEmpty == false)
            {
                sb.Append("font-size:");
                sb.Append(fu.ToString(CultureInfo.InvariantCulture));
                sb.Append(';');
            }

            return(sb.ToString());
        }
Ejemplo n.º 21
0
            public override void LoadFormatInfo()
            {
                HorizontalAlign horizontalAlign;
                Color           backColor = this.runtimeStyle.BackColor;

                this.backColor = ColorTranslator.ToHtml(backColor);
                backColor      = this.runtimeStyle.ForeColor;
                this.foreColor = ColorTranslator.ToHtml(backColor);
                FontInfo font = this.runtimeStyle.Font;

                this.fontName        = font.Name;
                this.fontNameChanged = false;
                this.bold            = font.Bold;
                this.italic          = font.Italic;
                this.underline       = font.Underline;
                this.strikeOut       = font.Strikeout;
                this.overline        = font.Overline;
                this.fontType        = -1;
                FontUnit size = font.Size;

                if (!size.IsEmpty)
                {
                    this.fontSize = null;
                    switch (size.Type)
                    {
                    case FontSize.AsUnit:
                        this.fontType = 10;
                        this.fontSize = size.ToString(CultureInfo.CurrentCulture);
                        break;

                    case FontSize.Smaller:
                        this.fontType = 1;
                        break;

                    case FontSize.Larger:
                        this.fontType = 2;
                        break;

                    case FontSize.XXSmall:
                        this.fontType = 3;
                        break;

                    case FontSize.XSmall:
                        this.fontType = 4;
                        break;

                    case FontSize.Small:
                        this.fontType = 5;
                        break;

                    case FontSize.Medium:
                        this.fontType = 6;
                        break;

                    case FontSize.Large:
                        this.fontType = 7;
                        break;

                    case FontSize.XLarge:
                        this.fontType = 8;
                        break;

                    case FontSize.XXLarge:
                        this.fontType = 9;
                        break;
                    }
                }
                TableItemStyle runtimeStyle = null;

                if (this.runtimeStyle is TableItemStyle)
                {
                    runtimeStyle       = (TableItemStyle)this.runtimeStyle;
                    horizontalAlign    = runtimeStyle.HorizontalAlign;
                    this.allowWrapping = runtimeStyle.Wrap;
                }
                else
                {
                    horizontalAlign = ((TableStyle)this.runtimeStyle).HorizontalAlign;
                }
                this.horzAlignment = 0;
                switch (horizontalAlign)
                {
                case HorizontalAlign.Left:
                    this.horzAlignment = 1;
                    break;

                case HorizontalAlign.Center:
                    this.horzAlignment = 2;
                    break;

                case HorizontalAlign.Right:
                    this.horzAlignment = 3;
                    break;

                case HorizontalAlign.Justify:
                    this.horzAlignment = 4;
                    break;
                }
                if (runtimeStyle != null)
                {
                    VerticalAlign verticalAlign = runtimeStyle.VerticalAlign;
                    this.vertAlignment = 0;
                    switch (verticalAlign)
                    {
                    case VerticalAlign.Top:
                        this.vertAlignment = 1;
                        return;

                    case VerticalAlign.Middle:
                        this.vertAlignment = 2;
                        return;

                    case VerticalAlign.Bottom:
                        this.vertAlignment = 3;
                        break;

                    default:
                        return;
                    }
                }
            }
Ejemplo n.º 22
0
        string GetOperaCSS()
        {
            int    fh              = GetFontHeight(fontfamily, fontsize);
            int    pgwidth         = Width;
            string fontfam         = fontfamily;
            string fntsize         = fontsize.ToString();
            int    widthinner      = Width - 2;
            int    lineheight      = fh + 6;
            int    padwidth        = 18;
            int    lineheightmarge = lineheight + 1;
            int    widthlesspad    = widthinner - padwidth;
            int    halfwidth       = widthlesspad / 2;
            int    halfwidthless3  = halfwidth - 5;
            int    inputlineheight = lineheight - 4;
            string bgcol           = CSSColor(bgcolor);
            string hdcol           = CSSColor(headercolor);
            string frcol           = CSSColor(color);
            string itbgcol         = CSSColor(itembgcolor);
            string selcol          = CSSColor(selcolor);

            return(string.Format(@"
<style type=""text/css"">
.PG_{16}
{{
  width:{0}px;
}}
.PG_{16} *
{{
  font-family:{1};
  font-size:{2};
  color:{13};
}}
.PGH_{16}, .PGF_{16}, .PGC_{16}, .PGF2_{16}
{{
  border-color: {12};
  background-color:{11};
}}
.PGC_{16} *
{{
  line-height:{4}px;
  height:{4}px;
}}
.PGC_{16} a, .PGC_OPEN_{16}, .PGC_CLOSED_{16}
{{
  width:{5}px;
}}
.PGC_HEAD_{16} span
{{
  color:{12};
}}
.PGI_NONE_{16}, .PGI_CLOSED_{16}, .PGI_OPEN_{16}
{{
  width:{5}px;
  height:{6}px;
}}
.PGI_NAME_{16}, .PGI_VALUE_{16}, .PGI_NAME_SUB_{16}
{{
  width:{8}px;
  background-color:{14};
}}
.PGI_VALUE_{16} a, .PGI_VALUE_{16} select
{{
  width:100%;
}}
.PGI_NAME_SUB_{16} span
{{
  margin-left:{5}px;
}}
.PGI_VALUE_{16} a:hover
{{
  background-color:{15};
}}
.PGI_VALUE_{16} input
{{
  width:{9}px;
  line-height:{10}px;
  height:{10}px;
}}
</style>", pgwidth, fontfam, fontsize, widthinner, lineheight, padwidth, lineheightmarge, widthlesspad, halfwidth, halfwidthless3, inputlineheight, bgcol, hdcol, frcol, itbgcol, selcol, ClientID));
        }
Ejemplo n.º 23
0
 /// <summary>
 /// 将布尔值转化为 javascript 字号.
 /// </summary>
 /// <param name="value">字号.</param>
 /// <returns>javascript 字号.</returns>
 private static string toString(FontUnit value)
 {
     return("'" + value.ToString( ) + "'");
 }
        private string CssStyle()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(" style='");
            if (this.BorderWidth.ToString().Length > 0)
            {
                stringBuilder.Append("border-width:");
                stringBuilder.Append(this.BorderWidth.ToString());
                stringBuilder.Append(";");
            }
            if (this.BorderStyle != BorderStyle.NotSet)
            {
                stringBuilder.Append("border-style:");
                stringBuilder.Append(this.BorderStyle.ToString());
                stringBuilder.Append(";");
            }
            string str = this.HtmlColor(this.BorderColor);

            if (str.Length > 0)
            {
                stringBuilder.Append("border-color:");
                stringBuilder.Append(str);
                stringBuilder.Append(";");
            }
            str = this.HtmlColor(this.BackColor);
            if (str.Length > 0)
            {
                stringBuilder.Append(string.Concat("background-color:", str, ";"));
            }
            str = this.HtmlColor(this.ForeColor);
            if (str.Length > 0)
            {
                stringBuilder.Append(string.Concat("color:", str, ";"));
            }
            if (this.Font.Bold)
            {
                stringBuilder.Append("font-weight:bold;");
            }
            if (this.Font.Italic)
            {
                stringBuilder.Append("font-style:italic;");
            }
            if (this.Font.Underline)
            {
                stringBuilder.Append("text-decoration:underline;");
            }
            if (this.Font.Strikeout)
            {
                stringBuilder.Append("text-decoration:line-through;");
            }
            if (this.Font.Overline)
            {
                stringBuilder.Append("text-decoration:overline;");
            }
            if (this.Font.Size.ToString().Length > 0)
            {
                FontUnit size = this.Font.Size;
                stringBuilder.Append(string.Concat("font-size:", size.ToString(), ";"));
            }
            if (this.Font.Names.Length > 0)
            {
                stringBuilder.Append("font-family:");
                string[] names = this.Font.Names;
                for (int i = 0; i < names.Length; i++)
                {
                    stringBuilder.Append(names[i]);
                    stringBuilder.Append(",");
                }
                stringBuilder.Length = stringBuilder.Length - 1;
                stringBuilder.Append(";");
            }
            if (this.Height.ToString() != "")
            {
                Unit height = this.Height;
                stringBuilder.Append(string.Concat("height:", height.ToString(), ";"));
            }
            if (this.Width.ToString() != "")
            {
                Unit width = this.Width;
                stringBuilder.Append(string.Concat("width:", width.ToString(), ";"));
            }
            stringBuilder.Append("'");
            if (stringBuilder.ToString() == " style=''")
            {
                return("");
            }
            return(stringBuilder.ToString());
        }
Ejemplo n.º 25
0
        private string GetCssFromStyle(Style style)
        {
            StringBuilder sb = new StringBuilder(256);
            Color         c;

            c = style.ForeColor;
            if (!c.IsEmpty)
            {
                sb.Append("color:");
                sb.Append(ColorTranslator.ToHtml(c));
                sb.Append(";");
            }
            c = style.BackColor;
            if (!c.IsEmpty)
            {
                sb.Append("background-color:");
                sb.Append(ColorTranslator.ToHtml(c));
                sb.Append(";");
            }

            FontInfo fi = style.Font;
            string   s;

            s = fi.Name;
            if (s.Length != 0)
            {
                sb.Append("font-family:'");
                sb.Append(s);
                sb.Append("';");
            }
            if (fi.Bold)
            {
                sb.Append("font-weight:bold;");
            }
            if (fi.Italic)
            {
                sb.Append("font-style:italic;");
            }

            s = String.Empty;
            if (fi.Underline)
            {
                s += "underline";
            }
            if (fi.Strikeout)
            {
                s += " line-through";
            }
            if (fi.Overline)
            {
                s += " overline";
            }
            if (s.Length != 0)
            {
                sb.Append("text-decoration:");
                sb.Append(s);
                sb.Append(';');
            }

            FontUnit fu = fi.Size;

            if (fu.IsEmpty == false)
            {
                sb.Append("font-size:");
                sb.Append(fu.ToString(CultureInfo.InvariantCulture));
                sb.Append(';');
            }

            s = String.Empty;
            Unit        u  = style.BorderWidth;
            BorderStyle bs = style.BorderStyle;

            if (u.IsEmpty == false)
            {
                s = u.ToString(CultureInfo.InvariantCulture);
                if (bs == BorderStyle.NotSet)
                {
                    s += " solid";
                }
            }
            c = style.BorderColor;
            if (!c.IsEmpty)
            {
                s += " " + ColorTranslator.ToHtml(c);
            }
            if (bs != BorderStyle.NotSet)
            {
                s += " " + Enum.Format(typeof(BorderStyle), bs, "G");
            }
            if (s.Length != 0)
            {
                sb.Append("border:");
                sb.Append(s);
                sb.Append(';');
            }

            return(sb.ToString());
        }