예제 #1
0
        public void CanConvertXlColorToX14ColorType()
        {
            var xlColor1 = XLColor.Red;
            var xlColor2 = XLColor.FromIndex(20);
            var xlColor3 = XLColor.FromTheme(XLThemeColor.Accent1);
            var xlColor4 = XLColor.FromTheme(XLThemeColor.Accent2, 0.4);

            var color1 = new X14.AxisColor().FromClosedXMLColor <X14.AxisColor>(xlColor1);
            var color2 = new X14.BorderColor().FromClosedXMLColor <X14.BorderColor>(xlColor2);
            var color3 = new X14.FillColor().FromClosedXMLColor <X14.FillColor>(xlColor3);
            var color4 = new X14.HighMarkerColor().FromClosedXMLColor <X14.HighMarkerColor>(xlColor4);

            Assert.AreEqual("FFFF0000", color1.Rgb.Value);
            Assert.IsNull(color1.Indexed);
            Assert.IsNull(color1.Theme);
            Assert.IsNull(color1.Tint);

            Assert.IsNull(color2.Rgb);
            Assert.AreEqual(20, color2.Indexed.Value);
            Assert.IsNull(color2.Theme);
            Assert.IsNull(color2.Tint);

            Assert.IsNull(color3.Rgb);
            Assert.IsNull(color3.Indexed);
            Assert.AreEqual(4, color3.Theme.Value);
            Assert.IsNull(color3.Tint);

            Assert.IsNull(color4.Rgb);
            Assert.IsNull(color4.Indexed);
            Assert.AreEqual(5, color4.Theme.Value);
            Assert.AreEqual(0.4, color4.Tint.Value);
        }
예제 #2
0
 internal void FromAxisColor(X14.AxisColor clr)
 {
     SetAllNull();
     if (clr.Auto != null)
     {
         Auto = clr.Auto.Value;
     }
     if (clr.Indexed != null)
     {
         Indexed = clr.Indexed.Value;
     }
     if (clr.Rgb != null)
     {
         Rgb = clr.Rgb.Value;
     }
     if (clr.Theme != null)
     {
         Theme = clr.Theme.Value;
     }
     if (clr.Tint != null)
     {
         Tint = clr.Tint.Value;
     }
     SetDisplayColor();
 }
예제 #3
0
        internal X14.AxisColor ToAxisColor()
        {
            var clr = new X14.AxisColor();

            if (Auto != null)
            {
                clr.Auto = Auto.Value;
            }
            if (Indexed != null)
            {
                clr.Indexed = Indexed.Value;
            }
            if (Rgb != null)
            {
                clr.Rgb = new HexBinaryValue(Rgb);
            }
            if (Theme != null)
            {
                clr.Theme = Theme.Value;
            }
            if ((Tint != null) && (Tint.Value != 0.0))
            {
                clr.Tint = Tint.Value;
            }

            return(clr);
        }
예제 #4
0
        internal X14.AxisColor ToAxisColor()
        {
            X14.AxisColor clr = new X14.AxisColor();
            if (this.Auto != null)
            {
                clr.Auto = this.Auto.Value;
            }
            if (this.Indexed != null)
            {
                clr.Indexed = this.Indexed.Value;
            }
            if (this.Rgb != null)
            {
                clr.Rgb = new HexBinaryValue(this.Rgb);
            }
            if (this.Theme != null)
            {
                clr.Theme = this.Theme.Value;
            }
            if (this.Tint != null && this.Tint.Value != 0.0)
            {
                clr.Tint = this.Tint.Value;
            }

            return(clr);
        }
예제 #5
0
        public void CanConvertX14ColorTypeToXlColor()
        {
            var color1 = new X14.AxisColor {
                Rgb = new DocumentFormat.OpenXml.HexBinaryValue("FFFF0000")
            };
            var color2 = new X14.BorderColor {
                Indexed = new DocumentFormat.OpenXml.UInt32Value((uint)20)
            };
            var color3 = new X14.FillColor {
                Theme = new DocumentFormat.OpenXml.UInt32Value((uint)4)
            };
            var color4 = new X14.HighMarkerColor
            {
                Theme = new DocumentFormat.OpenXml.UInt32Value((uint)4),
                Tint  = new DocumentFormat.OpenXml.DoubleValue(0.4)
            };

            var xlColor1 = color1.ToClosedXMLColor();
            var xlColor2 = color2.ToClosedXMLColor();
            var xlColor3 = color3.ToClosedXMLColor();
            var xlColor4 = color4.ToClosedXMLColor();

            Assert.AreEqual(XLColorType.Color, xlColor1.ColorType);
            Assert.AreEqual(XLColor.Red.Color, xlColor1.Color);

            Assert.AreEqual(XLColorType.Indexed, xlColor2.ColorType);
            Assert.AreEqual(20, xlColor2.Indexed);

            Assert.AreEqual(XLColorType.Theme, xlColor3.ColorType);
            Assert.AreEqual(XLThemeColor.Accent1, xlColor3.ThemeColor);
            Assert.AreEqual(0, xlColor3.ThemeTint, XLHelper.Epsilon);

            Assert.AreEqual(XLColorType.Theme, xlColor4.ColorType);
            Assert.AreEqual(XLThemeColor.Accent1, xlColor4.ThemeColor);
            Assert.AreEqual(0.4, xlColor4.ThemeTint, XLHelper.Epsilon);
        }
예제 #6
0
        internal X14.AxisColor ToAxisColor()
        {
            X14.AxisColor clr = new X14.AxisColor();
            if (this.Auto != null) clr.Auto = this.Auto.Value;
            if (this.Indexed != null) clr.Indexed = this.Indexed.Value;
            if (this.Rgb != null) clr.Rgb = new HexBinaryValue(this.Rgb);
            if (this.Theme != null) clr.Theme = this.Theme.Value;
            if (this.Tint != null && this.Tint.Value != 0.0) clr.Tint = this.Tint.Value;

            return clr;
        }