Esempio n. 1
0
File: CssBox.cs Progetto: dfr0/moon
 /// <summary>
 /// Sets a style property.
 /// </summary>
 /// <param name="style">The style name.</param>
 /// <param name="value">The value to set.</param>
 protected void SetStyleProperty(CssAttribute style, Unit value)
 {
     if (value == null || value.IsEmpty)
     {
         _mhe.RemoveStyleAttribute(style);
     }
     else
     {
         _mhe.SetStyleAttribute(style, value);
     }
 }
Esempio n. 2
0
        public FontUnit(string value, CultureInfo culture) 
        {
            _type = FontSize.NotSet;
            _value = Unit.Empty;

            if ((value != null) && (value.Length > 0)) 
            {
                // This is invariant because it acts like an enum with a number 
                // together. The enum part is invariant, but the number uses 
                // current culture. 
                char firstChar = Char.ToLower(value[0], CultureInfo.InvariantCulture);
                if (firstChar == 'x') 
                {
                    string lcaseValue = value.ToLower(CultureInfo.InvariantCulture);

                    if (lcaseValue.Equals("xx-small") || lcaseValue.Equals("xxsmall")) 
                    {
                        _type = FontSize.XXSmall;
                        return;
                    }
                    else if (lcaseValue.Equals("x-small") || lcaseValue.Equals("xsmall")) 
                    {
                        _type = FontSize.XSmall;
                        return;
                    }
                    else if (lcaseValue.Equals("x-large") || lcaseValue.Equals("xlarge")) 
                    {
                        _type = FontSize.XLarge;
                        return;
                    }
                    else if (lcaseValue.Equals("xx-large") || lcaseValue.Equals("xxlarge")) 
                    {
                        _type = FontSize.XXLarge;
                        return;
                    }
                }
                else if (firstChar == 's') 
                {
                    string lcaseValue = value.ToLower(CultureInfo.InvariantCulture);
                    if (lcaseValue.Equals("small")) 
                    {
                        _type = FontSize.Small;
                        return;
                    }
                    else if (lcaseValue.Equals("smaller")) 
                    {
                        _type = FontSize.Smaller;
                        return;
                    }
                }
                else if (firstChar == 'l') 
                {
                    string lcaseValue = value.ToLower(CultureInfo.InvariantCulture);
                    if (lcaseValue.Equals("large")) 
                    {
                        _type = FontSize.Large;
                        return;
                    }
                    if (lcaseValue.Equals("larger")) 
                    {
                        _type = FontSize.Larger;
                        return;
                    }
                }
                else if ((firstChar == 'm') && (value.ToLower(CultureInfo.InvariantCulture).Equals("medium"))) 
                {
                    _type = FontSize.Medium;
                    return;
                }

                _value = new Unit(value, culture, UnitType.Point);
                _type = FontSize.AsUnit;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the  class with a FontSize.
 /// </summary>
 /// <param name="type">The font size.</param>
 public FontUnit(FontSize type) 
 {
     if (type < FontSize.NotSet || type > FontSize.XXLarge) 
     {
         throw new ArgumentOutOfRangeException("type");
     }
     _type = type;
     if (_type == FontSize.AsUnit) 
     {
         _value = Unit.Point(10);
     }
     else 
     {
         _value = Unit.Empty;
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the  class with an integer value.
 /// </summary>
 /// <param name="value">The integer value.</param>
 public FontUnit(int value) 
 {
     _type = FontSize.AsUnit;
     _value = Unit.Point(value);
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the  class with a Unit.
 /// </summary>
 /// <param name="value">The integer value.</param>
 public FontUnit(Unit value) 
 {
     _type = FontSize.NotSet;
     if (value.IsEmpty == false) 
     {
         _type = FontSize.AsUnit;
         _value = value;
     }
     else 
     {
         _value = Unit.Empty;
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Sets a number of border properties for the element.
 /// </summary>
 /// <param name="width">The width of the border.</param>
 /// <param name="color">The border color.</param>
 /// <param name="style">The border style.</param>
 public void SetBorder(Unit width, string color, BorderStyle style)
 {
     BorderWidth = width;
     BorderColor = color;
     BorderStyle = style;
 }
Esempio n. 7
0
 /// <summary>
 /// Sets a number of border properties for the element.
 /// </summary>
 /// <param name="width">The width of the border.</param>
 /// <param name="color">The border color.</param>
 public void SetBorder(Unit width, string color)
 {
     SetBorder(width, color, BorderStyle.Solid);
 }
Esempio n. 8
0
 /// <summary>
 /// Sets the style attribute.
 /// </summary>
 /// <param name="name">Attribute name.</param>
 /// <param name="unit">The value to set the property to.</param>
 public void SetStyleAttribute(CssAttribute name, Unit unit)
 {
     SetStyleAttribute(name, unit.ToString());
 }