Пример #1
0
 private static float CalculateValue(UnitValue value, float fullValue)
 {
     if (value == null)
     {
         return(0);
     }
     return(value.IsPercentValue() ? (value.GetValue() / 100 * fullValue) : value.GetValue());
 }
Пример #2
0
        /// <summary>Converts all percentage and enum values to point equivalent.</summary>
        /// <param name="fullWidth">container width to calculate percentage.</param>
        /// <param name="fullHeight">container height to calculate percentage.</param>
        /// <param name="outXValue">
        ///
        /// <see cref="UnitValue"/>
        /// to store processed xPosition.
        /// </param>
        /// <param name="outYValue">
        ///
        /// <see cref="UnitValue"/>
        /// to store processed yPosition.
        /// </param>
        public virtual void CalculatePositionValues(float fullWidth, float fullHeight, UnitValue outXValue, UnitValue
                                                    outYValue)
        {
            int posMultiplier = ParsePositionXToUnitValueAndReturnMultiplier(outXValue);

            if (posMultiplier == 0 && xShift != null && Math.Abs(xShift.GetValue()) > EPS)
            {
                outXValue.SetValue(0);
            }
            else
            {
                outXValue.SetValue(CalculateValue(outXValue, fullWidth) + CalculateValue(xShift, fullWidth) * posMultiplier
                                   );
            }
            outXValue.SetUnitType(UnitValue.POINT);
            posMultiplier = ParsePositionYToUnitValueAndReturnMultiplier(outYValue);
            if (posMultiplier == 0 && yShift != null && Math.Abs(yShift.GetValue()) > EPS)
            {
                outYValue.SetValue(0);
            }
            else
            {
                outYValue.SetValue(CalculateValue(outYValue, fullHeight) + CalculateValue(yShift, fullHeight) * posMultiplier
                                   );
            }
            outYValue.SetUnitType(UnitValue.POINT);
        }