public static GradientStop?ToGradientStop(this CSSValue value, Single defaultStop = 0f) { var list = value as CSSValueList; Color? color = null; IDistance location = new Percent(defaultStop); if (list != null) { if (list.Length != 2) { return(null); } color = list[0].ToColor(); location = list[1].ToDistance(); } else { color = value.ToColor(); } if (color == null || location == null) { return(null); } return(new GradientStop(color.Value, location)); }
/// <summary> /// Determines if the given value represents a valid state of this property. /// </summary> /// <param name="value">The state that should be used.</param> /// <returns>True if the state is valid, otherwise false.</returns> protected override Boolean IsValid(CSSValue value) { var color = value.ToColor(); if (color.HasValue) _color = color.Value; else if (value != CSSValue.Inherit) return false; return true; }
protected override Boolean IsValid(CSSValue value) { var color = value.ToColor(); if (color.HasValue) { _color = color.Value; } else if (value != CSSValue.Inherit) { return(false); } return(true); }
protected override Boolean IsValid(CSSValue value) { var color = value.ToColor(); if (color.HasValue) { _mode = new SolidColorMode(color.Value); } else if (value.Is("invert")) { _mode = _invert; } else if (value != CSSValue.Inherit) { return(false); } return(true); }
protected override Boolean IsValid(CSSValue value) { if (value == CSSValue.Inherit) { return(true); } var width = Length.Medium; var color = Color.Transparent; var style = LineStyle.None; if (value is CSSValueList) { var values = (CSSValueList)value; if (values.Length > 3) { return(false); } Length? w = null; Color? c = null; LineStyle?s = null; foreach (var v in values) { if (!w.HasValue && (w = v.ToBorderWidth()).HasValue) { width = w.Value; } else if (!c.HasValue && (c = v.ToColor()).HasValue) { color = c.Value; } else if (!s.HasValue && (s = v.ToLineStyle()).HasValue) { style = s.Value; } else { return(false); } } } else { var w = value.ToBorderWidth(); var c = value.ToColor(); var s = value.ToLineStyle(); if (w.HasValue) { width = w.Value; } else if (c.HasValue) { color = c.Value; } else if (s.HasValue) { style = s.Value; } else { return(false); } } _width = width; _color = color; _style = style; return(true); }