private double ConvertNum(double num, int codeFrom, int codeTo, UnitTable table)
        {
            //if (num == 0)
            //{
            //    return 0;
            //}
            //else
            if (codeFrom == codeTo)
            {
                return(num);
            }
            else
            {
                Unit unit = new Unit(codeFrom, /*float.Parse(num.ToString())*/ num, table);
                //return Math.Round(Convert.ToDouble(unit.Convert(codeTo).Value), 10, MidpointRounding.AwayFromZero);

                return(Convert.ToDouble(unit.Convert(codeTo).Value));
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new Unit
 /// </summary>
 /// <param name="unitCode">Unit's code</param>
 /// <param name="unitValue">Unit's value</param>
 /// <param name="table">Unit's table</param>
 public Unit(int unitCode, /*float*/ double unitValue, UnitTable table)
 {
     unt_Value.Code  = unitCode;
     unt_Value.Value = unitValue;
     tbl_UnitTable   = table;
 }
        public double ConvertViscosity(double num, int codeFrom, int codeTo)
        {
            UnitTable table = UnitTable.ViscosityTable;

            return(ConvertNum(num, codeFrom, codeTo, table));
        }
        public double ConvertVolumeFlowRatePerArea(double num, int codeFrom, int codeTo)
        {
            UnitTable table = UnitTable.VolumeFlowRatePerAreaTable;

            return(ConvertNum(num, codeFrom, codeTo, table));
        }
        public double ConvertSurfaceTension(double num, int codeFrom, int codeTo)
        {
            UnitTable table = UnitTable.SurfaceTensionTable;

            return(ConvertNum(num, codeFrom, codeTo, table));
        }
        public double ConvertMassFlowRate(double num, int codeFrom, int codeTo)
        {
            UnitTable table = UnitTable.MassFlowRateTable;

            return(ConvertNum(num, codeFrom, codeTo, table));
        }
        public double ConvertWeight(double num, int codeFrom, int codeTo)
        {
            UnitTable table = UnitTable.WeightTable;

            return(ConvertNum(num, codeFrom, codeTo, table));
        }
        public double ConvertVolume(double num, int codeFrom, int codeTo)
        {
            UnitTable table = UnitTable.VolumeTable;

            return(ConvertNum(num, codeFrom, codeTo, table));
        }
        public double ConvertTemperature(double num, int codeFrom, int codeTo)
        {
            UnitTable table = UnitTable.TemperatureTable;

            return(ConvertNum(num, codeFrom, codeTo, table));
        }
        public double ConvertLength(double num, int codeFrom, int codeTo)
        {
            UnitTable table = UnitTable.LengthTable;

            return(ConvertNum(num, codeFrom, codeTo, table));
        }
        public double ConvertAreaUnits(double num, int codeFrom, int codeTo)
        {
            UnitTable table = UnitTable.AreaTable;

            return(ConvertNum(num, codeFrom, codeTo, table));
        }
        public double ConvertMomentumUnits(double num, int codeFrom, int codeTo)
        {
            UnitTable table = UnitTable.MomentumTable;

            return(ConvertNum(num, codeFrom, codeTo, table));
        }
        public double ConvertPressureDrop(double num, int codeFrom, int codeTo)
        {
            UnitTable table = UnitTable.PressureDrop;

            return(ConvertNum(num, codeFrom, codeTo, table));
        }