internal CSSPrimitiveValue(CSSColor value) { _text = value.ToCss(); _type = CssValueType.PrimitiveValue; _unit = CssUnit.Rgbcolor; _value = value; }
public static CSSBackground Parse(string value) { var background = new CSSBackground { Color = CSSColor.Parse(value) }; return(background); }
/// <summary> /// Called in a value - a hash (probably hex) value has been found. /// </summary> /// <param name="token">The value of the token.</param> /// <returns>The status.</returns> Boolean InSingleValueHexColor(String color) { CSSColor value; if (CSSColor.TryFromHex(color, out value)) { return(AddValue(new CSSPrimitiveValue(value))); } return(false); }
public CSSBorder() { Left = new CSSNumber(); Right = new CSSNumber(); Top = new CSSNumber(); Bottom = new CSSNumber(); Type = CSSBorderType.Solid; Radius = new CSSNumber(); Color = CSSColor.Black; }
public void CSSColorParseConstTest() { var color = CSSColor.ParseConstant("black"); color.Should().NotBeNull(); color.A.Should().BeGreaterOrEqualTo(255); color.R.Should().BeGreaterOrEqualTo(0); color.G.Should().BeGreaterOrEqualTo(0); color.B.Should().BeGreaterOrEqualTo(0); }
public void CSSColorParseHexWithoutAlpha() { var color = CSSColor.ParseHex("#FFFFFF"); color.Should().NotBeNull(); color.A.Should().BeGreaterOrEqualTo(255); color.R.Should().BeGreaterOrEqualTo(255); color.G.Should().BeGreaterOrEqualTo(255); color.B.Should().BeGreaterOrEqualTo(255); }
public void CSSColorParseHexTest() { var color = CSSColor.ParseHex("FFFFFFCC"); color.Should().NotBeNull(); color.A.Should().BeGreaterOrEqualTo(204); color.R.Should().BeGreaterOrEqualTo(255); color.G.Should().BeGreaterOrEqualTo(255); color.B.Should().BeGreaterOrEqualTo(255); }
/// <summary> /// Options to change (graphics attributes) /// </summary> /// <param name="d">disposition</param> /// <param name="w">constraint on width</param> /// <param name="h">constraint on height</param> /// <param name="b">background color</param> /// <param name="a">border color</param> /// <param name="f">font color</param> /// <param name="bs">border size</param> /// <param name="ps">padding size</param> /// <param name="obj">ux object</param> public void Options(Disposition d, EnumConstraint w, EnumConstraint h, CSSColor b, CSSColor a, CSSColor f, int bs, int ps, IUXObject obj) { this.disposition = d; this.constraintWidth = w; this.constraintHeight = h; this.backgroundColor = (CSSColor)b.Clone(); this.borderColor = (CSSColor)a.Clone(); this.textColor = (CSSColor)f.Clone(); this.borderSize = bs; this.paddingSize = ps; this.content = obj; }
public PathStyle(Dictionary <string, string> properties, PathStyle?parent) { // Fill in the default values according to the default values on https://svgwg.org/svg-next/painting.htm // Special handling for paint servers (which now only accept colors) FillColor = CSSColor.Parse(properties.GetOrDefault("fill")) ?? (parent.HasValue ? parent.Value.FillColor : Color.Black); StrokeColor = CSSColor.Parse(properties.GetOrDefault("stroke")) ?? parent?.StrokeColor; FillRule = CSSEnumPicker <FillRule> .Get(properties.GetOrDefault("fill-rule")) ?? parent?.FillRule ?? FillRule.Nonzero; StrokeWidth = DoubleUtils.TryParse(properties.GetOrDefault("stroke-width")) ?? parent?.StrokeWidth ?? 1; StrokeLineCap = CSSEnumPicker <StrokeLineCap> .Get(properties.GetOrDefault("stroke-linecap")) ?? parent?.StrokeLineCap ?? StrokeLineCap.Butt; StrokeLineJoin = CSSEnumPicker <StrokeLineJoin> .Get(properties.GetOrDefault("stroke-linejoin")) ?? parent?.StrokeLineJoin ?? StrokeLineJoin.Miter; MiterLimit = DoubleUtils.TryParse(properties.GetOrDefault("stroke-miterlimit")) ?? parent?.StrokeWidth ?? 4; }
public CSSStyleDeclaration() { Color = new CSSColor(); Background = new CSSBackground(); Padding = new CSSPadding(); Margin = new CSSMargin(); Border = new CSSBorder(); Cursor = new CSSCursor(); Float = new CSSFloat(); Font = new CSSFont(); Left = new CSSNumber(); Right = new CSSNumber(); Width = new CSSNumber(); Height = new CSSNumber(); Display = new CSSDisplay(); Position = new CSSPosition(); ChangedFields = new List <string>(); }
public void CSSColorParseCombinationTest() { var colorHex = CSSColor.Parse("FFFFFFCC"); colorHex.Should().NotBeNull(); colorHex.A.Should().BeGreaterOrEqualTo(204); colorHex.R.Should().BeGreaterOrEqualTo(255); colorHex.G.Should().BeGreaterOrEqualTo(255); colorHex.B.Should().BeGreaterOrEqualTo(255); var colorConst = CSSColor.Parse("white"); colorConst.Should().NotBeNull(); colorConst.A.Should().BeGreaterOrEqualTo(255); colorConst.R.Should().BeGreaterOrEqualTo(255); colorConst.G.Should().BeGreaterOrEqualTo(255); colorConst.B.Should().BeGreaterOrEqualTo(255); }
/// <summary> /// Gets the name of the given color. /// </summary> /// <param name="color">The color that searches its name.</param> /// <returns>The name of the given color or null.</returns> public static String GetNameFromColor(CSSColor color) { foreach (var pair in _colors) if (pair.Value.Equals(color)) return pair.Key; return null; }