Example #1
0
        public static string FormatLargeMass(float massKg, bool isMetric, bool isUK)
        {
            if (isMetric)
            {
                return(FormatMass(massKg, isMetric));
            }

            var massT = isUK ? Kg.ToTUK(massKg) : Kg.ToTUS(massKg);

            if (massT > 1)
            {
                return(String.Format(CultureInfo.CurrentCulture, "{0:F1} {1}", massT, isUK ? tonUK : tonUS));
            }
            else
            {
                return(FormatMass(massKg, isMetric));
            }
        }
Example #2
0
 /// <summary>
 /// format localized mass string, as displayed in in-game windows.
 /// </summary>
 /// <param name="massKg">mass in kg or in Lb</param>
 /// <param name="isMetric">use kg if true, Lb if false</param>
 public static string FormatMass(float massKg, bool isMetric)
 {
     if (isMetric)
     {
         // < 1 tons, show kilograms.
         float massInTonne = Kg.ToTonne(massKg);
         if (Math.Abs(massInTonne) > 1)
         {
             return(String.Format(CultureInfo.CurrentCulture, "{0:F1} {1}", massInTonne, t));
         }
         else
         {
             return(String.Format(CultureInfo.CurrentCulture, "{0:F0} {1}", massKg, kg));
         }
     }
     else
     {
         return(String.Format(CultureInfo.CurrentCulture, "{0:F0} {1}", Kg.ToLb(massKg), lb));
     }
 }