Пример #1
0
        public void Include()
        {
            if (_term != null)
            {
                _termList.Add(_term);
            }

            _term = null;
        }
Пример #2
0
 private static byte ToByte(Term cssValue)
 {
     return ToByte(((PrimitiveTerm)cssValue).GetFloatValue(UnitType.Number));
 }
Пример #3
0
 private static Single ToSingle(Term cssValue)
 {
     var value = ((PrimitiveTerm)cssValue).GetFloatValue(UnitType.Number);
         
     return value.HasValue 
         ? value.Value 
         : 0f;
 }
Пример #4
0
 private static bool CheckNumber(Term cssValue)
 {
     return (cssValue is PrimitiveTerm && 
             ((PrimitiveTerm)cssValue).PrimitiveType == UnitType.Number);
 }
Пример #5
0
 private static bool CheckPercentage(Term cssValue)
 {
     return (cssValue is PrimitiveTerm &&
             (((PrimitiveTerm)cssValue).PrimitiveType == UnitType.Number ||
             ((PrimitiveTerm)cssValue).PrimitiveType == UnitType.Percentage));
 }
Пример #6
0
        /// <summary>
        /// Gets the RGB value.
        /// </summary>
        /// <param name="term">The term.</param>
        /// <returns></returns>
        private static int GetRGBValue(Term term)
        {
            try
            {
                if (term.Unit.HasValue && term.Unit.Value == Model.Unit.Percent)
                {
                    return (int)(255f * float.Parse(term.Value) / 100f);
                }

                return int.Parse(term.Value);
            }
            catch
            {
                ;
            }

            return 0;
        }
Пример #7
0
        /// <summary>
        /// Gets the hue.
        /// </summary>
        /// <param name="term">The term.</param>
        /// <returns></returns>
        private static int GetHueValue(Term term)
        {
            // 0 - 360
            try
            {
                return (int)(float.Parse(term.Value) * 255f / 360f);
            }
            catch
            {
                ;
            }

            return 0;
        }