/***********************************************************************************/
    public static bool ExtractType(string text, ref float value, ref SVGLengthType lengthType)
    {
        string _value = "";
        int i;
        for(i = 0; i < text.Length; i++) {
          if((('0' <= text[i]) && (text[i] <= '9')) || (text[i] == '+') || (text[i] == '-') || (text[i] == '.')) {
        _value = _value + text[i];
          } else if(text[i] == ' ') {
        // Skip.
          } else {
        break;
          }
        }
        string unit = text.Substring(i);

        if(_value == "") return false;

        value = float.Parse(_value, System.Globalization.CultureInfo.InvariantCulture);
        switch(unit.ToUpper()) {
          case "EM": lengthType = SVGLengthType.EMs; break;
          case "EX": lengthType = SVGLengthType.EXs; break;
          case "PX": lengthType = SVGLengthType.PX; break;
          case "CM": lengthType = SVGLengthType.CM; break;
          case "MM": lengthType = SVGLengthType.MM; break;
          case "IN": lengthType = SVGLengthType.IN; break;
          case "PT": lengthType = SVGLengthType.PT; break;
          case "PC": lengthType = SVGLengthType.PC; break;
          case "%": lengthType = SVGLengthType.Percentage; break;
          default : lengthType = SVGLengthType.Unknown; break;
        }
        return true;
    }
示例#2
0
        public static float GetPXLength(string valueText)
        {
            float         t_value = 0.0f;
            SVGLengthType t_type  = SVGLengthType.Unknown;

            SVGLengthConvertor.ExtractType(valueText, ref t_value, ref t_type);
            return(SVGLengthConvertor.ConvertToPX(t_value, t_type));
        }
示例#3
0
 public SVGLength(string valueText)
 {
     float t_value = 0.0f;
     SVGLengthType t_type = SVGLengthType.Unknown;
     SVGLengthConvertor.ExtractType(valueText, ref t_value, ref t_type);
     _unitType = t_type;
     _valueInSpecifiedUnits = t_value;
     _value = SVGLengthConvertor.ConvertToPX(_valueInSpecifiedUnits, _unitType);
 }
示例#4
0
        public SVGLength(string valueText)
        {
            float         t_value = 0.0f;
            SVGLengthType t_type  = SVGLengthType.Unknown;

            SVGLengthConvertor.ExtractType(valueText, ref t_value, ref t_type);
            _unitType = t_type;
            _valueInSpecifiedUnits = t_value;
            _value = SVGLengthConvertor.ConvertToPX(_valueInSpecifiedUnits, _unitType);
        }
 /***********************************************************************************/
 public static float ConvertToPX(float value, SVGLengthType lengthType)
 {
     switch(lengthType) {
       case SVGLengthType.IN: return value * 90.0f;
       case SVGLengthType.CM: return value * 35.43307f;
       case SVGLengthType.MM: return value * 3.543307f;
       case SVGLengthType.PT: return value * 1.25f;
       case SVGLengthType.PC: return value * 15.0f;
       default: return value;
     }
 }
示例#6
0
 private static float ConvertToPX(float value, SVGLengthType lengthType)
 {
     // TODO: Shouldn't PX-per-<real-world-unit> be a function of the render target size?
     switch(lengthType) {
     case SVGLengthType.IN: return value * 90.0f;
     case SVGLengthType.CM: return value * 35.43307f;
     case SVGLengthType.MM: return value * 3.543307f;
     case SVGLengthType.PT: return value * 1.25f;
     case SVGLengthType.PC: return value * 15.0f;
     default: return value;
     }
 }
