public void Include() { if (_term != null) { _termList.Add(_term); } _term = null; }
private static byte ToByte(Term cssValue) { return ToByte(((PrimitiveTerm)cssValue).GetFloatValue(UnitType.Number)); }
private static Single ToSingle(Term cssValue) { var value = ((PrimitiveTerm)cssValue).GetFloatValue(UnitType.Number); return value.HasValue ? value.Value : 0f; }
private static bool CheckNumber(Term cssValue) { return (cssValue is PrimitiveTerm && ((PrimitiveTerm)cssValue).PrimitiveType == UnitType.Number); }
private static bool CheckPercentage(Term cssValue) { return (cssValue is PrimitiveTerm && (((PrimitiveTerm)cssValue).PrimitiveType == UnitType.Number || ((PrimitiveTerm)cssValue).PrimitiveType == UnitType.Percentage)); }
/// <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; }
/// <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; }