コード例 #1
0
ファイル: CSSPrimitiveValue.cs プロジェクト: rrsc/AngleSharp
 internal CSSPrimitiveValue(CSSColor value)
 {
     _text = value.ToCss();
     _type = CssValueType.PrimitiveValue;
     _unit = CssUnit.Rgbcolor;
     _value = value;
 }
コード例 #2
0
ファイル: CSSBackground.cs プロジェクト: Winster332/Quantum
        public static CSSBackground Parse(string value)
        {
            var background = new CSSBackground
            {
                Color = CSSColor.Parse(value)
            };

            return(background);
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
        public CSSBorder()
        {
            Left   = new CSSNumber();
            Right  = new CSSNumber();
            Top    = new CSSNumber();
            Bottom = new CSSNumber();

            Type   = CSSBorderType.Solid;
            Radius = new CSSNumber();
            Color  = CSSColor.Black;
        }
コード例 #5
0
ファイル: CSSColorTests.cs プロジェクト: Winster332/Quantum
        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);
        }
コード例 #6
0
ファイル: CSSColorTests.cs プロジェクト: Winster332/Quantum
        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);
        }
コード例 #7
0
ファイル: CSSColorTests.cs プロジェクト: Winster332/Quantum
        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);
        }
コード例 #8
0
 /// <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;
 }
コード例 #9
0
        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;
        }
コード例 #10
0
 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>();
 }
コード例 #11
0
ファイル: CSSColorTests.cs プロジェクト: Winster332/Quantum
        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);
        }
コード例 #12
0
ファイル: Colors.cs プロジェクト: rrsc/AngleSharp
        /// <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;
        }