Scientific calculations often require measurement unit conversion and demand high accuracy. Although it may be very easy to google around the web and get some formula, however when we looked into SI units and its Unit Guide, then we realized that even units with same name have little different value in different countries and continents.

So we decided to bring them all into User Interface control for WPF and Silverlight.

  1. Which allows Developer to adhere to one standard unit.
  2. Which allows users to choose unit of their own choice.
  3. See the conversion while editing the value.

MeasurementControlPart1

 

The following sample code displays how to use these unit converters in Silverlight and WPF.

Properties

Each of the measurement unit converter controls has four properties as mentioned below.

DisplayValue Property:

This is the editable value displayed in the text box, and user can directly modify this value by either using up/down arrow buttons or by typing in the value. The display value works in conjunction with the type of unit that is selected in Display Unit ID property.

DisplayUnitID Property:

Every measurement unit has different ID assigned by our developers to uniquely identify alpha numeric ID within the set of units. For example, meter and centimeter are IDs of Length. However you do not have to remember these IDs, when you edit your UI in Visual Studio, you can configure these IDs in the property editor. End user can visually modify Display Unit in order to retrieve and enter value in the desired unit.

ValueUnitID Property:

The DisplayUnitID is attached to DisplayValue, similarly the underlying actual value is attached with ValueUnitID property. This Unit ID is usually set to a constant throughout the lifetime of the application and is already defaulted to SI unit. e.g. for Length, it is set to meter. We recommend you to change this only if your base unit requirement is something different then SI unit. This unit can not be changed by end user it can only be programmed in the code at design time.

Value Property:

The value property is something which you are interested saving in the database and use it as base value. This is the converted value of unit ValueUnitID specified from display value of display unit.

Example:

In the first control in the above picture, Display Value is 100, Display Unit is Fathom, Value Unit is meter, so converted value in meter is 182.8804.

Live Sample:

Click here to view live sample in Silverlight.

Download Demo:

Click here to download the demo version of UI Atoms.

Share
Tagged with:  

UI Atoms 2010 v1.1 Released

On May 5, 2010, in C#, Programming, by Akash Kava

New update of UI Atoms 2010 v1.1 is now available, it includes fixes for Silverlight 4 and new controls as per following list.

Update 1.1

  1. UI Atoms is now upgraded to Silverlight 4, all binding workarounds have been removed.
  2. Six New Measurement Unit Controls have been added.

Measurement Unit Controls

Scientific measurements are complex and wide range of units are used everywhere, though conversions are not difficult but it is not possible to carry and remember all conversions and correct formulae.

UI Atoms 2010 v1.1 brings power of SI units conversion in set of following Measurement Unit Controls.

  • AtomLengthEditor – helps in conversion of “Length” units.
  • AtomTemperatureEditor – helps in conversion of “Temperature” units.
  • AtomTimeEditor – helps in conversion of “Time” units.
  • AtomVelocityEditor – helps in conversion of “Velocity” units.
  • AtomVolumeEditor – helps in conversion of “Volume” units.
  • AtomWeightEditor – helps in conversion of “Weight” units.

MeasurementControls Currently, these controls offers very simple GUI as first draft, however you can see the number of units that are available that can help users view/edit the value in any desired unit.

Share
Tagged with: