Ejemplo n.º 1
0
		public void FontUnitConstructors1 ()
		{
			FontUnit f1 = new FontUnit (FontSize.Large);
			
			Assert.AreEqual (f1.Type, FontSize.Large, "A1");
			Assert.AreEqual (f1.Unit, Unit.Empty, "A1.1");
		}
Ejemplo n.º 2
0
        /// <summary>
        ///  Converts a FontUnit to a size for the HTML FONT tag
        /// </summary>
        internal static string ConvertToHtmlFontSize(FontUnit fu)
        {
            if ((int)(fu.Type) > 3)
            {
                return ((int)(fu.Type)-3).ToString();
            }

            if (fu.Type == FontSize.AsUnit) {
                if (fu.Unit.Type == UnitType.Point) {
                    if (fu.Unit.Value <= 8)
                        return "1";
                    else if (fu.Unit.Value <= 10)
                        return "2";
                    else if (fu.Unit.Value <= 12)
                        return "3";
                    else if (fu.Unit.Value <= 14)
                        return "4";
                    else if (fu.Unit.Value <= 18)
                        return "5";
                    else if (fu.Unit.Value <= 24)
                        return "6";
                    else
                        return "7";
                }
            }

            return null;
        }
Ejemplo n.º 3
0
		public void FontUnitConstructors3 ()
		{
			FontUnit f1 = new FontUnit (15);
			Assert.AreEqual (f1.Type, FontSize.AsUnit, "A5");
			Assert.AreEqual (f1.Unit.Type, UnitType.Point, "A6");
			Assert.AreEqual (f1.Unit.Value, 15, "A7");
		}
Ejemplo n.º 4
0
		public void FontUnitConstructors4 ()
		{
			// Test the string constructor: null and empty
			FontUnit f1 = new FontUnit (null);
			Assert.AreEqual (f1.Type, FontSize.NotSet, "A8");
			Assert.AreEqual (f1.Unit.IsEmpty, true, "A9");
		}
Ejemplo n.º 5
0
		public void FontUnitConstructors2 ()
		{
			// Test the AsUnit values
			FontUnit f1 = new FontUnit (FontSize.AsUnit);
			Assert.AreEqual (f1.Type, FontSize.AsUnit, "A2");
			Assert.AreEqual (f1.Unit.Type, UnitType.Point, "A3");
			Assert.AreEqual (f1.Unit.Value, 10, "A4");
		}
Ejemplo n.º 6
0
 public override bool Equals(object obj)
 {
     if (obj is FontUnit)
     {
         FontUnit other = (FontUnit)obj;
         return(other.type == type && other.unit == unit);
     }
     return(false);
 }
        public override bool Equals(object obj)
        {
            if ((obj == null) || !(obj is FontUnit))
            {
                return(false);
            }
            FontUnit unit = (FontUnit)obj;

            return((unit.type == this.type) && (unit.value == this.value));
        }
 static FontUnit()
 {
     Empty   = new FontUnit();
     Smaller = new FontUnit(FontSize.Smaller);
     Larger  = new FontUnit(FontSize.Larger);
     XXSmall = new FontUnit(FontSize.XXSmall);
     XSmall  = new FontUnit(FontSize.XSmall);
     Small   = new FontUnit(FontSize.Small);
     Medium  = new FontUnit(FontSize.Medium);
     Large   = new FontUnit(FontSize.Large);
     XLarge  = new FontUnit(FontSize.XLarge);
     XXLarge = new FontUnit(FontSize.XXLarge);
 }
Ejemplo n.º 9
0
        /// <devdoc>
        /// <para>Determines if the specified <see cref='System.Object' qualify='true'/> is equivilent to the <see cref='System.Web.UI.WebControls.FontUnit'/> represented by this instance.</para>
        /// </devdoc>
        public override bool Equals(object obj)
        {
            if (obj == null || !(obj is FontUnit))
            {
                return(false);
            }

            FontUnit f = (FontUnit)obj;

            if ((f.type == type) && (f.value == value))
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 10
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value == null)
            {
                return(null);
            }
            string str = value as string;

            if (str == null)
            {
                return(base.ConvertFrom(context, culture, value));
            }
            string s = str.Trim();

            if (s.Length == 0)
            {
                return(FontUnit.Empty);
            }
            return(FontUnit.Parse(s, culture));
        }
