protected bool DoConvertBorderColor(StyleBase onStyle, object value, out PDFColor result) { double?opacity; if (null == value) { result = PDFColor.Transparent; return(false); } else if (value is PDFColor color) { result = color; return(true); } else if (ParseCSSColor(value.ToString(), out result, out opacity)) { if (opacity.HasValue) { onStyle.SetValue(StyleKeys.BorderOpacityKey, opacity.Value); } return(true); } else { result = PDFColor.Transparent; return(false); } }
protected bool DoConvertBorderColor(StyleBase onStyle, object value, out PDFColor result) { double?opacity; if (null == value) { result = PDFColor.Transparent; return(false); } else if (value is PDFColor color) { result = color; return(true); } else if (ParseCSSColor(value.ToString(), out result, out opacity)) { //TODO:Support individual opacity on borders return(true); } else { result = PDFColor.Transparent; return(false); } }
public void ColorSpace_Test() { ColorSpace cs = ColorSpace.RGB; PDFColor target = new PDFColor(cs, 1.0, 1.0, 1.0); ColorSpace actual; actual = target.ColorSpace; Assert.AreEqual(actual, cs); }
public void op_Implicit_Test() { Color rgbcolor = Color.FromArgb(255, 255, 255); PDFColor expected = new PDFColor(1, 1, 1); PDFColor actual; actual = rgbcolor; Assert.AreEqual(expected, actual); }
protected override object DoGetNativeValue(string key, string qsValue, IPDFComponent comp) { PDFColor val; if (string.IsNullOrEmpty(qsValue) || !PDFColor.TryParse(qsValue, out val)) { val = this.Value; } return(val); }
public void FillStyle_Test() { PDFColor color = PDFColors.Aqua; PDFSolidBrush target = new PDFSolidBrush(color); FillType expected = FillType.Solid; FillType actual; actual = target.FillStyle; Assert.AreEqual(expected, actual); }
public void PDFSolidPenConstructor_Test() { PDFColor color = PDFColors.Aqua; // TODO: Initialize to an appropriate value PDFUnit width = 1; PDFSolidPen target = new PDFSolidPen(color, width); Assert.IsNotNull(target); Assert.AreEqual(color, target.Color); Assert.AreEqual(width, target.Width); }
public void PDFSolidBrushConstructor_Test3() { PDFColor color = PDFColors.Aqua; PDFSolidBrush target = new PDFSolidBrush(color); Assert.IsNotNull(target); Assert.AreEqual(color, target.Color); Assert.AreEqual((PDFReal)1, target.Opacity); Assert.AreEqual(FillType.Solid, target.FillStyle); }
public void PDFSolidBrushConstructor_Test() { PDFColor color = PDFColors.Aqua; double opacity = 1F; PDFSolidBrush target = new PDFSolidBrush(color, opacity); Assert.IsNotNull(target); Assert.AreEqual(color, target.Color); Assert.AreEqual(opacity, target.Opacity.Value); }
public void Color_Test() { PDFSolidPen target = new PDFSolidPen(); // TODO: Initialize to an appropriate value PDFColor expected = PDFColors.Aqua; PDFColor actual; target.Color = expected; actual = target.Color; Assert.AreEqual(expected, actual); }
public void ToString_Test() { ColorSpace cs = ColorSpace.RGB; Color c = Color.FromArgb(255, 255, 255); PDFColor target = new PDFColor(cs, c); string expected = "rgb(255,255,255)"; string actual; actual = target.ToString(); Assert.AreEqual(expected, actual); }
public void PDFColorConstructor_Test4() { double gray = 0.5; PDFColor target = new PDFColor(gray); Assert.AreEqual(ColorSpace.G, target.ColorSpace); double expected = Math.Round(gray, 1); double actual = Math.Round(target.Gray.Value, 1); Assert.AreEqual(expected, actual); }
public void Color_Test() { ColorSpace cs = ColorSpace.RGB; PDFColor target = new PDFColor(cs, 1.0, 1.0, 1.0); Color actual; actual = target.Color; Assert.AreEqual(actual.R, 255); Assert.AreEqual(actual.G, 255); Assert.AreEqual(actual.B, 255); }
protected override void DoSetNativeValue(object value, IPDFComponent owner) { if (null == value) { this.Value = PDFColor.Transparent; } else { this.Value = (PDFColor)value; } }
public void IsEmpty_Test() { ColorSpace cs = ColorSpace.RGB; Color c = new Color();//Empty System.Drawing.Color PDFColor target = new PDFColor(cs, c); Assert.IsTrue(target.IsEmpty); c = Color.FromArgb(255, 0, 0); target = new PDFColor(cs, c); Assert.IsFalse(target.IsEmpty); }
public void PDFColorConstructor_Test2() { double red = 1.0; double green = 0.0; double blue = 0.0; PDFColor target = new PDFColor(red, green, blue); Assert.AreEqual(ColorSpace.RGB, target.ColorSpace); Assert.AreEqual(red, Math.Round(target.Red.Value, 2)); Assert.AreEqual(green, Math.Round(target.Green.Value, 2)); Assert.AreEqual(blue, Math.Round(target.Blue.Value, 2)); }
internal static PDColor GetColor(PDFColor color) { PDColor pDColor; try { switch (color) { case PDFColor.Black: { pDColor = new PDColor(new float[3], PDDeviceRGB.INSTANCE); return(pDColor); } case PDFColor.White: { pDColor = new PDColor(new float[] { 1f, 1f, 1f }, PDDeviceRGB.INSTANCE); return(pDColor); } case PDFColor.Red: { pDColor = new PDColor(new float[] { 1f, default(float), default(float) }, PDDeviceRGB.INSTANCE); return(pDColor); } case PDFColor.Blue: { pDColor = new PDColor(new float[] { default(float), default(float), 1f }, PDDeviceRGB.INSTANCE); return(pDColor); } case PDFColor.Green: { pDColor = new PDColor(new float[] { default(float), 1f, default(float) }, PDDeviceRGB.INSTANCE); return(pDColor); } case PDFColor.Yellow: { pDColor = new PDColor(new float[] { 1f, 1f, default(float) }, PDDeviceRGB.INSTANCE); return(pDColor); } } pDColor = new PDColor(new float[3], PDDeviceRGB.INSTANCE); } catch (Exception exception) { pDColor = new PDColor(new float[3], PDDeviceRGB.INSTANCE); } return(pDColor); }
public void Create_Test() { PDFColor color = PDFColors.Aqua; PDFSolidBrush expected = new PDFSolidBrush(color); PDFSolidBrush actual; actual = PDFSolidBrush.Create(color); Assert.IsNotNull(actual); Assert.AreEqual(expected.Color, actual.Color); Assert.AreEqual(expected.Opacity, actual.Opacity); Assert.AreEqual(expected.FillStyle, actual.FillStyle); }
public void Opacity_Test() { PDFColor color = PDFColors.Aqua; PDFReal opacity = 1F; PDFSolidBrush target = new PDFSolidBrush(color, opacity); Assert.AreEqual(opacity, target.Opacity); PDFReal expected = 0.4F; target.Opacity = expected; Assert.AreEqual(expected, target.Opacity); }
public void PDFColorConstructor_Test3() { ColorSpace cs = ColorSpace.RGB; double one = 0.2; double two = 1.0; double three = 0.5; PDFColor target = new PDFColor(cs, one, two, three); Assert.AreEqual(cs, target.ColorSpace); Assert.AreEqual(one, Math.Round(target.Red.Value, 1)); Assert.AreEqual(two, Math.Round(target.Green.Value, 1)); Assert.AreEqual(three, Math.Round(target.Blue.Value, 1)); }
public void Red_Test() { ColorSpace cs = ColorSpace.RGB; PDFColor target = new PDFColor(cs, 1.0, 1.0, 1.0); PDFReal actual; actual = target.Red; Assert.AreEqual(Math.Round(actual.Value, 2), 1.0); target = new PDFColor(cs, 0.5, 1.0, 0); actual = target.Red; Assert.AreEqual(Math.Round(actual.Value, 1), 0.5); }
public void Parse_Test() { string color = "#FF00FF"; PDFColor expected = new PDFColor(1.0, 0.0, 1.0); PDFColor actual; actual = PDFColor.Parse(color); Assert.AreEqual(expected, actual); color = "rgb(255,0,255)"; actual = PDFColor.Parse(color); Assert.AreEqual(expected, actual); }
public void Color_Test() { PDFColor color = PDFColors.Aqua; PDFSolidBrush target = new PDFSolidBrush(color); PDFColor expected = color; PDFColor actual = target.Color; Assert.AreEqual(expected, actual); expected = PDFColors.White; target.Color = expected; actual = target.Color; Assert.AreEqual(expected, actual); }
public void Gray_Test() { ColorSpace cs = ColorSpace.RGB; PDFColor target = new PDFColor(cs, 1.0, 1.0, 1.0); PDFReal actual; actual = target.Gray; Assert.AreEqual(Math.Round(actual.Value, 1), 1.0); cs = ColorSpace.G; target = new PDFColor(0.5); actual = target.Gray; Assert.AreEqual(Math.Round(actual.Value, 1), 0.5); }
private static PDFColor[] GetPDFPalette(ColorSpace cspace, Color[] colors) { if (null == colors) { throw new ArgumentNullException("colors"); } PDFColor[] all = new PDFColor[colors.Length]; for (int i = 0; i < colors.Length; i++) { all[i] = new PDFColor(cspace, colors[i]); } return(all); }
private RgbColor ConvertPDFColor(PDFColor color) { switch (color) { case PDFColor.Beige: return(RgbColor.Beige); case PDFColor.Black: return(RgbColor.Black); case PDFColor.Blue: return(RgbColor.Blue); case PDFColor.Brown: return(RgbColor.Brown); case PDFColor.DarkBlue: return(RgbColor.DarkBlue); case PDFColor.DarkGray: return(RgbColor.DarkGray); case PDFColor.DarkGreen: return(RgbColor.DarkGreen); case PDFColor.DarkRed: return(RgbColor.DarkRed); case PDFColor.Gold: return(RgbColor.Gold); case PDFColor.Gray: return(RgbColor.Gray); case PDFColor.Green: return(RgbColor.Green); case PDFColor.Navy: return(RgbColor.Navy); case PDFColor.Olive: return(RgbColor.Olive); case PDFColor.Pink: return(RgbColor.Pink); case PDFColor.Purple: return(RgbColor.Purple); case PDFColor.Red: return(RgbColor.Red); case PDFColor.Teal: return(RgbColor.Teal); case PDFColor.White: return(RgbColor.White); case PDFColor.Yellow: return(RgbColor.Yellow); default: return(RgbColor.Black); } }
public void Create_Test() { PDFColor color = PDFColors.Aqua; PDFUnit width = 1; PDFSolidPen expected = new PDFSolidPen(); expected.Color = color; expected.Width = width; PDFPen actual; actual = PDFPen.Create(color, width); Assert.IsInstanceOfType(actual, typeof(PDFSolidPen)); PDFSolidPen solid = (PDFSolidPen)actual; Assert.AreEqual(expected.Width, solid.Width); Assert.AreEqual(expected.Color, solid.Color); }
protected override void DoSetNativeValueFromString(string value, IPDFComponent owner) { PDFColor val; if (string.IsNullOrEmpty(value)) { this.Value = PDFColor.Transparent; } else if (PDFColor.TryParse(value, out val)) { this.Value = val; } else { throw new InvalidCastException("Could not parse the value '" + value + "' to a PDFColor"); } }
public void Outline_ColorTest() { OutlineStyle target = new OutlineStyle(); PDFColor expected = PDFColors.Transparent; Assert.AreEqual(expected, target.Color); expected = PDFColors.Olive; target.Color = expected; Assert.AreEqual(expected, target.Color); expected = PDFColors.Gray; target.Color = expected; Assert.AreEqual(expected, target.Color); target.RemoveColor(); expected = PDFColors.Transparent; Assert.AreEqual(expected, target.Color); }
public void PDFLinearBrushConstructor_Test() { PDFGradientLinearDescriptor descriptor = new PDFGradientLinearDescriptor(); descriptor.Colors = new List <PDFGradientColor>(new PDFGradientColor[] { new PDFGradientColor(PDFColors.Red, null, null) }); PDFGradientLinearBrush target = new PDFGradientLinearBrush(descriptor); PDFColor color = PDFColors.Red; double? opacity = null; double? distance = null; Assert.IsNotNull(target); Assert.AreEqual(GradientType.Linear, target.GradientType); Assert.AreEqual(color, target.Colors[0].Color); Assert.AreEqual(opacity, target.Colors[0].Opacity); Assert.AreEqual(distance, target.Colors[0].Distance); }