🚀 Welcome to MDriven Learn –  Don’t miss the latest Release Notes.
Metric and imperial units

In multicultural systems, it may be important to handle imperial types for numbers.

In this MDriven-supported approach, the value stored is always in the metric system, but you can allow for display and editing in the Imperial system.

The settings are controlled by a model pattern that is part of the SysTranslations merge model that is described here Documentation:Localization - MDrivenWiki.

The important settings for MetricImperial are:

SysCultureSettingsSingleton.MetricNotImperial_Area:Boolean=true
SysCultureSettingsSingleton.MetricNotImperial_Length:Boolean=true
SysCultureSettingsSingleton.MetricNotImperial_Temperature:Boolean=true
SysCultureSettingsSingleton.MetricNotImperial_Velocity:Boolean=true
SysCultureSettingsSingleton.MetricNotImperial_Volume:Boolean=true
SysCultureSettingsSingleton.MetricNotImperial_Weight:Boolean=true

You would probably make this derived - and let each user store their own value for this setting.

The functionality is used by setting a tagged value on an Attribute of type decimal, float, double, or int to MetricImperial with one of the following values:

GramOunce (Weight),

MillimeterInch (Length),

MilliliterFluidOunce (Volume),

CelsiusFahrenheit (Temperature),

SquareKilometersSquareMiles (Area),

SquareMetersSquareFeet (Area),

SquareCentimetersSquareInches (Area),

KilometersPerHourMilesPerHour (Velocity),

MetersPerSecondFeetPerSecond (Velocity)

You may also set the MetricImperialUIDecimals tagged value to an integer to control how many decimals are used after conversion. The default value if it is not given is 2*SysCultureSettingsSingleton.DefaultDecimalDisplay (DefaultDecimalDisplay defaults to 2 if not given).

Presentation unit

This functionality hijacks the PresentationUnit and sets it and updates it according to the MetricNotImperial setting.

Example:

Label : The temp (°C) will turn into The temp (°F) when MetricNotImperial_Temperature=false