Ejemplo n.º 11
0
        /// <include file='doc\FontUnitConverter.uex' path='docs/doc[@for="FontUnitConverter.ConvertFrom"]/*' />
        /// <devdoc>
        /// <para>Converts the specified <see cref='System.Object' qualify='true'/> into a <see cref='System.Web.UI.WebControls.FontUnit'/>.</para>
        /// </devdoc>
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value == null)
            {
                return(null);
            }

            if (value is string)
            {
                string textValue = ((string)value).Trim();
                if (textValue.Length == 0)
                {
                    return(FontUnit.Empty);
                }
                return(FontUnit.Parse(textValue, culture));
            }
            else
            {
                return(base.ConvertFrom(context, culture, value));
            }
        }
Ejemplo n.º 12
0
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            string s;

            if ((value == null) || !(value is string))
            {
                return(base.ConvertFrom(context, culture, value));
            }


            s = (string)value;

            if (culture == null)
            {
                culture = CultureInfo.CurrentCulture;
            }

            if (s == "")
            {
                return(FontUnit.Empty);
            }
            return(FontUnit.Parse(s, culture));
        }
Ejemplo n.º 13
0
		private void Test(Type ctrlType)
		{
			FontUnit unit1;
			try
			{
				this.GHTSubTestBegin(ctrlType, "Set legal absolute size.");
				unit1 = new FontUnit(12);
				this.TestedControl.ControlStyle.Font.Size = unit1;
			}
			catch (Exception exception7)
			{
				// ProjectData.SetProjectError(exception7);
				Exception exception1 = exception7;
				this.GHTSubTestUnexpectedExceptionCaught(exception1);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
			try
			{
				this.GHTSubTestBegin(ctrlType, "Set legal relative size.");
				unit1 = new FontUnit(FontSize.Larger);
				this.TestedControl.ControlStyle.Font.Size = unit1;
			}
			catch (Exception exception8)
			{
				// ProjectData.SetProjectError(exception8);
				Exception exception2 = exception8;
				this.GHTSubTestUnexpectedExceptionCaught(exception2);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
			try
			{
				this.GHTSubTestBegin(ctrlType, "Set to negative size.");
				unit1 = new FontUnit(-10);
				this.TestedControl.ControlStyle.Font.Size = unit1;
				this.GHTSubTestExpectedExceptionNotCaught("argumentOutOfRangeException");
			}
			catch (ArgumentOutOfRangeException exception9)
			{
				// ProjectData.SetProjectError(exception9);
				ArgumentOutOfRangeException exception3 = exception9;
				this.GHTSubTestExpectedExceptionCaught(exception3);
				// ProjectData.ClearProjectError();
			}
			catch (Exception exception10)
			{
				// ProjectData.SetProjectError(exception10);
				Exception exception4 = exception10;
				this.GHTSubTestUnexpectedExceptionCaught(exception4);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
			try
			{
				this.GHTSubTestBegin(ctrlType, "Set to zero.");
				unit1 = new FontUnit(FontSize.NotSet);
				this.TestedControl.ControlStyle.Font.Size = unit1;
			}
			catch (Exception exception11)
			{
				// ProjectData.SetProjectError(exception11);
				Exception exception5 = exception11;
				this.GHTSubTestUnexpectedExceptionCaught(exception5);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
			try
			{
				this.GHTSubTestBegin(ctrlType, "Set size in code and in CssClass.");
				unit1 = new FontUnit(0x19);
				this.TestedControl.ControlStyle.Font.Size = unit1;
				this.TestedControl.ControlStyle.CssClass = "CssClass1";
			}
			catch (Exception exception12)
			{
				// ProjectData.SetProjectError(exception12);
				Exception exception6 = exception12;
				this.GHTSubTestUnexpectedExceptionCaught(exception6);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
		}
Ejemplo n.º 14
0
		public void FontUnit_IFormatProviderToString ()
		{
			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.º 15
0
		public void IncorrectConstructor ()
		{
			FontUnit a = new FontUnit ((FontSize) (-1));
		}
Ejemplo n.º 16
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.º 17
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.º 18
0
 public static object StrongTypeValue(object value, Type type)
 {
     if (null == type)
     {
         throw new ArgumentNullException("type");
     }
     object result;
     if (null == value)
     {
         result = null;
     }
     else
     {
         if (type.IsEnum)
         {
             result = Enum.Parse(type, value.ToString());
         }
         else
         {
             if (type == typeof(FontUnit))
             {
                 if (value is FontUnit)
                 {
                     result = value;
                 }
                 else
                 {
                     if (value is string && (string.IsNullOrEmpty(value.ToString()) || "NotSet" == value.ToString()))
                     {
                         result = default(FontUnit);
                     }
                     else
                     {
                         result = new FontUnit(value.ToString());
                     }
                 }
             }
             else
             {
                 if (type == typeof(Color))
                 {
                     if (value is Color)
                     {
                         result = value;
                     }
                     else
                     {
                         if (value is string && string.IsNullOrEmpty(value.ToString()))
                         {
                             result = default(Color);
                         }
                         else
                         {
                             result = Color.FromName(value.ToString());
                         }
                     }
                 }
                 else
                 {
                     if (type == typeof(Unit))
                     {
                         result = Unit.Parse(value.ToString());
                     }
                     else
                     {
                         if (type.IsArray && value is string)
                         {
                             string[] values = value.ToString().Split(new char[]
                             {
                                 ','
                             });
                             for (int i = 0; i < values.Length; i++)
                             {
                                 values[i] = values[i].Trim();
                             }
                             Array ret = Array.CreateInstance(type.GetElementType(), values.Length);
                             values.CopyTo(ret, 0);
                             result = ret;
                         }
                         else
                         {
                             if (value is IConvertible && (!type.IsGenericType || !type.Name.Contains("Nullable")))
                             {
                                 if (value is DateTime && type == typeof(string))
                                 {
                                     result = ((DateTime)value).ToString();
                                 }
                                 else
                                 {
                                     result = Convert.ChangeType(value, type);
                                 }
                             }
                             else
                             {
                                 result = value;
                             }
                         }
                     }
                 }
             }
         }
     }
     return result;
 }
Ejemplo n.º 19
0
		private void AddTitle(ref HtmlForm frm, string text)
		{
			Label label1 = new Label();
			label1.Text = text;
			label1.Font.Bold = true;
			label1.Font.Underline = true;
			FontUnit unit1 = new FontUnit(FontSize.Larger);
			label1.Font.Size = unit1;
			frm.Controls.Add(label1);
		}
Ejemplo n.º 20
0
        protected sealed override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
        {
            StateBag viewState = base.ViewState;

            if (this._owner.IsSet(4))
            {
                Color foreColor = this._owner.ForeColor;
                if (!foreColor.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.Color, ColorTranslator.ToHtml(foreColor));
                }
            }
            FontInfo font = this._owner.Font;

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

            if (!size.IsEmpty)
            {
                attributes.Add(HtmlTextWriterStyle.FontSize, size.ToString(CultureInfo.InvariantCulture));
            }
            if (this._owner.IsSet(0x800))
            {
                if (font.Bold)
                {
                    attributes.Add(HtmlTextWriterStyle.FontWeight, "bold");
                }
                else
                {
                    attributes.Add(HtmlTextWriterStyle.FontWeight, "normal");
                }
            }
            if (this._owner.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.DoNotRenderDefaults)
            {
                attributes.Add(HtmlTextWriterStyle.TextDecoration, "none");
            }
            if (this._owner.IsSet(2))
            {
                attributes.Add(HtmlTextWriterStyle.BorderStyle, "none");
            }
        }
 private string ConvertToHtmlFontSize(string value)
 {
     FontUnit unit = new FontUnit(value, CultureInfo.InvariantCulture);
     if (unit.Type > FontSize.Larger)
     {
         int num = ((int) unit.Type) - 3;
         return num.ToString(CultureInfo.InvariantCulture);
     }
     if ((unit.Type != FontSize.AsUnit) || (unit.Unit.Type != UnitType.Point))
     {
         return null;
     }
     if (unit.Unit.Value <= 8.0)
     {
         return "1";
     }
     if (unit.Unit.Value <= 10.0)
     {
         return "2";
     }
     if (unit.Unit.Value <= 12.0)
     {
         return "3";
     }
     if (unit.Unit.Value <= 14.0)
     {
         return "4";
     }
     if (unit.Unit.Value <= 18.0)
     {
         return "5";
     }
     if (unit.Unit.Value <= 24.0)
     {
         return "6";
     }
     return "7";
 }
Ejemplo n.º 22
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            MemberInfo field;

            object[] objArray;
            string   str;

            if (!(destinationType == typeof(string)))
            {
                if (!(destinationType == typeof(InstanceDescriptor)) || (value == null))
                {
                    return(base.ConvertTo(context, culture, value, destinationType));
                }
                FontUnit unit = (FontUnit)value;
                field    = null;
                objArray = null;
                if (unit.IsEmpty)
                {
                    field = typeof(FontUnit).GetField("Empty");
                    goto Label_016E;
                }
                if (unit.Type == FontSize.AsUnit)
                {
                    field    = typeof(FontUnit).GetConstructor(new Type[] { typeof(Unit) });
                    objArray = new object[] { unit.Unit };
                    goto Label_016E;
                }
                str = null;
                switch (unit.Type)
                {
                case FontSize.Smaller:
                    str = "Smaller";
                    break;

                case FontSize.Larger:
                    str = "Larger";
                    break;

                case FontSize.XXSmall:
                    str = "XXSmall";
                    break;

                case FontSize.XSmall:
                    str = "XSmall";
                    break;

                case FontSize.Small:
                    str = "Small";
                    break;

                case FontSize.Medium:
                    str = "Medium";
                    break;

                case FontSize.Large:
                    str = "Large";
                    break;

                case FontSize.XLarge:
                    str = "XLarge";
                    break;

                case FontSize.XXLarge:
                    str = "XXLarge";
                    break;
                }
            }
            else
            {
                if (value != null)
                {
                    FontUnit unit2 = (FontUnit)value;
                    if (unit2.Type != FontSize.NotSet)
                    {
                        FontUnit unit3 = (FontUnit)value;
                        return(unit3.ToString(culture));
                    }
                }
                return(string.Empty);
            }
            if (str != null)
            {
                field = typeof(FontUnit).GetField(str);
            }
Label_016E:
            if (field != null)
            {
                return(new InstanceDescriptor(field, objArray));
            }
            return(null);
        }
Ejemplo n.º 23
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.º 24
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");
		}
        protected override sealed void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
        {
            Debug.Assert(_owner != null);

            StateBag viewState = ViewState;

            Color c;

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

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

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

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

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

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

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

            string textDecoration = String.Empty;

            if (font.Underline)
            {
                textDecoration = "underline";
            }
            if (font.Overline)
            {
                textDecoration += " overline";
            }
            if (font.Strikeout)
            {
                textDecoration += " line-through";
            }
            if (textDecoration.Length > 0)
            {
                attributes.Add(HtmlTextWriterStyle.TextDecoration, textDecoration);
            }
            else
            {
                if (!DoNotRenderDefaults)
                {
                    attributes.Add(HtmlTextWriterStyle.TextDecoration, "none");
                }
            }
            // Removing the border with an inline style if the class name was set
            if (_owner.IsSet(PROP_CSSCLASS))
            {
                attributes.Add(HtmlTextWriterStyle.BorderStyle, "none");
            }
        }
Ejemplo n.º 26
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.º 27
0
		public void FontUnitConstructors6 ()
		{
			FontUnit f1 = new FontUnit (2.5);
			Assert.AreEqual (f1.Type, FontSize.AsUnit, "A12");
			Assert.AreEqual (f1.Unit.Type, UnitType.Point, "A13");
			Assert.AreEqual (f1.Unit.Value, 2.5, "A14");
		}
Ejemplo n.º 28
0
		public void UnitEquality ()
		{
			FontUnit u1 = new FontUnit ("1px");
			FontUnit u2 = new FontUnit ("2px");
			FontUnit t1 = new FontUnit ("1px");
			FontUnit c2 = new FontUnit ("2cm");

			Assert.AreEqual (u1 == t1, true, "U1");
			Assert.AreEqual (u1 != u2, true, "U2");
			Assert.AreEqual (u1 == u2, false, "U3");
			Assert.AreEqual (u1 != t1, false, "U4");

			// Test that its comparing the units and value
			Assert.AreEqual (u2 != c2, true, "U5");
		}
Ejemplo n.º 29
0
		private void Test(Type ctrlType)
		{
			try
			{
				this.GHTSubTestBegin(ctrlType, "Bold");
				this.TestedControl.Font.Bold = true;
				this.GHTSubTestAddResult(this.TestedControl.Font.ToString());
			}
			catch (Exception exception9)
			{
				// ProjectData.SetProjectError(exception9);
				Exception exception1 = exception9;
				this.GHTSubTestUnexpectedExceptionCaught(exception1);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
			try
			{
				this.GHTSubTestBegin(ctrlType, "Italic");
				this.TestedControl.Font.Italic = true;
				this.GHTSubTestAddResult(this.TestedControl.Font.ToString());
			}
			catch (Exception exception10)
			{
				// ProjectData.SetProjectError(exception10);
				Exception exception2 = exception10;
				this.GHTSubTestUnexpectedExceptionCaught(exception2);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
			try
			{
				this.GHTSubTestBegin(ctrlType, "Name ");
				this.TestedControl.Font.Name = "Lucida Console";
			}
			catch (Exception exception11)
			{
				// ProjectData.SetProjectError(exception11);
				Exception exception3 = exception11;
				this.GHTSubTestUnexpectedExceptionCaught(exception3);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
			try
			{
				this.GHTSubTestBegin(ctrlType, "Names");
				string[] textArray1 = new string[] { "verdana", "Lucida Console", "Courier" } ;
				this.TestedControl.Font.Names = textArray1;
			}
			catch (Exception exception12)
			{
				// ProjectData.SetProjectError(exception12);
				Exception exception4 = exception12;
				this.GHTSubTestUnexpectedExceptionCaught(exception4);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
			try
			{
				this.GHTSubTestBegin(ctrlType, "Overline");
				this.TestedControl.Font.Overline = true;
				this.GHTSubTestAddResult(this.TestedControl.Font.ToString());
			}
			catch (Exception exception13)
			{
				// ProjectData.SetProjectError(exception13);
				Exception exception5 = exception13;
				this.GHTSubTestUnexpectedExceptionCaught(exception5);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
			try
			{
				this.GHTSubTestBegin(ctrlType, "FontSize");
				FontUnit unit1 = new FontUnit(FontSize.XXLarge);
				this.TestedControl.Font.Size = unit1;
				this.GHTSubTestAddResult(this.TestedControl.Font.ToString());
			}
			catch (Exception exception14)
			{
				// ProjectData.SetProjectError(exception14);
				Exception exception6 = exception14;
				this.GHTSubTestUnexpectedExceptionCaught(exception6);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
			try
			{
				this.GHTSubTestBegin(ctrlType, "Strikeout");
				this.TestedControl.Font.Strikeout = true;
				this.GHTSubTestAddResult(this.TestedControl.Font.ToString());
			}
			catch (Exception exception15)
			{
				// ProjectData.SetProjectError(exception15);
				Exception exception7 = exception15;
				this.GHTSubTestUnexpectedExceptionCaught(exception7);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
			try
			{
				this.GHTSubTestBegin(ctrlType, "Underline");
				this.TestedControl.Font.Underline = true;
				this.GHTSubTestAddResult(this.TestedControl.Font.ToString());
			}
			catch (Exception exception16)
			{
				// ProjectData.SetProjectError(exception16);
				Exception exception8 = exception16;
				this.GHTSubTestUnexpectedExceptionCaught(exception8);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
		}
Ejemplo n.º 30
0
		public void IncorrectConstructor2 ()
		{
			FontUnit a = new FontUnit ((FontSize) (FontSize.XXLarge + 1));
		}
Ejemplo n.º 31
0
        /// <summary>
        /// Gets the font size.
        /// </summary>
        /// <returns>The font size.</returns>
        public string GetFontSize()
        {
            string szSize = this["font-size"];
            if (szSize != null)
            {
                FontUnit fu = new FontUnit(szSize);
                if (fu.Type == FontSize.NotSet)
                {
                    return szSize;
                }
                else
                {
                    return Util.ConvertToHtmlFontSize(fu);
                }
            }

            return null;
        }
		private void Test(Type ctrlType)
		{
			try
			{
				this.GHTSubTestBegin(ctrlType, "Default style", false);
				this.GHTAddToActiveForm(this.TestedControl);
				this.GHTSubTestAddResult(this.TestedControl.ControlStyleCreated.ToString());
			}
			catch (Exception exception3)
			{
				// ProjectData.SetProjectError(exception3);
				Exception exception1 = exception3;
				this.GHTSubTestUnexpectedExceptionCaught(exception1);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
			try
			{
				this.GHTSubTestBegin(ctrlType, "Modified style", false);
				Style style1 = new Style();
				Style style2 = style1;
				style2.BackColor = Color.Fuchsia;
				style2.BorderColor = Color.DeepSkyBlue;
				style2.BorderStyle = BorderStyle.Ridge;
				Unit unit2 = new Unit(2);
				style2.BorderWidth = unit2;
				style2.ForeColor = Color.IndianRed;
				unit2 = new Unit(30);
				style2.Height = unit2;
				unit2 = new Unit(40);
				style2.Width = unit2;
				FontInfo info1 = style2.Font;
				info1.Bold = true;
				info1.Italic = true;
				info1.Name = "Times new roman";
				info1.Overline = true;
				FontUnit unit1 = new FontUnit(FontSize.Larger);
				info1.Size = unit1;
				info1.Strikeout = true;
				info1.Underline = true;
				info1 = null;
				style2 = null;
				this.TestedControl.ApplyStyle(style1);
				this.GHTAddToActiveForm(this.TestedControl);
				this.GHTSubTestAddResult(this.TestedControl.ControlStyleCreated.ToString());
			}
			catch (Exception exception4)
			{
				// ProjectData.SetProjectError(exception4);
				Exception exception2 = exception4;
				this.GHTSubTestUnexpectedExceptionCaught(exception2);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
		}
Ejemplo n.º 33
0
        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));
                }
            }
        }
Ejemplo n.º 34
0
        /// <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));
                }
            }
        }
Ejemplo n.º 35
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.º 36
0
		public void FontUnitConstructors5 ()
		{
			FontUnit f1 = new FontUnit ("");
			Assert.AreEqual (f1.Type, FontSize.NotSet, "A10");
			Assert.AreEqual (f1.Unit.IsEmpty, true, "A11");
		}
Ejemplo n.º 37
0
		private void InitStyles()
		{
			this.m_blankStyle = new Style();
			this.m_oldStyle = new Style();
			Style style2 = this.m_oldStyle;
			style2.BackColor = Color.Wheat;
			style2.BorderColor = Color.DarkGreen;
			style2.BorderStyle = BorderStyle.Double;
			Unit unit2 = new Unit(5);
			style2.BorderWidth = unit2;
			style2.ForeColor = Color.DarkMagenta;
			unit2 = new Unit(60);
			style2.Height = unit2;
			unit2 = new Unit(60);
			style2.Width = unit2;
			FontInfo info2 = style2.Font;
			info2.Bold = false;
			info2.Italic = false;
			info2.Name = "Times New Roman";
			info2.Overline = false;
			FontUnit unit1 = new FontUnit(FontSize.Small);
			info2.Size = unit1;
			info2.Strikeout = false;
			info2.Underline = false;
			info2 = null;
			style2 = null;
			this.m_newStyle = new Style();
			Style style1 = this.m_newStyle;
			style1.BackColor = Color.AliceBlue;
			style1.BorderColor = Color.Red;
			style1.BorderStyle = BorderStyle.Dashed;
			unit2 = new Unit(2);
			style1.BorderWidth = unit2;
			style1.ForeColor = Color.RoyalBlue;
			unit2 = new Unit(40);
			style1.Height = unit2;
			unit2 = new Unit(40);
			style1.Width = unit2;
			FontInfo info1 = style1.Font;
			info1.Bold = true;
			info1.Italic = true;
			info1.Name = "Arial";
			info1.Overline = true;
			unit1 = new FontUnit(FontSize.Large);
			info1.Size = unit1;
			info1.Strikeout = true;
			info1.Underline = true;
			info1 = null;
			style1 = null;
		}
Ejemplo n.º 38
0
		public void FontUnitConstructors7 ()
		{
			FontUnit f1 = new FontUnit (5.0, UnitType.Percentage);
			Assert.AreEqual (f1.Type, FontSize.AsUnit, "A15");
			Assert.AreEqual (f1.Unit.Type, UnitType.Percentage, "A17");
			Assert.AreEqual (f1.Unit.Value, 5.0, "A18");
		}
        /// <devdoc>
        /// <para>Converts the specified <see cref='System.Web.UI.WebControls.FontUnit'/> into the specified <see cref='System.Type' qualify='true'/>. </para>
        /// </devdoc>
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(string))
            {
                if ((value == null) || (((FontUnit)value).Type == FontSize.NotSet))
                {
                    return(String.Empty);
                }
                else
                {
                    return(((FontUnit)value).ToString(culture));
                }
            }
            else if ((destinationType == typeof(InstanceDescriptor)) && (value != null))
            {
                FontUnit   u      = (FontUnit)value;
                MemberInfo member = null;
                object[]   args   = null;

                if (u.IsEmpty)
                {
                    member = typeof(FontUnit).GetField("Empty");
                }
                else if (u.Type != FontSize.AsUnit)
                {
                    string fieldName = null;
                    switch (u.Type)
                    {
                    case FontSize.Smaller:
                        fieldName = "Smaller";
                        break;

                    case FontSize.Larger:
                        fieldName = "Larger";
                        break;

                    case FontSize.XXSmall:
                        fieldName = "XXSmall";
                        break;

                    case FontSize.XSmall:
                        fieldName = "XSmall";
                        break;

                    case FontSize.Small:
                        fieldName = "Small";
                        break;

                    case FontSize.Medium:
                        fieldName = "Medium";
                        break;

                    case FontSize.Large:
                        fieldName = "Large";
                        break;

                    case FontSize.XLarge:
                        fieldName = "XLarge";
                        break;

                    case FontSize.XXLarge:
                        fieldName = "XXLarge";
                        break;
                    }
                    Debug.Assert(fieldName != null, "Invalid FontSize type");
                    if (fieldName != null)
                    {
                        member = typeof(FontUnit).GetField(fieldName);
                    }
                }
                else
                {
                    member = typeof(FontUnit).GetConstructor(new Type[] { typeof(Unit) });
                    args   = new object[] { u.Unit };
                }

                Debug.Assert(member != null, "Looks like we're missing FontUnit static fields or FontUnit::ctor(Unit)");
                if (member != null)
                {
                    return(new InstanceDescriptor(member, args));
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(base.ConvertTo(context, culture, value, destinationType));
            }
        }
Ejemplo n.º 40
0
        protected virtual void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
        {
            StateBag viewState = ViewState;

            Color c;

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

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

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

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

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

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

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

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

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

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

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

            //
            string textDecoration = String.Empty;

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

            Unit u;

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

            // Width
            if (IsSet(PROP_WIDTH))
            {
                u = (Unit)viewState["Width"];
                if (!u.IsEmpty)
                {
                    attributes.Add(HtmlTextWriterStyle.Width, u.ToString(CultureInfo.InvariantCulture));
                }
            }
        }
Ejemplo n.º 41
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;
			}
		}
Ejemplo n.º 42
0
        private string ConvertToHtmlFontSize(string value) {
            FontUnit fu = new FontUnit(value, CultureInfo.InvariantCulture);
            if ((int)(fu.Type) > 3)
                return((int)(fu.Type)-3).ToString(CultureInfo.InvariantCulture);

            if (fu.Type == FontSize.AsUnit) {
                if (fu.Unit.Type == UnitType.Point) {
                    if (fu.Unit.Value <= 8)
                        return "1";
                    else if (fu.Unit.Value <= 10)
                        return "2";
                    else if (fu.Unit.Value <= 12)
                        return "3";
                    else if (fu.Unit.Value <= 14)
                        return "4";
                    else if (fu.Unit.Value <= 18)
                        return "5";
                    else if (fu.Unit.Value <= 24)
                        return "6";
                    else
                        return "7";
                }
            }

            return null;
        }
 static FontUnit()
 {
     Empty = new FontUnit();
     Smaller = new FontUnit(FontSize.Smaller);
     Larger = new FontUnit(FontSize.Larger);
     XXSmall = new FontUnit(FontSize.XXSmall);
     XSmall = new FontUnit(FontSize.XSmall);
     Small = new FontUnit(FontSize.Small);
     Medium = new FontUnit(FontSize.Medium);
     Large = new FontUnit(FontSize.Large);
     XLarge = new FontUnit(FontSize.XLarge);
     XXLarge = new FontUnit(FontSize.XXLarge);
 }