Profile Picture

Convert value of NLength to different measurement unit

Posted By Kevin Harrison 11 Years Ago
Author
Message
Nevron Support
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 6 hours ago
Posts: 3,054, Visits: 4,012
Hi Kevin,

Yes there is an easy way to convert values from one measurement unit to another. The following code shows how to create and initialize a measurement unit converter class that can be used to perform this conversion:

NMeasurementUnitConverter converter = new NMeasurementUnitConverter(NResolution.ScreenResolution);

NSizeF rootSize = new NSizeF(200, 200);
NSizeF parentSize = new NSizeF(100, 100);
converter.InitializeRelativeMembers(rootSize, parentSize);

float parentPercentage = converter.ConvertX(NGraphicsUnit.Pixel, NRelativeUnit.ParentPercentage, 10);

Note that in general the conversion is defined when you specify x/y resolution, x/y parent size (used by the ParentPercentage unit) and x/y root size (used by the RootPercentageUnit). Hope this helps - let us know if you have any questions...

Best Regards,
Nevron Support Team



Kevin Harrison
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 176, Visits: 1,865

Is it possible to easily an NLength in one measurement unit into a different measurement unit?

e.g. I have a length in NGraphicsUnit.Pixel which I want to convert to NRelativeUnit.ParentPercentage

Thanks

Kevin





Similar Topics


Reading This Topic