protected override Boolean IsValid(CSSValue value) { if (value == CSSValue.Inherit) { return(true); } var values = value as CSSValueList ?? new CSSValueList(value); var origins = new List <BoxModel>(); for (int i = 0; i < values.Length; i++) { var origin = values[i].ToBoxModel(); if (!origin.HasValue) { return(false); } origins.Add(origin.Value); if (++i < values.Length && values[i] != CSSValue.Separator) { return(false); } } _origins = origins; return(true); }
public static Boolean TryGetValue <T>(this Dictionary <String, T> obj, CSSValue value, out T mode) { var primitive = value as CSSPrimitiveValue; mode = default(T); return(primitive != null && primitive.Unit == UnitType.Ident && obj.TryGetValue(primitive.GetString(), out mode)); }
protected override Boolean IsValid(CSSValue value) { var length = value.ToLength(); if (length.HasValue) { _h = _v = length.Value; } else if (value is CSSValueList) { var values = (CSSValueList)value; if (values.Length != 2) { return(false); } var h = values[0].ToLength(); var v = values[1].ToLength(); if (!h.HasValue || !v.HasValue) { return(false); } _h = h.Value; _v = v.Value; } else if (value != CSSValue.Inherit) { return(false); } return(true); }
/// <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) { if (value.Is("none")) _quotes.Clear(); else if (value is CSSValueList) { var values = (CSSValueList)value; if (values.Length % 2 != 0) return false; var quotes = new List<Tuple<String, String>>(); for (int i = 0; i < values.Length; i += 2) { var open = values[i] as CSSStringValue; var close = values[i + 1] as CSSStringValue; if (open == null || close == null) return false; quotes.Add(Tuple.Create(open.Value, close.Value)); } _quotes = quotes; } else if (value != CSSValue.Inherit) return false; return true; }
protected override Boolean IsValid(CSSValue value) { if (value == CSSValue.Inherit) { return(true); } var list = value as CSSValueList ?? new CSSValueList(value); var attachments = new List <BackgroundAttachment>(); for (int i = 0; i < list.Length; i++) { BackgroundAttachment attachment; if (list[i] is CSSIdentifierValue && _modes.TryGetValue(((CSSIdentifierValue)list[i]).Value, out attachment)) { attachments.Add(attachment); } else { return(false); } if (++i < list.Length && list[i] != CSSValue.Separator) { return(false); } } _attachments = attachments; return(true); }
protected override Boolean IsValid(CSSValue value) { var values = value.AsList <CSSIdentifierValue>(); if (values != null) { var fillModes = new List <AnimationDirection>(); foreach (var item in values) { var direction = item.ToDirection(); if (!direction.HasValue) { return(false); } fillModes.Add(direction.Value); } _directions = fillModes; } else if (value != CSSValue.Inherit) { return(false); } return(true); }
/// <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 length = value.ToLength(); if (length.HasValue) _h = _v = length.Value; else if (value is CSSValueList) { var values = (CSSValueList)value; if (values.Length != 2) return false; var h = values[0].ToLength(); var v = values[1].ToLength(); if (!h.HasValue || !v.HasValue) return false; _h = h.Value; _v = v.Value; } else if (value != CSSValue.Inherit) return false; return true; }
protected override Boolean IsValid(CSSValue value) { if (value == CSSValue.Inherit) { return(true); } var list = value as CSSValueList ?? new CSSValueList(value); var clips = new List <BoxModel>(); for (int i = 0; i < list.Length; i++) { var clip = list[i].ToBoxModel(); if (!clip.HasValue) { return(false); } clips.Add(clip.Value); if (++i < list.Length && list[i] != CSSValue.Separator) { return(false); } } _clips = clips; return(true); }
protected override Boolean IsValid(CSSValue value) { if (value.Is("none")) { _properties.Clear(); } else if (value is CSSIdentifierValue) { _properties.Clear(); _properties.Add(((CSSIdentifierValue)value).Value); } else if (value is CSSValueList) { var values = value.AsList <CSSIdentifierValue>(); if (values == null) { return(false); } _properties.Clear(); foreach (var ident in values) { _properties.Add(ident.Value); } } else if (value != CSSValue.Inherit) { return(false); } return(true); }
protected override Boolean IsValid(CSSValue value) { var list = value as CSSValueList; var v1 = value; var v2 = value; if (list != null) { if (list.Length != 2) { return(false); } v1 = list[0]; v2 = list[1]; } var c1 = v1.AsCalc(); var c2 = v2.AsCalc(); if (c1 != null && c2 != null) { _h = c1; _v = c2; } else if (value != CSSValue.Inherit) { return(false); } return(true); }
static CustomFontFamily FromIdentifiers(CSSValue value) { if (value is CSSIdentifierValue) { return(new CustomFontFamily(((CSSIdentifierValue)value).Value)); } else if (value is CSSValueList) { var list = (CSSValueList)value; var content = new String[list.Length]; for (var i = 0; i < list.Length; i++) { if (list[i] is CSSIdentifierValue) { content[i] = ((CSSIdentifierValue)list[i]).Value; } else { return(null); } } return(new CustomFontFamily(String.Join(" ", content))); } return(null); }
/// <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) { if (value.Is("none")) _names.Clear(); else if (value is CSSIdentifierValue) { _names.Clear(); _names.Add(((CSSIdentifierValue)value).Value); } else if (value is CSSValueList) { var values = value.AsList<CSSIdentifierValue>(); if (values == null) return false; _names.Clear(); foreach (var ident in values) _names.Add(ident.Value); } else if (value != CSSValue.Inherit) return false; return true; }
protected override Boolean IsValid(CSSValue value) { var values = value.AsList <CSSIdentifierValue>(); if (values != null) { var states = new List <PlayState>(); foreach (var item in values) { if (item.Is("running")) { states.Add(PlayState.Running); } else if (item.Is("paused")) { states.Add(PlayState.Paused); } else { return(false); } } _states = states; } else if (value != CSSValue.Inherit) { return(false); } return(true); }
public static Angle?ToSideOrCorner(this CSSValue value) { var values = value as CSSValueList; if (values != null && values.Length > 1 && values[0].Is(Keywords.To)) { if (values.Length == 2) { var val = 0f; if (horizontalModes.TryGetValue(values[1], out val)) { return(new Angle(270f - val * 180f, Angle.Unit.Deg)); } else if (verticalModes.TryGetValue(values[1], out val)) { return(new Angle(val * 180f, Angle.Unit.Deg)); } } else if (values.Length == 3) { var h = 0f; var v = 0f; if ((horizontalModes.TryGetValue(values[1], out h) && verticalModes.TryGetValue(values[2], out v)) || (horizontalModes.TryGetValue(values[2], out h) && verticalModes.TryGetValue(values[1], out v))) { return(new Angle((Single)(Math.Atan2(h - 0.5, 0.5 - v) * 180.0 / Math.PI), Angle.Unit.Deg)); } } } return(null); }
protected override Boolean IsValid(CSSValue value) { var values = value.AsList <CSSIdentifierValue>(); if (values != null) { var fillModes = new List <AnimationFillMode>(); foreach (var item in values) { var mode = item.ToFillMode(); if (!mode.HasValue) { return(false); } fillModes.Add(mode.Value); } _fillModes = fillModes; } else if (value != CSSValue.Inherit) { return(false); } return(true); }
static Boolean Check(CSSValue value, ref Position position) { var calc = value.AsCalc(); if (calc != null) { position.X = calc; } else if (value.Is("left")) { position.X = CSSCalcValue.Zero; } else if (value.Is("right")) { position.X = CSSCalcValue.Full; } else if (value.Is("top")) { position.Y = CSSCalcValue.Zero; } else if (value.Is("bottom")) { position.Y = CSSCalcValue.Full; } else if (!value.Is("center")) { return(false); } return(true); }
static ContentMode Evaluate(CSSValue value) { ContentMode mode = null; if (value is CSSIdentifierValue) { modes.TryGetValue(((CSSIdentifierValue)value).Value, out mode); } else if (value is CSSAttrValue) { mode = new AttributeContentMode(((CSSAttrValue)value).Name); } else if (value is CSSStringValue) { mode = new TextContentMode(((CSSStringValue)value).Value); } else if (value is CSSCounter) { mode = new CounterContentMode((CSSCounter)value); } else if (value is CSSPrimitiveValue <Location> ) { mode = new UrlContentMode(((CSSPrimitiveValue <Location>)value).Value); } return(mode); }
/// <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 values = value.AsList<CSSIdentifierValue>(); if (values != null) { var states = new List<PlayState>(); foreach (var item in values) { if (item.Is("running")) states.Add(PlayState.Running); else if (item.Is("paused")) states.Add(PlayState.Paused); else return false; } _states = states; } else if (value != CSSValue.Inherit) return false; return true; }
/// <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 list = value as CSSValueList; var v1 = value; var v2 = value; if (list != null) { if (list.Length != 2) return false; v1 = list[0]; v2 = list[1]; } var c1 = v1.AsCalc(); var c2 = v2.AsCalc(); if (c1 != null && c2 != null) { _h = c1; _v = c2; } else if (value != CSSValue.Inherit) return false; return true; }
protected override Boolean IsValid(CSSValue value) { var transition = ParseValue(value); if (transition.HasValue) { _animations.Clear(); _animations.Add(transition.Value); } else if (value is CSSValueList) { var values = ((CSSValueList)value).ToList(); var animations = new List <Animation>(); foreach (var item in values) { var t = item.Length == 1 ? ParseValue(item[0]) : ParseValue(item); if (!t.HasValue) { return(false); } animations.Add(t.Value); } _animations = animations; } else if (value != CSSValueList.Inherit) { return(false); } return(true); }
/// <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 values = value.AsList<CSSIdentifierValue>(); if (values != null) { var fillModes = new List<AnimationDirection>(); foreach (var item in values) { var direction = item.ToDirection(); if (!direction.HasValue) return false; fillModes.Add(direction.Value); } _directions = fillModes; } else if (value != CSSValue.Inherit) return false; return true; }
Transition?ParseValue(CSSValue value) { var delay = Time.Zero; var duration = Time.Zero; var function = value.ToTimingFunction(); var property = "all"; if (function == null) { function = CSSTimingValue.Ease; if (value is CSSIdentifierValue) { property = ((CSSIdentifierValue)value).Value; } else if (value is CSSPrimitiveValue <Time> ) { duration = value.ToTime().Value; } else { return(null); } } return(new Transition { Delay = delay, Duration = duration, Timing = function, Property = property }); }
/// <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) { TextDecorationLine mode; if (value.Is("none")) _line.Clear(); else if (value is CSSIdentifierValue && modes.TryGetValue(((CSSIdentifierValue)value).Value, out mode)) { _line.Clear(); _line.Add(mode); } else if (value is CSSValueList) { var values = (CSSValueList)value; var list = new List<TextDecorationLine>(); foreach (var item in values) { if (item is CSSIdentifierValue && modes.TryGetValue(((CSSIdentifierValue)value).Value, out mode)) list.Add(mode); else return false; } _line = list; } else if (value != CSSValue.Inherit) return false; return true; }
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) { if (value is CSSValueList) { var values = (CSSValueList)value; var images = new List<CSSImageValue>(); for (int i = 0; i < values.Length; i++) { var image = values[i].AsImage(); if (image == null || (++i < values.Length && values[i] != CSSValue.Separator)) return false; images.Add(image); } _images = images; } else if (value != CSSValue.Inherit) { var image = value.AsImage(); if (image == null) return false; _images.Clear(); _images.Add(image); } return true; }
protected override Boolean IsValid(CSSValue value) { if (value.Is("auto")) { _mode = _auto; } else if (value is CSSValueList) { return(Evaluate((CSSValueList)value)); } else if (value == CSSValue.Inherit) { return(true); } else { var mode = Evaluate(value); if (mode == null) { return(false); } _mode = mode; } return(true); }
/// <summary> /// Adds the new value to the current value (or replaces it). /// </summary> /// <param name="value">The value to add.</param> /// <returns>The status.</returns> Boolean AddValue(CSSValue value) { if (fraction) { if (this.value != null) { value = new CSSPrimitiveValue(CssUnit.Unknown, this.value.ToCss() + "/" + value.ToCss()); this.value = null; } fraction = false; } if (function.Count > 0) { function.Peek().Arguments.Add(value); } else if (this.value == null) { this.value = value; } else { return(false); } return(true); }
protected override Boolean IsValid(CSSValue value) { if (value == CSSValue.Inherit) { return(true); } var values = value as CSSValueList ?? new CSSValueList(value); var top = new CSSBorderTopWidthProperty(); var bottom = new CSSBorderBottomWidthProperty(); var right = new CSSBorderRightWidthProperty(); var left = new CSSBorderLeftWidthProperty(); if (values.Length == 1) { if (!CheckSingleProperty(top, 0, values)) { return(false); } right.Value = left.Value = bottom.Value = top.Value; } else if (values.Length == 2) { if (!CheckSingleProperty(top, 0, values) || !CheckSingleProperty(right, 1, values)) { return(false); } bottom.Value = top.Value; left.Value = right.Value; } else if (values.Length == 3) { if (!CheckSingleProperty(top, 0, values) || !CheckSingleProperty(right, 1, values) || !CheckSingleProperty(bottom, 2, values)) { return(false); } left.Value = right.Value; } else if (values.Length == 4) { if (!CheckSingleProperty(top, 0, values) || !CheckSingleProperty(right, 1, values) || !CheckSingleProperty(bottom, 2, values) || !CheckSingleProperty(left, 3, values)) { return(false); } } else { return(false); } _top = top; _bottom = bottom; _right = right; _left = left; return(true); }
/// <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) { if (value == CSSValue.Inherit) return true; else if (value is CSSValueList) return Check((CSSValueList)value); return Check(new CSSValue[] { value, value, value, value }); }
public void Include() { if (value != null) { arguments.Add(value); } value = null; }
protected override Boolean IsValid(CSSValue value) { if (value == CSSValue.Inherit) { return(true); } var values = value as CSSValueList ?? new CSSValueList(value); var repeats = new List <Repeat>(); for (int i = 0; i < values.Length; i++) { if (values[i] is CSSIdentifierValue == false) { return(false); } var ident = ((CSSIdentifierValue)values[i]).Value; var repeat = new Repeat(); if (ident.Equals("repeat-x", StringComparison.OrdinalIgnoreCase)) { repeat.Horizontal = RepeatMode.Repeat; repeat.Vertical = RepeatMode.NoRepeat; } else if (ident.Equals("repeat-y", StringComparison.OrdinalIgnoreCase)) { repeat.Horizontal = RepeatMode.NoRepeat; repeat.Vertical = RepeatMode.Repeat; } else if (_modes.TryGetValue(ident, out repeat.Horizontal)) { if (i + 1 < values.Length && values[i + 1] is CSSIdentifierValue && _modes.TryGetValue(((CSSIdentifierValue)values[i + 1]).Value, out repeat.Vertical)) { i++; } else { repeat.Vertical = repeat.Horizontal; } } else { return(false); } if (++i < values.Length && values[i] != CSSValue.Separator) { return(false); } repeats.Add(repeat); } _repeats = repeats; return(true); }
public static ICssObject ToImage(this CSSValue value) { if (value.Is(Keywords.None)) { return(Color.Transparent); } return(value.ToUri() ?? value.ToLinearGradient() ?? value.ToRadialGradient() as ICssObject); }
/// <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) { if (value == CSSValue.Inherit) return true; else if (value is CSSValueList) return SetXY((CSSValueList)value); return SetSingle(value); }
/// <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) { if (value is CSSValueList) return CheckList((CSSValueList)value); else if (!CheckSingle(value) && value != CSSValue.Inherit) return false; return true; }
/// <summary> /// Closes a property. /// </summary> void CloseProperty() { if (property != null) { property.Value = value; } value = null; property = null; }
public static Int32?ToInteger(this CSSValue value) { var primitive = value as CSSPrimitiveValue; if (primitive != null && primitive.Unit == UnitType.Number) { return((Int32)primitive.GetNumber(UnitType.Number)); } return(null); }
/// <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 num = value.ToNumber(); if (num.HasValue) _value = num.Value; else if (value != CSSValue.Inherit) return false; return true; }
/// <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) { if (value.Is("flat")) _flat = true; else if (value.Is("preserve-3d")) _flat = false; else if (value != CSSValue.Inherit) return false; return true; }
protected override Boolean IsValid(CSSValue value) { if (value == CSSValue.Inherit) { return(true); } var list = value as CSSValueList; if (list == null) { list = new CSSValueList(value); } var index = 0; var startGroup = new List <CSSProperty>(3); var style = new CSSTextDecorationStyleProperty(); var line = new CSSTextDecorationLineProperty(); var color = new CSSTextDecorationColorProperty(); startGroup.Add(style); startGroup.Add(line); startGroup.Add(color); while (true) { var length = startGroup.Count; for (int i = 0; i < length; i++) { if (CheckSingleProperty(startGroup[i], index, list)) { startGroup.RemoveAt(i); index++; break; } } if (length == startGroup.Count) { break; } } if (index == list.Length) { _style = style; _line = line; _color = color; return(true); } return(false); }
/// <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 style = value.ToLineStyle(); if (style.HasValue) _style = style.Value; else if (value != CSSValue.Inherit) return false; return true; }
/// <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) { if (value == CSSValue.Inherit) return true; else if (value is CSSValueList) return CheckList((CSSValueList)value); else if (value is CSSIdentifierValue) return CheckIdentifier((CSSIdentifierValue)value); return false; }
/// <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 width = value.ToBorderWidth(); if (width.HasValue) _width = width.Value; else if (value != CSSValue.Inherit) return false; return true; }
/// <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 image = value.AsImage(); if (image != null) _image = image; else if (value != CSSValue.Inherit) return false; return true; }
/// <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) { if (value.Is("auto")) _mode = BreakMode.Auto; else if (value.Is("avoid")) _mode = BreakMode.Avoid; else if (value != CSSValue.Inherit) return false; return true; }
/// <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) { if (value.Is("visible")) _visible = true; else if (value.Is("hidden")) _visible = false; else if (value != CSSValue.Inherit) return false; return true; }
public static Byte?ToByte(this CSSValue value) { var primitive = value as CSSPrimitiveValue; if (primitive != null && primitive.Unit == UnitType.Number) { return((Byte)Math.Min(Math.Max((Int32)primitive.GetNumber(UnitType.Number), 0), 255)); } return(null); }
/// <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 calc = value.AsCalc(); if (calc != null) _mode = calc; else if (value != CSSValue.Inherit) return false; return true; }
/// <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 values = value.AsList(ValueExtensions.ToTimingFunction); if (values != null) _functions = values; else if (value != CSSValue.Inherit) return false; return true; }
public static Time?ToTime(this CSSValue value) { var primitive = value as CSSPrimitiveValue; if (primitive != null) { return(primitive.Value as Time?); } return(null); }
public static ITransform ToTransform(this CSSValue value) { var primitive = value as CSSPrimitiveValue; if (primitive != null && primitive.Unit == UnitType.Transform) { return((ITransform)primitive.Value); } return(null); }
public static Resolution?ToResolution(this CSSValue value) { var primitive = value as CSSPrimitiveValue; if (primitive != null) { return(primitive.Value as Resolution?); } return(null); }
/// <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) { UnicodeMode mode; if (value is CSSIdentifierValue && modes.TryGetValue(((CSSIdentifierValue)value).Value, out mode)) _mode = mode; else if (value != CSSValue.Inherit) return false; return true; }
/// <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) { FontStretch style; if (value is CSSIdentifierValue && _styles.TryGetValue(((CSSIdentifierValue)value).Value, out style)) _stretch = style; else if (value != CSSValue.Inherit) return false; return true; }
/// <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; }
static SizeMode Check(CSSValue horizontal, CSSValue vertical) { var width = horizontal.AsCalc(); var height = vertical.AsCalc(); if (width == null && !horizontal.Is("auto")) return null; else if (height == null && !vertical.Is("auto")) return null; return new CalcSizeMode(width, height); }
/// <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) { FontWeightMode weight; if (value is CSSIdentifierValue && _weights.TryGetValue(((CSSIdentifierValue)value).Value, out weight)) _weight = weight; else if (value.ToInteger().HasValue) _weight = new NumberWeightMode(value.ToInteger().Value); else if (value != CSSValue.Inherit) return false; return true; }
/// <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 width = value.ToLength(); if (width.HasValue) _width = width.Value; else if (value.Is("auto")) _width = null; else if (value != CSSValue.Inherit) return false; return true; }
/// <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 mode = ToMode(value); if (mode != null) _top = _right = _left = _bottom = mode; else if (value is CSSValueList) return Evaluate((CSSValueList)value); else if (value != CSSValue.Inherit) return false; return true; }
/// <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 shape = value as CSSShapeValue; if (shape != null) _shape = shape; else if (value.Is("auto")) _shape = null; else if (value != CSSValue.Inherit) return false; return true; }
internal override Boolean TrySetValue(CSSValue value) { var color = value.ToInteger(); if (color.HasValue && color.Value > 0) { Value = value; _color = color.Value; return true; } return false; }