示例#7
0
    /***********************************************************************************/
    public static bool ExtractType(string text, ref float value, ref SVGLengthType lengthType)
    {
        string _value = "";
        int    i;

        for (i = 0; i < text.Length; i++)
        {
            if ((('0' <= text[i]) && (text[i] <= '9')) || (text[i] == '+') || (text[i] == '-') || (text[i] == '.'))
            {
                _value = _value + text[i];
            }
            else if (text[i] == ' ')
            {
                // Skip.
            }
            else
            {
                break;
            }
        }
        string unit = text.Substring(i);

        if (_value == "")
        {
            return(false);
        }

        value = float.Parse(_value, System.Globalization.CultureInfo.InvariantCulture);
        switch (unit.ToUpper())
        {
        case "EM": lengthType = SVGLengthType.EMs; break;

        case "EX": lengthType = SVGLengthType.EXs; break;

        case "PX": lengthType = SVGLengthType.PX; break;

        case "CM": lengthType = SVGLengthType.CM; break;

        case "MM": lengthType = SVGLengthType.MM; break;

        case "IN": lengthType = SVGLengthType.IN; break;

        case "PT": lengthType = SVGLengthType.PT; break;

        case "PC": lengthType = SVGLengthType.PC; break;

        case "%": lengthType = SVGLengthType.Percentage; break;

        default: lengthType = SVGLengthType.Unknown; break;
        }
        return(true);
    }
示例#8
0
    private static void ExtractType(string text, ref float value, ref SVGLengthType lengthType)
    {
        if (string.IsNullOrEmpty(text))
        {
            return;
        }
        text = text.Trim();
        int i;

        for (i = 0; i < text.Length; ++i)
        {
            char c = text[i];
            if ((('0' <= c) && (c <= '9')) || (c == '+') || (c == '-') || (c == '.') || (c == ' '))
            {
                continue;
            }
            break;
        }

        var strValue = text.Substring(0, i);

        if (!string.IsNullOrEmpty(strValue))
        {
            string unit = text.Substring(i);
            value = float.Parse(strValue, System.Globalization.CultureInfo.InvariantCulture);
            switch (unit.ToUpper())
            {
            case "EM": lengthType = SVGLengthType.EMs; break;

            case "EX": lengthType = SVGLengthType.EXs; break;

            case "PX": lengthType = SVGLengthType.PX; break;

            case "CM": lengthType = SVGLengthType.CM; break;

            case "MM": lengthType = SVGLengthType.MM; break;

            case "IN": lengthType = SVGLengthType.IN; break;

            case "PT": lengthType = SVGLengthType.PT; break;

            case "PC": lengthType = SVGLengthType.PC; break;

            case "%": lengthType = SVGLengthType.Percentage; break;

            default: lengthType = SVGLengthType.Unknown; break;
            }
        }
    }
示例#9
0
    /***********************************************************************************/
    public static float ConvertToPX(float value, SVGLengthType lengthType)
    {
        switch (lengthType)
        {
        case SVGLengthType.IN: return(value * 90.0f);

        case SVGLengthType.CM: return(value * 35.43307f);

        case SVGLengthType.MM: return(value * 3.543307f);

        case SVGLengthType.PT: return(value * 1.25f);

        case SVGLengthType.PC: return(value * 15.0f);

        default: return(value);
        }
    }
示例#10
0
    private static float ConvertToPX(float value, SVGLengthType lengthType)
    {
        // TODO: Shouldn't PX-per-<real-world-unit> be a function of the render target size?
        switch (lengthType)
        {
        case SVGLengthType.IN: return(value * 90.0f);

        case SVGLengthType.CM: return(value * 35.43307f);

        case SVGLengthType.MM: return(value * 3.543307f);

        case SVGLengthType.PT: return(value * 1.25f);

        case SVGLengthType.PC: return(value * 15.0f);

        default: return(value);
        }
    }
示例#11
0
 public void ConvertToSpecifiedUnits(SVGLengthType unitType)
 {
 }
示例#12
0
 public void NewValueSpecifiedUnits(SVGLengthType unitType, float valueInSpecifiedUnits)
 {
 }
示例#13
0
 public void NewValueSpecifiedUnits(float valueInSpecifiedUnits)
 {
     _unitType = (SVGLengthType)0;
     _valueInSpecifiedUnits = valueInSpecifiedUnits;
     _value = SVGLengthConvertor.ConvertToPX(_valueInSpecifiedUnits, _unitType);
 }
