Esempio n. 1
0
        public string ToDisplayString(DynamoUnitDisplayType unitType)
        {
            switch (unitType)
            {
            case DynamoUnitDisplayType.FRACTIONAL_INCHES:
                return(Utils.ToFractionalInches(Item.ConvertTo(DynamoUnitType.INCHES)));

            case DynamoUnitDisplayType.DECIMAL_INCHES:
                return(Item.ConvertTo(DynamoUnitType.INCHES).ToString("0.00", CultureInfo.CurrentCulture) + " in");

            case DynamoUnitDisplayType.DECIMAL_FEET:
                return(Item.ConvertTo(DynamoUnitType.FEET).ToString("0.00", CultureInfo.CurrentCulture) + " ft");

            case DynamoUnitDisplayType.FRACTIONAL_FEET_INCHES:
                return(Utils.ToFeetAndFractionalInches(Item.ConvertTo(DynamoUnitType.FEET)));

            case DynamoUnitDisplayType.MILLIMETERS:
                return(Item.ConvertTo(DynamoUnitType.MILLIMETERS).ToString("0.00", CultureInfo.CurrentCulture) + " mm");

            case DynamoUnitDisplayType.CENTIMETERS:
                return(Item.ConvertTo(DynamoUnitType.CENTIMETERS).ToString("0.00", CultureInfo.CurrentCulture) + " cm");

            case DynamoUnitDisplayType.METERS:
                return(Item.ConvertTo(DynamoUnitType.METERS).ToString("0.00", CultureInfo.CurrentCulture) + " m");

            default:
                return(ToString());
            }
        }
Esempio n. 2
0
        public static double FromDisplayString(string value, DynamoUnitDisplayType unitType)
        {
            switch (unitType)
            {
            case DynamoUnitDisplayType.FractionalInches:
                return(ConvertFrom(Utils.FromFeetAndFractionalInches(value), DynamoUnitType.Feet));

            case DynamoUnitDisplayType.DecimalInches:
                return(ConvertFrom(Utils.ParseUnit(value, "in"), DynamoUnitType.Inches));

            case DynamoUnitDisplayType.DecimalFeet:
                return(ConvertFrom(Utils.ParseUnit(value, "ft"), DynamoUnitType.Feet));

            case DynamoUnitDisplayType.FractionalFeetInches:
                return(ConvertFrom(Utils.FromFeetAndFractionalInches(value), DynamoUnitType.Feet));

            case DynamoUnitDisplayType.Millimeters:
                return(ConvertFrom(Utils.ParseUnit(value, "mm"), DynamoUnitType.Millimeters));

            case DynamoUnitDisplayType.Centimeters:
                return(ConvertFrom(Utils.ParseUnit(value, "cm"), DynamoUnitType.Centimeters));

            case DynamoUnitDisplayType.Meters:
                return(ConvertFrom(Utils.ParseUnit(value, "m"), DynamoUnitType.Meters));

            default:
                return(0.0);
            }
        }
Esempio n. 3
0
        public static string ToDisplayString(double value, DynamoUnitDisplayType unitType)
        {
            switch (unitType)
            {
            case DynamoUnitDisplayType.FractionalInches:
                return(Utils.ToFractionalInches(ConvertTo(value, DynamoUnitType.Inches)));

            case DynamoUnitDisplayType.DecimalInches:
                return(ConvertTo(value, DynamoUnitType.Inches).ToString("0.00", CultureInfo.CurrentCulture) + " in");

            case DynamoUnitDisplayType.DecimalFeet:
                return(ConvertTo(value, DynamoUnitType.Feet).ToString("0.00", CultureInfo.CurrentCulture) + " ft");

            case DynamoUnitDisplayType.FractionalFeetInches:
                return(Utils.ToFeetAndFractionalInches(ConvertTo(value, DynamoUnitType.Feet)));

            case DynamoUnitDisplayType.Millimeters:
                return(ConvertTo(value, DynamoUnitType.Millimeters).ToString("0.00", CultureInfo.CurrentCulture) + " mm");

            case DynamoUnitDisplayType.Centimeters:
                return(ConvertTo(value, DynamoUnitType.Centimeters).ToString("0.00", CultureInfo.CurrentCulture) + " cm");

            case DynamoUnitDisplayType.Meters:
                return(ConvertTo(value, DynamoUnitType.Meters).ToString("0.00", CultureInfo.CurrentCulture) + " m");

            default:
                return(value.ToString());
            }
        }
