Beispiel #1
0
        /// <summary>
        /// Get the value as the specified medium possibly using the parents
        /// value in the calculation.
        /// </summary>
        public float Get(ValueMedium medium, int parentPixels)
        {
            switch (Medium)
            {
            case ValueMedium.Percent:
                switch (medium)
                {
                case ValueMedium.Percent:
                    return(Value / 10000.0f);

                case ValueMedium.Pixels:
                    return((Value / 10000.0f) * parentPixels);
                }
                break;

            case ValueMedium.Pixels:
                switch (medium)
                {
                case ValueMedium.Percent:
                    return((float)parentPixels / Value);
                }
                break;
            }
            return(Value);
        }
Beispiel #2
0
        /// <summary>
        /// Set the value as the specified medium.
        /// </summary>
        public void Set(float value, ValueMedium medium)
        {
            Medium = medium;
            switch (Medium)
            {
            case ValueMedium.Percent:
                Value = (int)(value * 10000);
                break;

            default:
                Value = (int)value;
                break;
            }
        }
Beispiel #3
0
 public ScalarValue(int value, ValueMedium medium)
 {
     Value  = value;
     Medium = medium;
 }