public void PDFSolidBrushConstructor_Test2()
        {
            PDFSolidBrush target = new PDFSolidBrush();

            Assert.IsNotNull(target);
            Assert.AreEqual(PDFColors.Transparent, 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 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 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 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 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 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);
        }
Exemplo n.º 8
0
        public void Fill_CreateBrushTest()
        {
            Scryber.Styles.FillStyle target = new Scryber.Styles.FillStyle();
            target.Style = Scryber.Drawing.FillType.Solid;
            target.Color = PDFColors.Red;
            PDFBrush expected = new PDFSolidBrush(PDFColors.Red);
            PDFBrush actual;

            actual = target.CreateBrush();
            Assert.AreEqual(expected.GetType(), actual.GetType());
            Assert.AreEqual(expected.FillStyle, actual.FillStyle);

            PDFSolidBrush solidexpected = (PDFSolidBrush)expected;
            PDFSolidBrush solidactual   = (PDFSolidBrush)actual;

            Assert.AreEqual(solidexpected.Color, solidactual.Color);
            Assert.AreEqual(solidexpected.Opacity, solidactual.Opacity);

            target                  = new Scryber.Styles.FillStyle();
            target.Style            = Scryber.Drawing.FillType.Image;
            target.ImageSource      = "../images/animage.png";
            target.PatternRepeat    = PatternRepeat.RepeatBoth;
            target.PatternXPosition = 10;
            target.PatternXSize     = 100;
            target.PatternXStep     = 90;
            target.PatternYPosition = 20;
            target.PatternYSize     = 200;
            target.PatternYStep     = 180;


            expected = new PDFImageBrush("../images/animage.png");
            actual   = target.CreateBrush();
            Assert.AreEqual(expected.GetType(), actual.GetType());
            Assert.AreEqual(expected.FillStyle, actual.FillStyle);

            PDFImageBrush imgexpected = (PDFImageBrush)expected;
            PDFImageBrush imgactual   = (PDFImageBrush)actual;

            Assert.AreEqual(imgexpected.ImageSource, imgactual.ImageSource);
            Assert.AreEqual(imgexpected.Opacity, imgactual.Opacity);
            Assert.AreEqual(target.PatternXPosition, imgactual.XPostion);
            Assert.AreEqual(target.PatternXSize, imgactual.XSize);
            Assert.AreEqual(target.PatternXStep, imgactual.XStep);
            Assert.AreEqual(target.PatternYPosition, imgactual.YPostion);
            Assert.AreEqual(target.PatternYSize, imgactual.YSize);
            Assert.AreEqual(target.PatternYStep, imgactual.YStep);

            //check that the patterns are conformed to repeating

            target.PatternRepeat = PatternRepeat.RepeatX;
            imgactual            = (PDFImageBrush)target.CreateBrush();
            Assert.AreEqual(imgactual.YStep, Scryber.Styles.FillStyle.NoYRepeatStepSize);

            target.PatternRepeat = PatternRepeat.RepeatY;
            imgactual            = (PDFImageBrush)target.CreateBrush();
            Assert.AreEqual(imgactual.XStep, Scryber.Styles.FillStyle.NoXRepeatStepSize);

            target.PatternRepeat = PatternRepeat.None;
            imgactual            = (PDFImageBrush)target.CreateBrush();
            Assert.AreEqual(imgactual.YStep, Scryber.Styles.FillStyle.NoYRepeatStepSize);
            Assert.AreEqual(imgactual.XStep, Scryber.Styles.FillStyle.NoXRepeatStepSize);
        }
Exemplo n.º 9
0
        //
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        internal virtual PDFBrush CreatePDFSolidBrush()
        {
            PDFSolidBrush target = new PDFSolidBrush();

            return(target);
        }
Exemplo n.º 10
0
        protected static PDFBrush Create(FillStyle fill)
        {
            if (fill == null)
            {
                throw new ArgumentNullException("fill");
            }

            Drawing.FillType fillstyle;
            bool             fillstyledefined;
            string           imgsrc;
            double           opacity;
            PDFColor         color;

            if (fill.TryGetValue(StyleKeys.FillStyleKey, out fillstyle))
            {
                if (fillstyle == Drawing.FillType.None)
                {
                    return(null);
                }
                fillstyledefined = true;
            }
            else
            {
                fillstyledefined = false;
            }

            //If we have an image source and we are set to use an image fill style (or it has not been specified)
            if (fill.TryGetValue(StyleKeys.FillImgSrcKey, out imgsrc) && !string.IsNullOrEmpty(imgsrc) && (fillstyle == Drawing.FillType.Image || fillstyledefined == false))
            {
                PDFImageBrush img    = new PDFImageBrush(imgsrc);
                PatternRepeat repeat = fill.PatternRepeat;

                if (repeat == PatternRepeat.RepeatX || repeat == PatternRepeat.RepeatBoth)
                {
                    img.XStep = fill.PatternXStep;
                }
                else
                {
                    img.XStep = NoXRepeatStepSize;
                }

                if (repeat == PatternRepeat.RepeatY || repeat == PatternRepeat.RepeatBoth)
                {
                    img.YStep = fill.PatternYStep;
                }
                else
                {
                    img.YStep = NoYRepeatStepSize;
                }

                img.XPostion = fill.PatternXPosition;
                img.YPostion = fill.PatternYPosition;

                PDFUnit x, y;

                if (fill.TryGetValue(StyleKeys.FillXSizeKey, out x))
                {
                    img.XSize = x;
                }

                if (fill.TryGetValue(StyleKeys.FillYSizeKey, out y))
                {
                    img.YSize = y;
                }

                if (fill.TryGetValue(StyleKeys.FillOpacityKey, out opacity))
                {
                    img.Opacity = opacity;
                }

                return(img);
            }

            //if we have a colour and a solid style (or no style)
            else if (fill.TryGetValue(StyleKeys.FillColorKey, out color) && (fill.Style == Drawing.FillType.Solid || fillstyledefined == false))
            {
                PDFSolidBrush solid = new PDFSolidBrush(fill.Color);

                //if we have an opacity set it.
                if (fill.TryGetValue(StyleKeys.FillOpacityKey, out opacity))
                {
                    solid.Opacity = opacity;
                }

                return(solid);
            }
            else
            {
                return(null);
            }
        }