[Mono-list] FontUnit: Checking negative values

A Rafael D Teixeira rafaelteixeirabr@hotmail.com
Fri, 21 Dec 2001 16:35:53 -0200


>From: "Gaurav Vaish" <gvaish@iitk.ac.in>
>Subject: [Mono-list] FontUnit: Checking negative values
>
>Hello,
>     Any clues how to do the "TODO"?
>     FontUnit is a struct.
>
>Index: FontInfo.cs
>===================================================================
>RCS file: 
>/cvs/public/mcs/class/System.Web/System.Web.UI.WebControls/FontInfo.cs,v
>retrieving revision 1.4
>diff -u -r1.4 FontInfo.cs
>--- FontInfo.cs 2001/12/19 17:34:12     1.4
>+++ FontInfo.cs 2001/12/19 17:35:04
>@@ -103,6 +103,7 @@
>                         }
>                 }
>
>+               // TODO: How do I check if the value is negative. FontUnit 
>is struct not enum
>                 public FontUnit Size
>                 {
>                         get

Itīs sometimes a "unitized" value, but not always, so you have to ask 
yourself When I to check for negative values.

Example: If you want to see if is being measured in pixels it is 
non-positive you have to use code like:

if (myControl.Size.Type == FontSize.AsUnit)
{
  Unit theUnit = myControl.Size.Unit;
  if (theUnit.Type == UnitType.Pixel)
  {
    if (theUnit.Value <= 0)
    {
       // Do Something
    }
  }
}

FontUnit is formed by nested structures with "values" tagged by "types" you 
have to look it like some complex beast to manipulate HTML/CSS  very 
flexible font-size attributes, for example:

<p style="font-size:xx-small">
  Hi <b style="font-size:12pt">Gaurav</b> &nbsp;
  <b style="font-size:19px">Vaish</b>
</p>



Rafael Teixeira
Brazilian Developer


_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com