public string ToString(IFormatProvider formatProvider) { if (type == FontSize.NotSet) { return(String.Empty); } else if (type == FontSize.AsUnit) { return(unit.ToString(formatProvider)); } else { return(font_size_names [(int)type]); } }
private void RenderItemSpacing(HtmlTextWriter writer, Unit spacing, Orientation orientation) { if (orientation == Orientation.Vertical) { writer.AddStyleAttribute(HtmlTextWriterStyle.Height, spacing.ToString(CultureInfo.InvariantCulture)); writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderEndTag(); writer.RenderEndTag(); } else { writer.AddStyleAttribute(HtmlTextWriterStyle.Width, spacing.ToString(CultureInfo.InvariantCulture)); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderEndTag(); } }
void RenderMenuItemSpacing(HtmlTextWriter writer, Unit itemSpacing, bool vertical) { if (vertical) { writer.AddStyleAttribute("height", itemSpacing.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderEndTag(); writer.RenderEndTag(); } else { writer.AddStyleAttribute("width", itemSpacing.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderEndTag(); } }
public string ToString(IFormatProvider formatProvider) { string s = String.Empty; if (IsEmpty) { return(s); } switch (type) { case FontSize.AsUnit: s = value.ToString(formatProvider); break; case FontSize.XXSmall: s = "XX-Small"; break; case FontSize.XSmall: s = "X-Small"; break; case FontSize.XLarge: s = "X-Large"; break; case FontSize.XXLarge: s = "XX-Large"; break; default: s = PropertyConverter.EnumToString(typeof(FontSize), type); break; } return(s); }
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (!(destinationType == typeof(string))) { if (!(destinationType == typeof(InstanceDescriptor)) || (value == null)) { return(base.ConvertTo(context, culture, value, destinationType)); } Unit unit = (Unit)value; MemberInfo member = null; object[] arguments = null; if (unit.IsEmpty) { member = typeof(Unit).GetField("Empty"); } else { member = typeof(Unit).GetConstructor(new Type[] { typeof(double), typeof(UnitType) }); arguments = new object[] { unit.Value, unit.Type }; } if (member != null) { return(new InstanceDescriptor(member, arguments)); } return(null); } if (value != null) { Unit unit2 = (Unit)value; if (!unit2.IsEmpty) { Unit unit3 = (Unit)value; return(unit3.ToString(culture)); } } return(string.Empty); }
private static void InitRootTable(HtmlTable table, Unit width, Unit height) { table.CellPadding = 4; table.CellSpacing = 0; table.Style["width"] = width.ToString(); table.Style["height"] = height.ToString(); table.ID = "ContainerTable"; table.Attributes["class"] = "opinionListView"; }
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)); } } }
public void Unit_IFormatProviderToString () { MyFormatProvider mfp = new MyFormatProvider (); Unit a1 = new Unit (1.0); Assert.AreEqual ("1px", a1.ToString (mfp), "A1"); a1 = new Unit (1); Assert.AreEqual ("1px", a1.ToString (mfp), "A2"); a1 = new Unit (32767); Assert.AreEqual ("32767px", a1.ToString (mfp), "A3"); a1 = new Unit (-32768); Assert.AreEqual ("-32768px", a1.ToString (mfp), "A4"); // // String constructor // Unit s1 = new Unit ("-45cm"); Assert.AreEqual ("-45cm", s1.ToString (mfp), "A5"); s1 = new Unit ("\t-45cm"); Assert.AreEqual ("-45cm", s1.ToString (mfp), "A6"); s1 = new Unit ("45\tcm"); Assert.AreEqual ("45cm", s1.ToString (mfp), "A7"); s1 = new Unit (null); Assert.AreEqual ("", s1.ToString (mfp), "A8"); s1 = new Unit ("-45"); Assert.AreEqual ("-45px", s1.ToString (mfp), "A9"); s1 = new Unit ("-45%"); Assert.AreEqual ("-45%", s1.ToString (mfp), "A10"); s1 = new Unit ("-45% \t "); Assert.AreEqual ("-45%", s1.ToString (mfp), "A11"); s1 = new Unit ("-45 % \t "); Assert.AreEqual ("-45%", s1.ToString (mfp), "A12"); s1 = new Unit ("45in"); Assert.AreEqual ("45in", s1.ToString (mfp), "A13"); s1 = new Unit ("45cm"); Assert.AreEqual ("45cm", s1.ToString (mfp), "A14"); s1 = new Unit ("45pt"); Assert.AreEqual ("45pt", s1.ToString (mfp), "A15"); s1 = new Unit ("45pc"); Assert.AreEqual ("45pc", s1.ToString (mfp), "A16"); s1 = new Unit ("45mm"); Assert.AreEqual ("45mm", s1.ToString (mfp), "A17"); s1 = new Unit ("45em"); Assert.AreEqual ("45em", s1.ToString (mfp), "A18"); s1 = new Unit ("45ex"); Assert.AreEqual ("45ex", s1.ToString (mfp), "A19"); s1 = new Unit ("45px"); Assert.AreEqual ("45px", s1.ToString (mfp), "A20"); s1 = new Unit ("1.75cm"); Assert.AreEqual ("1.75cm", s1.ToString (mfp), "A21"); s1 = new Unit ("1.75%"); Assert.AreEqual ("1.75%", s1.ToString (mfp), "A22"); s1 = new Unit (null); Assert.AreEqual ("", s1.ToString (mfp), "A23"); s1 = new Unit (""); Assert.AreEqual ("", s1.ToString (mfp), "A24"); s1 = new Unit ("45.75cm"); Assert.AreEqual ("45.75cm", s1.ToString (mfp), "A25"); a1 = new Unit (1.5); Assert.AreEqual ("1px", a1.ToString (mfp), "A26"); }
public void ParseCultures () { // Test cultures where the decimal separator is not "." CultureInfo ci = new CultureInfo ("es-ES", false); Unit s1 = new Unit ("1,5cm", ci); Assert.AreEqual (s1.Type, UnitType.Cm, "C1"); Assert.AreEqual (s1.Value, 1.5, "C2"); CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; CultureInfo currentUICulture = Thread.CurrentThread.CurrentUICulture; try { CultureInfo ciUS = CultureInfo.GetCultureInfo ("en-US"); Thread.CurrentThread.CurrentCulture = ciUS; Thread.CurrentThread.CurrentUICulture = ciUS; Assert.AreEqual (s1.ToString (), "1.5cm", "A54"); } finally { Thread.CurrentThread.CurrentCulture = currentCulture; Thread.CurrentThread.CurrentUICulture = currentUICulture; } Assert.AreEqual (s1.ToString (ci), "1,5cm", "A55"); }
void RenderMenuItemSpacing (HtmlTextWriter writer, Unit itemSpacing, bool vertical) { if (vertical) { writer.AddStyleAttribute ("height", itemSpacing.ToString ()); writer.RenderBeginTag (HtmlTextWriterTag.Tr); writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.RenderEndTag (); writer.RenderEndTag (); } else { writer.AddStyleAttribute ("width", itemSpacing.ToString ()); writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.RenderEndTag (); } }
public OptionBuilder AddOption(string name, Unit value, bool isStringValue) { if (isStringValue) { this.AddOption(name, value.ToString(), true); } else { this.AddOption(name, value.Value); } return this; }
private string GetPopupDimension(string name, Unit length, int min) { if (length.Type == UnitType.Pixel && length.Value >= min) { return length.ToString(); } else { return min.ToString(); } }
/// <include file='doc\Style.uex' path='docs/doc[@for="Style.AddAttributesToRender1"]/*' /> /// <devdoc> /// <para> /// Adds all non-blank style attributes to the HTML output stream to be rendered /// to the client. /// </para> /// </devdoc> public virtual void AddAttributesToRender(HtmlTextWriter writer, WebControl owner) { StateBag viewState = ViewState; // CssClass if (IsSet(PROP_CSSCLASS)) { string css = (string)(viewState["CssClass"]); if (css.Length > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Class, css); } } Color c; Unit u; // ForeColor if (IsSet(PROP_FORECOLOR)) { c = (Color)(viewState["ForeColor"]);; if (!c.IsEmpty) { writer.AddStyleAttribute(HtmlTextWriterStyle.Color, ColorTranslator.ToHtml(c)); } } // BackColor if (IsSet(PROP_BACKCOLOR)) { c = (Color)(viewState["BackColor"]); if (!c.IsEmpty) { writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, ColorTranslator.ToHtml(c)); } } // BorderColor if (IsSet(PROP_BORDERCOLOR)) { c = (Color)(viewState["BorderColor"]); if (!c.IsEmpty) { writer.AddStyleAttribute(HtmlTextWriterStyle.BorderColor, ColorTranslator.ToHtml(c)); } } BorderStyle bs = this.BorderStyle; Unit bu = this.BorderWidth; if (!bu.IsEmpty) { writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, bu.ToString(CultureInfo.InvariantCulture)); if (bs == BorderStyle.NotSet) { if (bu.Value != 0.0) { writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "solid"); } } else { writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, Enum.Format(typeof(BorderStyle), bs, "G")); } } else { if (bs != BorderStyle.NotSet) { writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, Enum.Format(typeof(BorderStyle), bs, "G")); } } // 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) { writer.AddStyleAttribute(HtmlTextWriterStyle.FontFamily, Style.FormatStringArray(names, ',')); } // Font.Size FontUnit fu = font.Size; if (fu.IsEmpty == false) { writer.AddStyleAttribute(HtmlTextWriterStyle.FontSize, fu.ToString(CultureInfo.InvariantCulture)); } // CONSIDER: How do we determine whether to render "normal" for font-weight or font-style? // How do we determine whether to render "none" for text-decoration? // Font.Bold bool fw = font.Bold; if (fw == true) { writer.AddStyleAttribute(HtmlTextWriterStyle.FontWeight, "bold"); } // Font.Italic bool fi = font.Italic; if (fi == true) { writer.AddStyleAttribute(HtmlTextWriterStyle.FontStyle, "italic"); } bool underline = font.Underline; bool overline = font.Overline; bool strikeout = font.Strikeout; string td = String.Empty; // CONSIDER, nikhilko: we need to detect not-set state and write out "none" if (underline) { td = "underline"; } if (overline) { td += " overline"; } if (strikeout) { td += " line-through"; } if (td.Length > 0) { writer.AddStyleAttribute(HtmlTextWriterStyle.TextDecoration, td); } // Height if (IsSet(PROP_HEIGHT)) { u = (Unit)(viewState["Height"]); if (u.IsEmpty == false) { writer.AddStyleAttribute(HtmlTextWriterStyle.Height, u.ToString(CultureInfo.InvariantCulture)); } } // Width if (IsSet(PROP_WIDTH)) { u = (Unit)(viewState["Width"]); if (u.IsEmpty == false) { writer.AddStyleAttribute(HtmlTextWriterStyle.Width, u.ToString(CultureInfo.InvariantCulture)); } } }
private void Test(Type ctrlType) { Unit unit1; try { this.GHTSubTestBegin(ctrlType, "Valid value"); unit1 = new Unit(120); this.TestedControl.Width = unit1; } catch (Exception exception5) { // ProjectData.SetProjectError(exception5); Exception exception1 = exception5; this.GHTSubTestUnexpectedExceptionCaught(exception1); // ProjectData.ClearProjectError(); } try { this.GHTSubTestBegin(ctrlType, "Default value"); unit1 = this.TestedControl.Width; this.GHTSubTestAddResult("Default width = " + unit1.ToString()); } catch (Exception exception6) { // ProjectData.SetProjectError(exception6); Exception exception2 = exception6; this.GHTSubTestUnexpectedExceptionCaught(exception2); // ProjectData.ClearProjectError(); } this.GHTSubTestEnd(); try { this.GHTSubTestBegin(ctrlType, "Negative value"); unit1 = new Unit(-10); this.TestedControl.Width = unit1; this.GHTSubTestExpectedExceptionNotCaught("ArgumentException"); } catch (ArgumentException exception7) { // ProjectData.SetProjectError(exception7); // ArgumentException exception3 = exception7; this.GHTSubTestAddResult("Test passed. Expected ArgumentException exception was caught."); // ProjectData.ClearProjectError(); } catch (Exception exception8) { // ProjectData.SetProjectError(exception8); Exception exception4 = exception8; this.GHTSubTestUnexpectedExceptionCaught(exception4); // ProjectData.ClearProjectError(); } this.GHTSubTestEnd(); }
protected internal void SetUnitAttribute(string attribute, Unit value) { if (value.IsEmpty) { this.RemoveAttribute(attribute); } else { UnitType type = value.Type; if ((type != UnitType.Pixel) && (type != UnitType.Percentage)) { throw new ArgumentException("Only pixel and percent values are allowed here."); } this.SetAttribute(attribute, value.ToString(CultureInfo.InvariantCulture)); } }
public HtmlAttributeManager Padding(Unit padding) { return Style(HtmlTextWriterStyle.Padding, padding.ToString()); }
public HtmlAttributeManager Right(Unit position) { return Right(position.ToString()); }
public HtmlAttributeManager PaddingRight(Unit padding) { return PaddingRight(padding.ToString()); }
public HtmlAttributeManager Bottom(Unit position) { return Bottom(position.ToString()); }
protected override void RenderMenuItem (HtmlTextWriter writer, MenuItem item, bool vertical, bool notLast, bool isFirst, OwnerContext oc) { Menu owner = Owner; string clientID = oc.ClientID; bool displayChildren = owner.DisplayChildren (item); bool dynamicChildren = displayChildren && (item.Depth + 1 >= oc.StaticDisplayLevels); bool isDynamicItem = IsDynamicItem (owner, item); bool isVertical = oc.IsVertical || isDynamicItem; Unit itemSpacing = owner.GetItemSpacing (item, isDynamicItem); if (itemSpacing != Unit.Empty && (item.Depth > 0 || !isFirst)) RenderMenuItemSpacing (writer, itemSpacing, isVertical); if(!String.IsNullOrEmpty(item.ToolTip)) writer.AddAttribute (HtmlTextWriterAttribute.Title, item.ToolTip); if (isVertical) writer.RenderBeginTag (HtmlTextWriterTag.Tr); string parentId = isDynamicItem ? "'" + item.Parent.Path + "'" : "null"; if (dynamicChildren) { writer.AddAttribute ("onmouseover", "javascript:Menu_OverItem ('" + clientID + "','" + item.Path + "'," + parentId + ")"); writer.AddAttribute ("onmouseout", "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "')"); } else if (isDynamicItem) { writer.AddAttribute ("onmouseover", "javascript:Menu_OverDynamicLeafItem ('" + clientID + "','" + item.Path + "'," + parentId + ")"); writer.AddAttribute ("onmouseout", "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "'," + parentId + ")"); } else { writer.AddAttribute ("onmouseover", "javascript:Menu_OverStaticLeafItem ('" + clientID + "','" + item.Path + "')"); writer.AddAttribute ("onmouseout", "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "')"); } writer.RenderBeginTag (HtmlTextWriterTag.Td); // Top separator image if (isDynamicItem) RenderSeparatorImage (owner, writer, oc.DynamicTopSeparatorImageUrl, false); else RenderSeparatorImage (owner, writer, oc.StaticTopSeparatorImageUrl, false); // Menu item box MenuItemStyle style = new MenuItemStyle (); if (oc.Header != null) { // styles are registered if (!isDynamicItem && oc.StaticMenuItemStyle != null) { AddCssClass (style, oc.StaticMenuItemStyle.CssClass); AddCssClass (style, oc.StaticMenuItemStyle.RegisteredCssClass); } if (isDynamicItem && oc.DynamicMenuItemStyle != null) { AddCssClass (style, oc.DynamicMenuItemStyle.CssClass); AddCssClass (style, oc.DynamicMenuItemStyle.RegisteredCssClass); } if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) { AddCssClass (style, oc.LevelMenuItemStyles [item.Depth].CssClass); AddCssClass (style, oc.LevelMenuItemStyles [item.Depth].RegisteredCssClass); } if (item == oc.SelectedItem) { if (!isDynamicItem && oc.StaticSelectedStyle != null) { AddCssClass (style, oc.StaticSelectedStyle.CssClass); AddCssClass (style, oc.StaticSelectedStyle.RegisteredCssClass); } if (isDynamicItem && oc.DynamicSelectedStyle != null) { AddCssClass (style, oc.DynamicSelectedStyle.CssClass); AddCssClass (style, oc.DynamicSelectedStyle.RegisteredCssClass); } if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) { AddCssClass (style, oc.LevelSelectedStyles [item.Depth].CssClass); AddCssClass (style, oc.LevelSelectedStyles [item.Depth].RegisteredCssClass); } } } else { // styles are not registered if (!isDynamicItem && oc.StaticMenuItemStyle != null) style.CopyFrom (oc.StaticMenuItemStyle); if (isDynamicItem && oc.DynamicMenuItemStyle != null) style.CopyFrom (oc.DynamicMenuItemStyle); if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) style.CopyFrom (oc.LevelMenuItemStyles [item.Depth]); if (item == oc.SelectedItem) { if (!isDynamicItem && oc.StaticSelectedStyle != null) style.CopyFrom (oc.StaticSelectedStyle); if (isDynamicItem && oc.DynamicSelectedStyle != null) style.CopyFrom (oc.DynamicSelectedStyle); if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) style.CopyFrom (oc.LevelSelectedStyles [item.Depth]); } } style.AddAttributesToRender (writer); writer.AddAttribute ("id", GetItemClientId (clientID, item, "i")); writer.AddAttribute ("cellpadding", "0", false); writer.AddAttribute ("cellspacing", "0", false); writer.AddAttribute ("border", "0", false); writer.AddAttribute ("width", "100%", false); writer.RenderBeginTag (HtmlTextWriterTag.Table); writer.RenderBeginTag (HtmlTextWriterTag.Tr); // Menu item text if (isVertical) writer.AddStyleAttribute (HtmlTextWriterStyle.Width, "100%"); if (!owner.ItemWrap) writer.AddStyleAttribute ("white-space", "nowrap"); writer.RenderBeginTag (HtmlTextWriterTag.Td); RenderItemHref (owner, writer, item); Style linkStyle = new Style (); if (oc.Header != null) { // styles are registered AddCssClass (linkStyle, oc.ControlLinkStyle.RegisteredCssClass); if (!isDynamicItem && oc.StaticMenuItemStyle != null) { AddCssClass (linkStyle, oc.StaticMenuItemStyle.CssClass); AddCssClass (linkStyle, oc.StaticMenuItemLinkStyle.RegisteredCssClass); } if (isDynamicItem && oc.DynamicMenuItemStyle != null) { AddCssClass (linkStyle, oc.DynamicMenuItemStyle.CssClass); AddCssClass (linkStyle, oc.DynamicMenuItemLinkStyle.RegisteredCssClass); } if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) { AddCssClass (linkStyle, oc.LevelMenuItemStyles [item.Depth].CssClass); AddCssClass (linkStyle, oc.LevelMenuItemLinkStyles [item.Depth].RegisteredCssClass); } if (item == oc.SelectedItem) { if (!isDynamicItem && oc.StaticSelectedStyle != null) { AddCssClass (linkStyle, oc.StaticSelectedStyle.CssClass); AddCssClass (linkStyle, oc.StaticSelectedLinkStyle.RegisteredCssClass); } if (isDynamicItem && oc.DynamicSelectedStyle != null) { AddCssClass (linkStyle, oc.DynamicSelectedStyle.CssClass); AddCssClass (linkStyle, oc.DynamicSelectedLinkStyle.RegisteredCssClass); } if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) { AddCssClass (linkStyle, oc.LevelSelectedStyles [item.Depth].CssClass); AddCssClass (linkStyle, oc.LevelSelectedLinkStyles [item.Depth].RegisteredCssClass); } } } else { // styles are not registered linkStyle.CopyFrom (oc.ControlLinkStyle); if (!isDynamicItem && oc.StaticMenuItemStyle != null) linkStyle.CopyFrom (oc.StaticMenuItemLinkStyle); if (isDynamicItem && oc.DynamicMenuItemStyle != null) linkStyle.CopyFrom (oc.DynamicMenuItemLinkStyle); if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) linkStyle.CopyFrom (oc.LevelMenuItemLinkStyles [item.Depth]); if (item == oc.SelectedItem) { if (!isDynamicItem && oc.StaticSelectedStyle != null) linkStyle.CopyFrom (oc.StaticSelectedLinkStyle); if (isDynamicItem && oc.DynamicSelectedStyle != null) linkStyle.CopyFrom (oc.DynamicSelectedLinkStyle); if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) linkStyle.CopyFrom (oc.LevelSelectedLinkStyles [item.Depth]); } linkStyle.AlwaysRenderTextDecoration = true; } linkStyle.AddAttributesToRender (writer); writer.AddAttribute ("id", GetItemClientId (clientID, item, "l")); if (item.Depth > 0 && !isDynamicItem) { double value; Unit unit = oc.StaticSubMenuIndent; if (unit == Unit.Empty) value = 16; else value = unit.Value; Unit indent = new Unit (value * item.Depth, oc.StaticSubMenuIndent.Type); writer.AddStyleAttribute (HtmlTextWriterStyle.MarginLeft, indent.ToString ()); } writer.RenderBeginTag (HtmlTextWriterTag.A); owner.RenderItemContent (writer, item, isDynamicItem); writer.RenderEndTag (); // A writer.RenderEndTag (); // TD // Popup image if (dynamicChildren) { string popOutImage = GetPopOutImage (owner, item, isDynamicItem); if (popOutImage != null) { writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.AddAttribute ("src", owner.ResolveClientUrl (popOutImage)); writer.AddAttribute ("border", "0"); string toolTip = String.Format (isDynamicItem ? oc.DynamicPopOutImageTextFormatString : oc.StaticPopOutImageTextFormatString, item.Text); writer.AddAttribute (HtmlTextWriterAttribute.Alt, toolTip); writer.RenderBeginTag (HtmlTextWriterTag.Img); writer.RenderEndTag (); // IMG writer.RenderEndTag (); // TD } } writer.RenderEndTag (); // TR writer.RenderEndTag (); // TABLE writer.RenderEndTag (); // TD if (!isVertical && itemSpacing == Unit.Empty && (notLast || (displayChildren && !dynamicChildren))) { writer.AddStyleAttribute ("width", "3px"); writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.RenderEndTag (); } // Bottom separator image string separatorImg = item.SeparatorImageUrl; if (separatorImg.Length == 0) { if (isDynamicItem) separatorImg = oc.DynamicBottomSeparatorImageUrl; else separatorImg = oc.StaticBottomSeparatorImageUrl; } if (separatorImg.Length > 0) { if (!isVertical) writer.RenderBeginTag (HtmlTextWriterTag.Td); RenderSeparatorImage (owner, writer, separatorImg, false); if (!isVertical) writer.RenderEndTag (); // TD } if (isVertical) writer.RenderEndTag (); // TR if (itemSpacing != Unit.Empty) RenderMenuItemSpacing (writer, itemSpacing, isVertical); // Submenu if (displayChildren && !dynamicChildren) { if (isVertical) writer.RenderBeginTag (HtmlTextWriterTag.Tr); writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.AddAttribute ("width", "100%"); owner.RenderMenu (writer, item.ChildItems, vertical, false, item.Depth + 1, notLast); if (item.Depth + 2 == oc.StaticDisplayLevels) owner.RenderDynamicMenu (writer, item.ChildItems); writer.RenderEndTag (); // TD if (isVertical) writer.RenderEndTag (); // TR } }
public HtmlAttributeManager Left(Unit position) { return Left(position.ToString()); }
void RenderMenuItem (HtmlTextWriter writer, MenuItem item, bool notLast, bool isFirst) { bool displayChildren = DisplayChildren (item); bool dynamicChildren = displayChildren && (item.Depth + 1 >= StaticDisplayLevels); bool isDynamicItem = IsDynamicItem (item); bool vertical = (Orientation == Orientation.Vertical) || isDynamicItem; Unit itemSpacing = GetItemSpacing (item, isDynamicItem); if (itemSpacing != Unit.Empty && (item.Depth > 0 || !isFirst)) RenderMenuItemSpacing (writer, itemSpacing, vertical); if(!String.IsNullOrEmpty(item.ToolTip)) writer.AddAttribute (HtmlTextWriterAttribute.Title, item.ToolTip); if (vertical) writer.RenderBeginTag (HtmlTextWriterTag.Tr); string parentId = isDynamicItem ? "'" + item.Parent.Path + "'" : "null"; if (dynamicChildren) { writer.AddAttribute ("onmouseover", "javascript:Menu_OverItem ('" + ClientID + "','" + item.Path + "'," + parentId + ")"); writer.AddAttribute ("onmouseout", "javascript:Menu_OutItem ('" + ClientID + "','" + item.Path + "')"); } else if (isDynamicItem) { writer.AddAttribute ("onmouseover", "javascript:Menu_OverDynamicLeafItem ('" + ClientID + "','" + item.Path + "'," + parentId + ")"); writer.AddAttribute ("onmouseout", "javascript:Menu_OutItem ('" + ClientID + "','" + item.Path + "'," + parentId + ")"); } else { writer.AddAttribute ("onmouseover", "javascript:Menu_OverStaticLeafItem ('" + ClientID + "','" + item.Path + "')"); writer.AddAttribute ("onmouseout", "javascript:Menu_OutItem ('" + ClientID + "','" + item.Path + "')"); } writer.RenderBeginTag (HtmlTextWriterTag.Td); // Top separator image if (isDynamicItem && DynamicTopSeparatorImageUrl != "") { writer.AddAttribute ("src", ResolveClientUrl (DynamicTopSeparatorImageUrl)); writer.RenderBeginTag (HtmlTextWriterTag.Img); writer.RenderEndTag (); // IMG } else if (!isDynamicItem && StaticTopSeparatorImageUrl != "") { writer.AddAttribute ("src", ResolveClientUrl (StaticTopSeparatorImageUrl)); writer.RenderBeginTag (HtmlTextWriterTag.Img); writer.RenderEndTag (); // IMG } // Menu item box MenuItemStyle style = new MenuItemStyle (); if (Page.Header != null) { // styles are registered if (!isDynamicItem && staticMenuItemStyle != null) { AddCssClass (style, staticMenuItemStyle.CssClass); AddCssClass (style, staticMenuItemStyle.RegisteredCssClass); } if (isDynamicItem && dynamicMenuItemStyle != null) { AddCssClass (style, dynamicMenuItemStyle.CssClass); AddCssClass (style, dynamicMenuItemStyle.RegisteredCssClass); } if (levelMenuItemStyles != null && levelMenuItemStyles.Count > item.Depth) { AddCssClass (style, levelMenuItemStyles [item.Depth].CssClass); AddCssClass (style, levelMenuItemStyles [item.Depth].RegisteredCssClass); } if (item == SelectedItem) { if (!isDynamicItem && staticSelectedStyle != null) { AddCssClass (style, staticSelectedStyle.CssClass); AddCssClass (style, staticSelectedStyle.RegisteredCssClass); } if (isDynamicItem && dynamicSelectedStyle != null) { AddCssClass (style, dynamicSelectedStyle.CssClass); AddCssClass (style, dynamicSelectedStyle.RegisteredCssClass); } if (levelSelectedStyles != null && levelSelectedStyles.Count > item.Depth) { AddCssClass (style, levelSelectedStyles [item.Depth].CssClass); AddCssClass (style, levelSelectedStyles [item.Depth].RegisteredCssClass); } } } else { // styles are not registered if (!isDynamicItem && staticMenuItemStyle != null) { style.CopyFrom (staticMenuItemStyle); } if (isDynamicItem && dynamicMenuItemStyle != null) { style.CopyFrom (dynamicMenuItemStyle); } if (levelMenuItemStyles != null && levelMenuItemStyles.Count > item.Depth) { style.CopyFrom (levelMenuItemStyles [item.Depth]); } if (item == SelectedItem) { if (!isDynamicItem && staticSelectedStyle != null) { style.CopyFrom (staticSelectedStyle); } if (isDynamicItem && dynamicSelectedStyle != null) { style.CopyFrom (dynamicSelectedStyle); } if (levelSelectedStyles != null && levelSelectedStyles.Count > item.Depth) { style.CopyFrom (levelSelectedStyles [item.Depth]); } } } style.AddAttributesToRender (writer); writer.AddAttribute ("id", GetItemClientId (item, "i")); writer.AddAttribute ("cellpadding", "0", false); writer.AddAttribute ("cellspacing", "0", false); writer.AddAttribute ("border", "0", false); writer.AddAttribute ("width", "100%", false); writer.RenderBeginTag (HtmlTextWriterTag.Table); writer.RenderBeginTag (HtmlTextWriterTag.Tr); // Menu item text if (vertical) writer.AddStyleAttribute (HtmlTextWriterStyle.Width, "100%"); if (!ItemWrap) writer.AddStyleAttribute ("white-space", "nowrap"); writer.RenderBeginTag (HtmlTextWriterTag.Td); RenderItemHref (writer, item); Style linkStyle = new Style (); if (Page.Header != null) { // styles are registered AddCssClass (linkStyle, ControlLinkStyle.RegisteredCssClass); if (!isDynamicItem && staticMenuItemStyle != null) { AddCssClass (linkStyle, staticMenuItemStyle.CssClass); AddCssClass (linkStyle, staticMenuItemLinkStyle.RegisteredCssClass); } if (isDynamicItem && dynamicMenuItemStyle != null) { AddCssClass (linkStyle, dynamicMenuItemStyle.CssClass); AddCssClass (linkStyle, dynamicMenuItemLinkStyle.RegisteredCssClass); } if (levelMenuItemStyles != null && levelMenuItemStyles.Count > item.Depth) { AddCssClass (linkStyle, levelMenuItemStyles [item.Depth].CssClass); AddCssClass (linkStyle, levelMenuItemLinkStyles [item.Depth].RegisteredCssClass); } if (item == SelectedItem) { if (!isDynamicItem && staticSelectedStyle != null) { AddCssClass (linkStyle, staticSelectedStyle.CssClass); AddCssClass (linkStyle, staticSelectedLinkStyle.RegisteredCssClass); } if (isDynamicItem && dynamicSelectedStyle != null) { AddCssClass (linkStyle, dynamicSelectedStyle.CssClass); AddCssClass (linkStyle, dynamicSelectedLinkStyle.RegisteredCssClass); } if (levelSelectedStyles != null && levelSelectedStyles.Count > item.Depth) { AddCssClass (linkStyle, levelSelectedStyles [item.Depth].CssClass); AddCssClass (linkStyle, levelSelectedLinkStyles [item.Depth].RegisteredCssClass); } } } else { // styles are not registered linkStyle.CopyFrom (ControlLinkStyle); if (!isDynamicItem && staticMenuItemStyle != null) { linkStyle.CopyFrom (staticMenuItemLinkStyle); } if (isDynamicItem && dynamicMenuItemStyle != null) { linkStyle.CopyFrom (dynamicMenuItemLinkStyle); } if (levelMenuItemStyles != null && levelMenuItemStyles.Count > item.Depth) { linkStyle.CopyFrom (levelMenuItemLinkStyles [item.Depth]); } if (item == SelectedItem) { if (!isDynamicItem && staticSelectedStyle != null) { linkStyle.CopyFrom (staticSelectedLinkStyle); } if (isDynamicItem && dynamicSelectedStyle != null) { linkStyle.CopyFrom (dynamicSelectedLinkStyle); } if (levelSelectedStyles != null && levelSelectedStyles.Count > item.Depth) { linkStyle.CopyFrom (levelSelectedLinkStyles [item.Depth]); } } linkStyle.AlwaysRenderTextDecoration = true; } linkStyle.AddAttributesToRender (writer); writer.AddAttribute ("id", GetItemClientId (item, "l")); if (item.Depth > 0 && !isDynamicItem) { Unit indent = new Unit (StaticSubMenuIndent.Value * item.Depth, StaticSubMenuIndent.Type); writer.AddStyleAttribute ("margin-left", indent.ToString ()); } writer.RenderBeginTag (HtmlTextWriterTag.A); RenderItemContent (writer, item, isDynamicItem); writer.RenderEndTag (); // A writer.RenderEndTag (); // TD // Popup image if (dynamicChildren) { string popOutImage = GetPopOutImage (item, isDynamicItem); if (popOutImage != null) { writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.AddAttribute ("src", ResolveClientUrl (popOutImage)); writer.AddAttribute ("border", "0"); string toolTip = String.Format (isDynamicItem ? DynamicPopOutImageTextFormatString : StaticPopOutImageTextFormatString, item.Text); writer.AddAttribute (HtmlTextWriterAttribute.Alt, toolTip); writer.RenderBeginTag (HtmlTextWriterTag.Img); writer.RenderEndTag (); // IMG writer.RenderEndTag (); // TD } } writer.RenderEndTag (); // TR writer.RenderEndTag (); // TABLE writer.RenderEndTag (); // TD if (!vertical && itemSpacing == Unit.Empty && (notLast || (displayChildren && !dynamicChildren))) { writer.AddStyleAttribute ("width", "3px"); writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.RenderEndTag (); } // Bottom separator image string separatorImg = item.SeparatorImageUrl; if (separatorImg.Length == 0) { if (isDynamicItem) separatorImg = DynamicBottomSeparatorImageUrl; else separatorImg = StaticBottomSeparatorImageUrl; } if (separatorImg.Length > 0) { if (!vertical) writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.AddAttribute ("src", ResolveClientUrl (separatorImg)); writer.RenderBeginTag (HtmlTextWriterTag.Img); writer.RenderEndTag (); // IMG if (!vertical) writer.RenderEndTag (); // TD } if (vertical) writer.RenderEndTag (); // TR if (itemSpacing != Unit.Empty) RenderMenuItemSpacing (writer, itemSpacing, vertical); // Submenu if (displayChildren && !dynamicChildren) { if (vertical) writer.RenderBeginTag (HtmlTextWriterTag.Tr); writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.AddAttribute ("width", "100%"); RenderMenu (writer, item.ChildItems, Orientation == Orientation.Vertical, false, item.Depth + 1, notLast); if (item.Depth + 2 == StaticDisplayLevels) RenderDynamicMenu (writer, item.ChildItems); writer.RenderEndTag (); // TD if (vertical) writer.RenderEndTag (); // TR } }
public HtmlAttributeManager Top(Unit position) { return Top(position.ToString()); }
public void ParseCultures () { // Test cultures where the decimal separator is not "." CultureInfo ci = new CultureInfo ("es-ES", false); Unit s1 = new Unit ("1,5cm", ci); Assert.AreEqual (s1.Type, UnitType.Cm, "C1"); Assert.AreEqual (s1.Value, 1.5, "C2"); Assert.AreEqual (s1.ToString (), "1.5cm", "A54"); Assert.AreEqual (s1.ToString (ci), "1,5cm", "A54"); }
public static void BuildScript(StringBuilder script, ITinyMceSettings config, string targetClientId, Unit width, Unit height) { if (script == null) { return; } if (config == null) { return; } script.Append("tinymce.init({"); if (config.Inline) { script.Append("inline:true,"); } script.Append("selector:\"#" + targetClientId + "\""); //http://www.tinymce.com/wiki.php/Configuration if(width != Unit.Empty) { script.Append(",width:\"" + width.ToString() + "\""); } if (height != Unit.Empty) { script.Append(",height: \"" + height.ToString() + "\""); } if(!config.ConvertUrls) { script.Append(",convert_urls:false"); } if (config.NoWrap) { script.Append(",nowrap:true"); } if (config.DisableMenuBar) { script.Append(",menubar:false"); } else { script.Append(",menubar:'" + config.Menubar + "'"); } if ((!config.ShowStatusbar)||(config.Inline)) { script.Append(",statusbar:false"); } if (config.ForcePasteAsPlainText) { script.Append(",paste_as_text:true"); } if(config.RemovedMenuItems.Length > 0) { script.Append(",removed_menuitems: '" + config.RemovedMenuItems + "'"); } script.Append(",schema:'html5'"); if (config.CustomToolbarElementClientId.Length > 0) { script.Append(",fixed_toolbar_container:'" + config.CustomToolbarElementClientId + "'"); } if (config.EnableBrowserSpellCheck) { script.Append(",browser_spellcheck:true "); } if (config.AutoLocalize) { CultureInfo culture; if (WebConfigSettings.UseCultureOverride) { culture = SiteUtils.GetDefaultUICulture(); } else { culture = CultureInfo.CurrentUICulture; } config.Language = GetSupportedLangCode(culture.Name, culture.TwoLetterISOLanguageName); if (culture.TextInfo.IsRightToLeft) { config.TextDirection = "rtl"; } } if (config.Language.Length > 0) { script.Append(",language:\"" + config.Language + "\""); } if (config.ExtendedValidElements.Length > 0) { script.Append(",extended_valid_elements:\"" + config.ExtendedValidElements + "\""); } if ((config.TextDirection != "ltr") && (config.TextDirection.Length > 0)) { script.Append(",directionality:'" + config.TextDirection + "'"); } if (!config.EnableObjectResizing) { script.Append(",object_resizing:false"); } //http://www.tinymce.com/wiki.php/Plugins if (config.Plugins.Length > 0) { script.Append(",plugins:\"" + config.Plugins + "\""); } if (config.Theme != "modern") { script.Append(",theme:\"" + config.Theme + "\""); } if (config.Skin != "lightgray") { script.Append(",skin:\"" + config.Skin + "\""); } if (config.UnDoLevels != -1) { script.Append(",custom_undo_redo_levels:" + config.UnDoLevels.ToInvariantString()); } if (config.Toolbar1Buttons.Length > 0) { script.Append(",toolbar1:\"" + config.Toolbar1Buttons + "\""); } if (config.Toolbar2Buttons.Length > 0) { script.Append(",toolbar2:\"" + config.Toolbar2Buttons + "\""); } if (config.Toolbar3Buttons.Length > 0) { script.Append(",toolbar3:\"" + config.Toolbar3Buttons + "\""); } if (config.EnableImageAdvancedTab) { script.Append(",image_advtab:true"); } if (config.EditorAreaCSS.Length > 0) { script.Append(",content_css:\"" + config.EditorAreaCSS + "\""); } if (config.EditorBodyCssClass.Length > 0) { script.Append(",body_class:\"" + config.EditorBodyCssClass + "\""); } if (config.AutoFocus) { script.Append(",auto_focus:\"" + targetClientId + "\" "); } if (config.TemplatesUrl.Length > 0) { script.Append(",templates: \"" + config.TemplatesUrl + "\""); } if (config.StyleFormats.Length > 0) { script.Append(",style_formats:" + config.StyleFormats); } if (config.EmotionsBaseUrl.Length > 0) { script.Append(",emotions_images_url:'" + config.EmotionsBaseUrl + "'"); } if (config.OnSaveCallback.Length > 0) { script.Append(",save_onsavecallback:" + config.OnSaveCallback); if(config.SaveEnableWhenDirty) { script.Append(",save_enablewhendirty:true"); } } if (config.DropFileUploadUrl.Length > 0) { script.Append(",dropFileUploadUrl:'" + config.DropFileUploadUrl + "'"); } if ((config.FileManagerUrl.Length > 0)) { script.Append(",file_browser_callback: function(field_name, url, type, win) { "); script.Append("tinyMCE.activeEditor.windowManager.open({"); script.Append("url:'" + config.FileManagerUrl + "' + '?ed=tmc&type=' + type, "); script.Append("title:'" + Resource.FileBrowser.HtmlEscapeQuotes() + "',"); script.Append("width:" + config.FileDialogWidth.ToInvariantString() + ","); script.Append("height:" + config.FileDialogHeight.ToInvariantString()); //script.Append(",resizable: true"); // doesn't seem to work //script.Append("inline : 'yes',"); // not needed in 4.x I guess //script.Append(" close_previous : 'no'"); // not needed in 4.x I guess script.Append("}, {"); script.Append("oninsert: function(newurl) {win.document.getElementById(field_name).value = newurl;}"); script.Append("}); "); script.Append("return false;"); script.Append("}"); } script.Append(",setup:function(editor) {"); if (config.GlobarVarToAssignEditor.Length > 0) { script.Append(config.GlobarVarToAssignEditor + " = editor; "); } if (config.PromptOnNavigationWithUnsavedChanges) { // autosave plugin also prompts so don't need this if it is used if(!config.Plugins.Contains("autosave,")) { script.Append("editor.on('change', function(e) {"); script.Append("hookupGoodbyePrompt(\"" + Resource.UnSavedChangesPrompt.HtmlEscapeQuotes().RemoveLineBreaks() + "\"); "); script.Append("});"); } } script.Append("}"); //end setup script.Append("});"); }
public void UnitConstructors () { Unit a1 = new Unit (1.0); Assert.AreEqual (a1.Type, UnitType.Pixel, "A1"); Assert.AreEqual (a1.Value, 1.0, "A2"); Assert.AreEqual ("1px", a1.ToString (), "A2.1"); Unit a2 = new Unit (1); Assert.AreEqual (a2.Type, UnitType.Pixel, "A3"); Assert.AreEqual (a1.Value, 1.0, "A4"); Assert.AreEqual ("1px", a1.ToString (), "A4.1"); Unit a3 = new Unit (32767); Assert.AreEqual (a3.Type, UnitType.Pixel, "A5"); Assert.AreEqual (a3.Value, 32767.0, "A6"); Assert.AreEqual ("32767px", a3.ToString (), "A6.1"); a3 = new Unit (-32768); Assert.AreEqual (a3.Type, UnitType.Pixel, "A7"); Assert.AreEqual (a3.Value, -32768.0, "A8"); Assert.AreEqual ("-32768px", a3.ToString (), "A8.1"); // // String constructor // Unit s1 = new Unit ("-45cm"); Assert.AreEqual (s1.Type, UnitType.Cm, "A9"); Assert.AreEqual (s1.Value, -45, "A10"); Assert.AreEqual ("-45cm", s1.ToString (), "A10.1"); s1 = new Unit ("\t-45cm"); Assert.AreEqual (s1.Type, UnitType.Cm, "A11"); Assert.AreEqual (s1.Value, -45, "A12"); Assert.AreEqual ("-45cm", s1.ToString (), "A12.1"); s1 = new Unit ("45\tcm"); Assert.AreEqual (s1.Type, UnitType.Cm, "A13"); Assert.AreEqual (s1.Value, 45, "A14"); s1 = new Unit ("45\tcm"); Assert.AreEqual (s1.Type, UnitType.Cm, "A15"); Assert.AreEqual (s1.Value, 45, "A16"); s1 = new Unit (null); Assert.AreEqual (s1.Type, UnitType.Pixel, "A17"); Assert.AreEqual (s1.Value, 0, "A18"); s1 = new Unit ("-45"); Assert.AreEqual (s1.Type, UnitType.Pixel, "A19"); Assert.AreEqual (s1.Value, -45, "A20"); s1 = new Unit ("-45%"); Assert.AreEqual (s1.Type, UnitType.Percentage, "A21"); Assert.AreEqual (s1.Value, -45, "A22"); Assert.AreEqual ("-45%", s1.ToString (), "A22.1"); s1 = new Unit ("-45% \t "); Assert.AreEqual (s1.Type, UnitType.Percentage, "A23"); Assert.AreEqual (s1.Value, -45, "A24"); s1 = new Unit ("-45 % \t "); Assert.AreEqual (s1.Type, UnitType.Percentage, "A25"); Assert.AreEqual (s1.Value, -45, "A26"); s1 = new Unit ("45in"); Assert.AreEqual (s1.Type, UnitType.Inch, "A27"); Assert.AreEqual (s1.Value, 45, "A28"); Assert.AreEqual ("45in", s1.ToString (), "A28.1"); s1 = new Unit ("45cm"); Assert.AreEqual (s1.Type, UnitType.Cm, "A29"); Assert.AreEqual (s1.Value, 45, "A30"); Assert.AreEqual ("45cm", s1.ToString (), "A30.1"); s1 = new Unit ("45pt"); Assert.AreEqual (s1.Type, UnitType.Point, "A31"); Assert.AreEqual (s1.Value, 45, "A32"); Assert.AreEqual ("45pt", s1.ToString (), "A32.1"); s1 = new Unit ("45pc"); Assert.AreEqual (s1.Type, UnitType.Pica, "A33"); Assert.AreEqual (s1.Value, 45, "A34"); Assert.AreEqual ("45pc", s1.ToString (), "A34.1"); s1 = new Unit ("45mm"); Assert.AreEqual (s1.Type, UnitType.Mm, "A35"); Assert.AreEqual (s1.Value, 45, "A36"); Assert.AreEqual ("45mm", s1.ToString (), "A36.1"); s1 = new Unit ("45em"); Assert.AreEqual (s1.Type, UnitType.Em, "A37"); Assert.AreEqual (s1.Value, 45, "A38"); Assert.AreEqual ("45em", s1.ToString (), "A38.1"); s1 = new Unit ("45ex"); Assert.AreEqual (s1.Type, UnitType.Ex, "A39"); Assert.AreEqual (s1.Value, 45, "A40"); Assert.AreEqual ("45ex", s1.ToString (), "A40.1"); s1 = new Unit ("45px"); Assert.AreEqual (s1.Type, UnitType.Pixel, "A41"); Assert.AreEqual (s1.Value, 45, "A42"); Assert.AreEqual ("45px", s1.ToString (), "A42.1"); s1 = new Unit ("1.75cm"); Assert.AreEqual (s1.Type, UnitType.Cm, "A43"); Assert.AreEqual (s1.Value, 1.75, "A44"); s1 = new Unit ("1.75%"); Assert.AreEqual (s1.Type, UnitType.Percentage, "A45"); Assert.AreEqual (s1.Value, 1.75, "A46"); s1 = new Unit (null); Assert.AreEqual (s1.Type, UnitType.Pixel, "A47"); Assert.AreEqual (s1.Value, 0, "A48"); Assert.AreEqual (s1.IsEmpty, true, "A49"); Assert.AreEqual (s1.ToString (), "", "A50"); s1 = new Unit (""); Assert.AreEqual (s1.Type, UnitType.Pixel, "A51"); Assert.AreEqual (s1.Value, 0, "A52"); Assert.AreEqual (s1.IsEmpty, true, "A53"); Assert.AreEqual (s1.ToString (), "", "A54"); s1 = new Unit ("45.75cm"); Assert.AreEqual (s1.Type, UnitType.Cm, "A55"); Assert.AreEqual (s1.Value, 45.75, "A56"); Assert.AreEqual ("45.75cm", s1.ToString (), "A57"); a3 = new Unit (1.5); Assert.AreEqual (UnitType.Pixel, a3.Type, "A58"); Assert.AreEqual (1.0, a3.Value, "A59"); s1 = new Unit (".9em"); Assert.AreEqual (s1.Type, UnitType.Em, "B1"); Assert.AreEqual (s1.Value, 0.9, "B2"); Assert.AreEqual ("0.9em", s1.ToString (), "B3"); }
private static void AddStyleUnit(StringBuilder sb, string property, Unit unit) { if (!unit.IsEmpty) sb.AppendFormat("{0}:{1};", property, unit.ToString(CultureInfo.InvariantCulture)); }
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)); } }
public static void AddJsStyleUnit(StringBuilder sb, string objName, string property, Unit unit) { if (!unit.IsEmpty) sb.AppendFormat("{0}.style.{1} = '{2}';", objName, property, unit.ToString(CultureInfo.InvariantCulture)); }
void RenderMenuItemSpacing (HtmlTextWriter writer, Unit itemSpacing) { #if !NET_4_0 writer.AddStyleAttribute (HtmlTextWriterStyle.Height, itemSpacing.ToString ()); #endif writer.RenderBeginTag (HtmlTextWriterTag.Tr); writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.RenderEndTag (); writer.RenderEndTag (); }
/// <summary> /// Add width attribute /// </summary> /// <param name="width"></param> /// <returns></returns> public HtmlStyleBuilder Width(Unit width) { MergeAttribute("width", width.ToString(), true); return this; }
protected override void RenderMenuItem(HtmlTextWriter writer, MenuItem item, bool vertical, bool notLast, bool isFirst, OwnerContext oc) { Menu owner = Owner; string clientID = oc.ClientID; bool displayChildren = owner.DisplayChildren(item); bool dynamicChildren = displayChildren && (item.Depth + 1 >= oc.StaticDisplayLevels); bool isDynamicItem = IsDynamicItem(owner, item); bool isVertical = oc.IsVertical || isDynamicItem; Unit itemSpacing = owner.GetItemSpacing(item, isDynamicItem); if (itemSpacing != Unit.Empty && (item.Depth > 0 || !isFirst)) { RenderMenuItemSpacing(writer, itemSpacing, isVertical); } if (!String.IsNullOrEmpty(item.ToolTip)) { writer.AddAttribute(HtmlTextWriterAttribute.Title, item.ToolTip); } if (isVertical) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); } string parentId = isDynamicItem ? "'" + item.Parent.Path + "'" : "null"; if (dynamicChildren) { writer.AddAttribute("onmouseover", "javascript:Menu_OverItem ('" + clientID + "','" + item.Path + "'," + parentId + ")"); writer.AddAttribute("onmouseout", "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "')"); } else if (isDynamicItem) { writer.AddAttribute("onmouseover", "javascript:Menu_OverDynamicLeafItem ('" + clientID + "','" + item.Path + "'," + parentId + ")"); writer.AddAttribute("onmouseout", "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "'," + parentId + ")"); } else { writer.AddAttribute("onmouseover", "javascript:Menu_OverStaticLeafItem ('" + clientID + "','" + item.Path + "')"); writer.AddAttribute("onmouseout", "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "')"); } writer.RenderBeginTag(HtmlTextWriterTag.Td); // Top separator image if (isDynamicItem) { RenderSeparatorImage(owner, writer, oc.DynamicTopSeparatorImageUrl, false); } else { RenderSeparatorImage(owner, writer, oc.StaticTopSeparatorImageUrl, false); } // Menu item box MenuItemStyle style = new MenuItemStyle(); if (oc.Header != null) { // styles are registered if (!isDynamicItem && oc.StaticMenuItemStyle != null) { AddCssClass(style, oc.StaticMenuItemStyle.CssClass); AddCssClass(style, oc.StaticMenuItemStyle.RegisteredCssClass); } if (isDynamicItem && oc.DynamicMenuItemStyle != null) { AddCssClass(style, oc.DynamicMenuItemStyle.CssClass); AddCssClass(style, oc.DynamicMenuItemStyle.RegisteredCssClass); } if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) { AddCssClass(style, oc.LevelMenuItemStyles [item.Depth].CssClass); AddCssClass(style, oc.LevelMenuItemStyles [item.Depth].RegisteredCssClass); } if (item == oc.SelectedItem) { if (!isDynamicItem && oc.StaticSelectedStyle != null) { AddCssClass(style, oc.StaticSelectedStyle.CssClass); AddCssClass(style, oc.StaticSelectedStyle.RegisteredCssClass); } if (isDynamicItem && oc.DynamicSelectedStyle != null) { AddCssClass(style, oc.DynamicSelectedStyle.CssClass); AddCssClass(style, oc.DynamicSelectedStyle.RegisteredCssClass); } if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) { AddCssClass(style, oc.LevelSelectedStyles [item.Depth].CssClass); AddCssClass(style, oc.LevelSelectedStyles [item.Depth].RegisteredCssClass); } } } else { // styles are not registered if (!isDynamicItem && oc.StaticMenuItemStyle != null) { style.CopyFrom(oc.StaticMenuItemStyle); } if (isDynamicItem && oc.DynamicMenuItemStyle != null) { style.CopyFrom(oc.DynamicMenuItemStyle); } if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) { style.CopyFrom(oc.LevelMenuItemStyles [item.Depth]); } if (item == oc.SelectedItem) { if (!isDynamicItem && oc.StaticSelectedStyle != null) { style.CopyFrom(oc.StaticSelectedStyle); } if (isDynamicItem && oc.DynamicSelectedStyle != null) { style.CopyFrom(oc.DynamicSelectedStyle); } if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) { style.CopyFrom(oc.LevelSelectedStyles [item.Depth]); } } } style.AddAttributesToRender(writer); writer.AddAttribute("id", GetItemClientId(clientID, item, "i")); writer.AddAttribute("cellpadding", "0", false); writer.AddAttribute("cellspacing", "0", false); writer.AddAttribute("border", "0", false); writer.AddAttribute("width", "100%", false); writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); // Menu item text if (isVertical) { writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); } if (!owner.ItemWrap) { writer.AddStyleAttribute("white-space", "nowrap"); } writer.RenderBeginTag(HtmlTextWriterTag.Td); RenderItemHref(owner, writer, item); Style linkStyle = new Style(); if (oc.Header != null) { // styles are registered AddCssClass(linkStyle, oc.ControlLinkStyle.RegisteredCssClass); if (!isDynamicItem && oc.StaticMenuItemStyle != null) { AddCssClass(linkStyle, oc.StaticMenuItemStyle.CssClass); AddCssClass(linkStyle, oc.StaticMenuItemLinkStyle.RegisteredCssClass); } if (isDynamicItem && oc.DynamicMenuItemStyle != null) { AddCssClass(linkStyle, oc.DynamicMenuItemStyle.CssClass); AddCssClass(linkStyle, oc.DynamicMenuItemLinkStyle.RegisteredCssClass); } if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) { AddCssClass(linkStyle, oc.LevelMenuItemStyles [item.Depth].CssClass); AddCssClass(linkStyle, oc.LevelMenuItemLinkStyles [item.Depth].RegisteredCssClass); } if (item == oc.SelectedItem) { if (!isDynamicItem && oc.StaticSelectedStyle != null) { AddCssClass(linkStyle, oc.StaticSelectedStyle.CssClass); AddCssClass(linkStyle, oc.StaticSelectedLinkStyle.RegisteredCssClass); } if (isDynamicItem && oc.DynamicSelectedStyle != null) { AddCssClass(linkStyle, oc.DynamicSelectedStyle.CssClass); AddCssClass(linkStyle, oc.DynamicSelectedLinkStyle.RegisteredCssClass); } if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) { AddCssClass(linkStyle, oc.LevelSelectedStyles [item.Depth].CssClass); AddCssClass(linkStyle, oc.LevelSelectedLinkStyles [item.Depth].RegisteredCssClass); } } } else { // styles are not registered linkStyle.CopyFrom(oc.ControlLinkStyle); if (!isDynamicItem && oc.StaticMenuItemStyle != null) { linkStyle.CopyFrom(oc.StaticMenuItemLinkStyle); } if (isDynamicItem && oc.DynamicMenuItemStyle != null) { linkStyle.CopyFrom(oc.DynamicMenuItemLinkStyle); } if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) { linkStyle.CopyFrom(oc.LevelMenuItemLinkStyles [item.Depth]); } if (item == oc.SelectedItem) { if (!isDynamicItem && oc.StaticSelectedStyle != null) { linkStyle.CopyFrom(oc.StaticSelectedLinkStyle); } if (isDynamicItem && oc.DynamicSelectedStyle != null) { linkStyle.CopyFrom(oc.DynamicSelectedLinkStyle); } if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) { linkStyle.CopyFrom(oc.LevelSelectedLinkStyles [item.Depth]); } } linkStyle.AlwaysRenderTextDecoration = true; } linkStyle.AddAttributesToRender(writer); writer.AddAttribute("id", GetItemClientId(clientID, item, "l")); if (item.Depth > 0 && !isDynamicItem) { double value; #if NET_4_0 Unit unit = oc.StaticSubMenuIndent; if (unit == Unit.Empty) { value = 16; } else { value = unit.Value; } #else value = oc.StaticSubMenuIndent.Value; #endif Unit indent = new Unit(value * item.Depth, oc.StaticSubMenuIndent.Type); writer.AddStyleAttribute(HtmlTextWriterStyle.MarginLeft, indent.ToString()); } writer.RenderBeginTag(HtmlTextWriterTag.A); owner.RenderItemContent(writer, item, isDynamicItem); writer.RenderEndTag(); // A writer.RenderEndTag(); // TD // Popup image if (dynamicChildren) { string popOutImage = GetPopOutImage(owner, item, isDynamicItem); if (popOutImage != null) { writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute("src", owner.ResolveClientUrl(popOutImage)); writer.AddAttribute("border", "0"); string toolTip = String.Format(isDynamicItem ? oc.DynamicPopOutImageTextFormatString : oc.StaticPopOutImageTextFormatString, item.Text); writer.AddAttribute(HtmlTextWriterAttribute.Alt, toolTip); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); // IMG writer.RenderEndTag(); // TD } } writer.RenderEndTag(); // TR writer.RenderEndTag(); // TABLE writer.RenderEndTag(); // TD if (!isVertical && itemSpacing == Unit.Empty && (notLast || (displayChildren && !dynamicChildren))) { writer.AddStyleAttribute("width", "3px"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderEndTag(); } // Bottom separator image string separatorImg = item.SeparatorImageUrl; if (separatorImg.Length == 0) { if (isDynamicItem) { separatorImg = oc.DynamicBottomSeparatorImageUrl; } else { separatorImg = oc.StaticBottomSeparatorImageUrl; } } if (separatorImg.Length > 0) { if (!isVertical) { writer.RenderBeginTag(HtmlTextWriterTag.Td); } RenderSeparatorImage(owner, writer, separatorImg, false); if (!isVertical) { writer.RenderEndTag(); // TD } } if (isVertical) { writer.RenderEndTag(); // TR } if (itemSpacing != Unit.Empty) { RenderMenuItemSpacing(writer, itemSpacing, isVertical); } // Submenu if (displayChildren && !dynamicChildren) { if (isVertical) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); } writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute("width", "100%"); owner.RenderMenu(writer, item.ChildItems, vertical, false, item.Depth + 1, notLast); if (item.Depth + 2 == oc.StaticDisplayLevels) { owner.RenderDynamicMenu(writer, item.ChildItems); } writer.RenderEndTag(); // TD if (isVertical) { writer.RenderEndTag(); // TR } } }
/// <summary> /// Add height attribute /// </summary> /// <param name="height"></param> /// <returns></returns> public HtmlStyleBuilder Height(Unit height) { MergeAttribute("height", height.ToString(), true); return this; }
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) })); } }
void RenderMenuItemSpacing (HtmlTextWriter writer, Unit itemSpacing) { writer.AddStyleAttribute ("height", itemSpacing.ToString ()); writer.RenderBeginTag (HtmlTextWriterTag.Tr); writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.RenderEndTag (); writer.RenderEndTag (); }
public HtmlAttributeManager Height(Unit unit) { return Height(unit.ToString()); }
/// <summary> /// Write a new Column Header /// </summary> /// <param name="writer">HtmlTextWriter to write to </param> /// <param name="cssClass">CssClass</param> /// <param name="columnWidth">Column Width in Units</param> /// <param name="headerText">Header text</param> /// <param name="display">Should the header be displayed</param> /// <param name="columnSpan">Column Span</param> private static void WriteColumnHeader(HtmlTextWriter writer, string cssClass, Unit columnWidth, string headerText, bool display, int columnSpan) { // DrugDetails Column Header writer.WriteBeginTag(HtmlTextWriterTag.Th.ToString()); if (columnSpan > 1) { writer.WriteAttribute("colspan", "3"); } writer.WriteAttribute("class", cssClass); writer.WriteAttribute("nowrap", "nowrap"); writer.Write(" style=\""); writer.WriteStyleAttribute(HtmlTextWriterStyle.Width.ToString(), columnWidth.ToString()); if (!display) { writer.WriteStyleAttribute(HtmlTextWriterStyle.Display.ToString(), "none"); } writer.Write(HtmlTextWriter.DoubleQuoteChar); writer.Write(HtmlTextWriter.TagRightChar); writer.WriteBeginTag(HtmlTextWriterTag.Div.ToString()); writer.Write(" style=\""); writer.WriteStyleAttribute("white-space", "nowrap"); writer.WriteStyleAttribute("word-break", "none"); writer.Write(HtmlTextWriter.DoubleQuoteChar); writer.Write(HtmlTextWriter.TagRightChar); writer.Write(AntiXss.HtmlEncode(headerText)); writer.WriteEndTag(HtmlTextWriterTag.Div.ToString()); writer.WriteEndTag(HtmlTextWriterTag.Th.ToString()); }
public HtmlAttributeManager Width(Unit unit) { return Width(unit.ToString()); }
protected virtual void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver) { Color color; Unit unit3; StateBag viewState = this.ViewState; if (this.IsSet(4)) { color = (Color)viewState["ForeColor"]; if (!color.IsEmpty) { attributes.Add(HtmlTextWriterStyle.Color, ColorTranslator.ToHtml(color)); } } if (this.IsSet(8)) { color = (Color)viewState["BackColor"]; if (!color.IsEmpty) { attributes.Add(HtmlTextWriterStyle.BackgroundColor, ColorTranslator.ToHtml(color)); } } if (this.IsSet(0x10)) { color = (Color)viewState["BorderColor"]; if (!color.IsEmpty) { attributes.Add(HtmlTextWriterStyle.BorderColor, ColorTranslator.ToHtml(color)); } } System.Web.UI.WebControls.BorderStyle borderStyle = this.BorderStyle; Unit borderWidth = this.BorderWidth; if (!borderWidth.IsEmpty) { attributes.Add(HtmlTextWriterStyle.BorderWidth, borderWidth.ToString(CultureInfo.InvariantCulture)); if (borderStyle == System.Web.UI.WebControls.BorderStyle.NotSet) { if (borderWidth.Value != 0.0) { attributes.Add(HtmlTextWriterStyle.BorderStyle, "solid"); } } else { attributes.Add(HtmlTextWriterStyle.BorderStyle, borderStyles[(int)borderStyle]); } } else if (borderStyle != System.Web.UI.WebControls.BorderStyle.NotSet) { attributes.Add(HtmlTextWriterStyle.BorderStyle, borderStyles[(int)borderStyle]); } FontInfo font = this.Font; string[] names = font.Names; if (names.Length > 0) { attributes.Add(HtmlTextWriterStyle.FontFamily, FormatStringArray(names, ',')); } FontUnit size = font.Size; if (!size.IsEmpty) { attributes.Add(HtmlTextWriterStyle.FontSize, size.ToString(CultureInfo.InvariantCulture)); } if (this.IsSet(0x800)) { if (font.Bold) { attributes.Add(HtmlTextWriterStyle.FontWeight, "bold"); } else { attributes.Add(HtmlTextWriterStyle.FontWeight, "normal"); } } if (this.IsSet(0x1000)) { if (font.Italic) { attributes.Add(HtmlTextWriterStyle.FontStyle, "italic"); } else { attributes.Add(HtmlTextWriterStyle.FontStyle, "normal"); } } string str = string.Empty; if (font.Underline) { str = "underline"; } if (font.Overline) { str = str + " overline"; } if (font.Strikeout) { str = str + " line-through"; } if (str.Length > 0) { attributes.Add(HtmlTextWriterStyle.TextDecoration, str); } else if ((this.IsSet(0x2000) || this.IsSet(0x4000)) || this.IsSet(0x8000)) { attributes.Add(HtmlTextWriterStyle.TextDecoration, "none"); } if (this.IsSet(0x80)) { unit3 = (Unit)viewState["Height"]; if (!unit3.IsEmpty) { attributes.Add(HtmlTextWriterStyle.Height, unit3.ToString(CultureInfo.InvariantCulture)); } } if (this.IsSet(0x100)) { unit3 = (Unit)viewState["Width"]; if (!unit3.IsEmpty) { attributes.Add(HtmlTextWriterStyle.Width, unit3.ToString(CultureInfo.InvariantCulture)); } } }