示例#14
0
 public void NewValueSpecifiedUnits(float valueInSpecifiedUnits)
 {
     _unitType = SVGLengthType.Unknown;
     _valueInSpecifiedUnits = valueInSpecifiedUnits;
     _value = ConvertToPX(_valueInSpecifiedUnits, _unitType);
 }
示例#15
0
 public SVGLength(float valueInSpecifiedUnits)
 {
     _unitType = SVGLengthType.Number;
     _valueInSpecifiedUnits = valueInSpecifiedUnits;
     _value = SVGLengthConvertor.ConvertToPX(_valueInSpecifiedUnits, _unitType);
 }
示例#16
0
    private static void ExtractType(string text, ref float value, ref SVGLengthType lengthType)
    {
        if(string.IsNullOrEmpty(text))
          return;
        text = text.Trim();
        int i;
        for(i = 0; i < text.Length; ++i) {
          char c = text[i];
          if((('0' <= c) && (c <= '9')) || (c == '+') || (c == '-') || (c == '.') || (c == ' '))
        continue;
          break;
        }

        var strValue = text.Substring(0, i);
        if(!string.IsNullOrEmpty(strValue)) {
          string unit = text.Substring(i);
          value = float.Parse(strValue, System.Globalization.CultureInfo.InvariantCulture);
          switch(unit.ToUpper()) {
          case "EM": lengthType = SVGLengthType.EMs; break;
          case "EX": lengthType = SVGLengthType.EXs; break;
          case "PX": lengthType = SVGLengthType.PX; break;
          case "CM": lengthType = SVGLengthType.CM; break;
          case "MM": lengthType = SVGLengthType.MM; break;
          case "IN": lengthType = SVGLengthType.IN; break;
          case "PT": lengthType = SVGLengthType.PT; break;
          case "PC": lengthType = SVGLengthType.PC; break;
          case "%": lengthType = SVGLengthType.Percentage; break;
          default: lengthType = SVGLengthType.Unknown; break;
          }
        }
    }
示例#17
0
 public void NewValueSpecifiedUnits(float valueInSpecifiedUnits)
 {
     _unitType = (SVGLengthType)0;
     _valueInSpecifiedUnits = valueInSpecifiedUnits;
     _value = SVGLengthConvertor.ConvertToPX(_valueInSpecifiedUnits, _unitType);
 }
示例#18
0
 public SVGLength(SVGLengthType unitType, float valueInSpecifiedUnits)
 {
     _unitType = unitType;
     _valueInSpecifiedUnits = valueInSpecifiedUnits;
     _value = SVGLengthConvertor.ConvertToPX(_valueInSpecifiedUnits, _unitType);
 }
示例#19
0
 public void NewValueSpecifiedUnits(SVGLengthType unitType, double valueInSpecifiedUnits)
 {
 }
示例#20
0
 public SVGLength(float valueInSpecifiedUnits)
 {
     _unitType = SVGLengthType.Number;
     _valueInSpecifiedUnits = valueInSpecifiedUnits;
     _value = SVGLengthConvertor.ConvertToPX(_valueInSpecifiedUnits, _unitType);
 }
示例#21
0
 public SVGLength(SVGLengthType unitType, float valueInSpecifiedUnits)
 {
     _unitType = unitType;
     _valueInSpecifiedUnits = valueInSpecifiedUnits;
     _value = SVGLengthConvertor.ConvertToPX(_valueInSpecifiedUnits, _unitType);
 }
示例#22
0
 public void NewValueSpecifiedUnits(float valueInSpecifiedUnits)
 {
     _unitType = SVGLengthType.Unknown;
     _valueInSpecifiedUnits = valueInSpecifiedUnits;
     _value = ConvertToPX(_valueInSpecifiedUnits, _unitType);
 }
示例#23
0
 public void ConvertToSpecifiedUnits(SVGLengthType unitType)
 {
 }