private static double convertToCm(double value, units unit) { if (unit.Equals(units.inches)) { value = value / 0.393700787; } if (unit.Equals(units.pts)) { value = value / 28.3464567; } return(value); }
private static double convertToInches(double value, units unit) { if (unit.Equals(units.cm)) { value = value * 0.393700787; } if (unit.Equals(units.pts)) { value = value * 0.013836; } return(value); }
private static double convertToPoints(double value, units unit) { if (unit.Equals(units.inches)) { value = value / 0.013836; } if (unit.Equals(units.cm)) { value = value * 28.3464567; } return(value); }
public static double convertLengthUnits(double value, units newUnit, units oldUnit) { if (newUnit.Equals(oldUnit)) { return(value); } switch (newUnit) { case units.pts: return(convertToPoints(value, oldUnit)); case units.inches: return(convertToInches(value, oldUnit)); case units.cm: return(convertToCm(value, oldUnit)); } return(0); }
private static double convertToPoints(double value, units unit) { if (unit.Equals(units.inches)) { value = value / 0.013836; } if (unit.Equals(units.cm)) { value = value * 28.3464567; } return value; }
private static double convertToInches(double value, units unit) { if (unit.Equals(units.cm)) { value = value * 0.393700787; } if (unit.Equals(units.pts)) { value = value * 0.013836; } return value; }
private static double convertToCm(double value, units unit) { if (unit.Equals(units.inches)) { value = value / 0.393700787; } if (unit.Equals(units.pts)) { value = value / 28.3464567; } return value; }
public static double convertLengthUnits(double value, units newUnit, units oldUnit) { if (newUnit.Equals(oldUnit)) return value; switch (newUnit) { case units.pts: return convertToPoints(value, oldUnit); case units.inches: return convertToInches(value, oldUnit); case units.cm: return convertToCm(value, oldUnit); } return 0; }