Пример #1
0
 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);
 }
Пример #2
0
 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);
 }
Пример #3
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);
 }
Пример #4
0
        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);
        }
Пример #5
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;
 }
Пример #6
0
 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;
 }
Пример #7
0
 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;
 }
Пример #8
0
        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;
        }