Esempio n. 4
0
        public void FromDisplayString(string value, DynamoUnitDisplayType unitType)
        {
            switch (unitType)
            {
            case DynamoUnitDisplayType.FRACTIONAL_INCHES:
                Item.ConvertFrom(Utils.FromFeetAndFractionalInches(value), DynamoUnitType.FEET);
                break;

            case DynamoUnitDisplayType.DECIMAL_INCHES:
                Item.ConvertFrom(Utils.ParseUnit(value, "in"), DynamoUnitType.INCHES);
                break;

            case DynamoUnitDisplayType.DECIMAL_FEET:
                Item.ConvertFrom(Utils.ParseUnit(value, "ft"), DynamoUnitType.FEET);
                break;

            case DynamoUnitDisplayType.FRACTIONAL_FEET_INCHES:
                Item.ConvertFrom(Utils.FromFeetAndFractionalInches(value), DynamoUnitType.FEET);
                break;

            case DynamoUnitDisplayType.MILLIMETERS:
                Item.ConvertFrom(Utils.ParseUnit(value, "mm"), DynamoUnitType.MILLIMETERS);
                break;

            case DynamoUnitDisplayType.CENTIMETERS:
                Item.ConvertFrom(Utils.ParseUnit(value, "cm"), DynamoUnitType.CENTIMETERS);
                break;

            case DynamoUnitDisplayType.METERS:
                Item.ConvertFrom(Utils.ParseUnit(value, "m"), DynamoUnitType.METERS);
                break;

            default:
                Item.Length = 0.0;
                break;
            }
        }
Esempio n. 5
0
        public static string ToDisplayString(double value, DynamoUnitDisplayType unitType)
        {
            switch (unitType)
            {
                case DynamoUnitDisplayType.FractionalInches:
                    return Utils.ToFractionalInches(ConvertTo(value, DynamoUnitType.Inches));

                case DynamoUnitDisplayType.DecimalInches:
                    return ConvertTo(value, DynamoUnitType.Inches).ToString("0.00", CultureInfo.CurrentCulture) + " in";

                case DynamoUnitDisplayType.DecimalFeet:
                    return ConvertTo(value, DynamoUnitType.Feet).ToString("0.00", CultureInfo.CurrentCulture) + " ft";

                case DynamoUnitDisplayType.FractionalFeetInches:
                    return Utils.ToFeetAndFractionalInches(ConvertTo(value, DynamoUnitType.Feet));

                case DynamoUnitDisplayType.Millimeters:
                    return ConvertTo(value, DynamoUnitType.Millimeters).ToString("0.00", CultureInfo.CurrentCulture) + " mm";

                case DynamoUnitDisplayType.Centimeters:
                    return ConvertTo(value, DynamoUnitType.Centimeters).ToString("0.00", CultureInfo.CurrentCulture) + " cm";

                case DynamoUnitDisplayType.Meters:
                    return ConvertTo(value, DynamoUnitType.Meters).ToString("0.00", CultureInfo.CurrentCulture) + " m";

                default:
                    return value.ToString();
            }
        }
Esempio n. 6
0
 public static double FromDisplayString(string value, DynamoUnitDisplayType unitType)
 {
     switch (unitType)
     {
         case DynamoUnitDisplayType.FractionalInches:
             return ConvertFrom(Utils.FromFeetAndFractionalInches(value), DynamoUnitType.Feet);
         case DynamoUnitDisplayType.DecimalInches:
             return ConvertFrom(Utils.ParseUnit(value, "in"), DynamoUnitType.Inches);
         case DynamoUnitDisplayType.DecimalFeet:
             return ConvertFrom(Utils.ParseUnit(value, "ft"), DynamoUnitType.Feet);
         case DynamoUnitDisplayType.FractionalFeetInches:
             return ConvertFrom(Utils.FromFeetAndFractionalInches(value), DynamoUnitType.Feet);
         case DynamoUnitDisplayType.Millimeters:
             return ConvertFrom(Utils.ParseUnit(value, "mm"), DynamoUnitType.Millimeters);
         case DynamoUnitDisplayType.Centimeters:
             return ConvertFrom(Utils.ParseUnit(value, "cm"), DynamoUnitType.Centimeters);
         case DynamoUnitDisplayType.Meters:
             return ConvertFrom(Utils.ParseUnit(value, "m"), DynamoUnitType.Meters);
         default:
             return 0.0;
     }
 }