/***********************************************************************************/ 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; }
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)); }
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 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; } }
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; } }
/***********************************************************************************/ 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); }
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; } } }
/***********************************************************************************/ 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); } }
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); } }
public void ConvertToSpecifiedUnits(SVGLengthType unitType) { }
public void NewValueSpecifiedUnits(SVGLengthType unitType, float valueInSpecifiedUnits) { }
public void NewValueSpecifiedUnits(float valueInSpecifiedUnits) { _unitType = (SVGLengthType)0; _valueInSpecifiedUnits = valueInSpecifiedUnits; _value = SVGLengthConvertor.ConvertToPX(_valueInSpecifiedUnits, _unitType); }
public void NewValueSpecifiedUnits(float valueInSpecifiedUnits) { _unitType = SVGLengthType.Unknown; _valueInSpecifiedUnits = valueInSpecifiedUnits; _value = ConvertToPX(_valueInSpecifiedUnits, _unitType); }
public SVGLength(float valueInSpecifiedUnits) { _unitType = SVGLengthType.Number; _valueInSpecifiedUnits = valueInSpecifiedUnits; _value = SVGLengthConvertor.ConvertToPX(_valueInSpecifiedUnits, _unitType); }
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; } } }
public void NewValueSpecifiedUnits(float valueInSpecifiedUnits) { _unitType = (SVGLengthType)0; _valueInSpecifiedUnits = valueInSpecifiedUnits; _value = SVGLengthConvertor.ConvertToPX(_valueInSpecifiedUnits, _unitType); }
public SVGLength(SVGLengthType unitType, float valueInSpecifiedUnits) { _unitType = unitType; _valueInSpecifiedUnits = valueInSpecifiedUnits; _value = SVGLengthConvertor.ConvertToPX(_valueInSpecifiedUnits, _unitType); }
public void NewValueSpecifiedUnits(SVGLengthType unitType, double valueInSpecifiedUnits) { }
public SVGLength(float valueInSpecifiedUnits) { _unitType = SVGLengthType.Number; _valueInSpecifiedUnits = valueInSpecifiedUnits; _value = SVGLengthConvertor.ConvertToPX(_valueInSpecifiedUnits, _unitType); }
public SVGLength(SVGLengthType unitType, float valueInSpecifiedUnits) { _unitType = unitType; _valueInSpecifiedUnits = valueInSpecifiedUnits; _value = SVGLengthConvertor.ConvertToPX(_valueInSpecifiedUnits, _unitType); }
public void NewValueSpecifiedUnits(float valueInSpecifiedUnits) { _unitType = SVGLengthType.Unknown; _valueInSpecifiedUnits = valueInSpecifiedUnits; _value = ConvertToPX(_valueInSpecifiedUnits, _unitType); }
public void ConvertToSpecifiedUnits(SVGLengthType unitType) { }