Ejemplo n.º 1
0
        /// <summary>
        /// Value-setting constructor.
        /// </summary>
        /// <param name="parent">The parent node of this page in the document page tree.</param>
        /// <param name="objectId">The indirect object ID of this page.</param>
        /// <param name="size">The paper size of this page.</param>
        /// <param name="orientation">The orientation of this page.</param>
        /// <param name="horizontalMarginProportion">The proportion of the page taken up by each of the left and right margins.</param>
        /// <param name="verticalMarginProportion">The proportion of the page taken up by each of the top and bottom margins.</param>
        /// <param name="generation">The object generation number.  Defaults to zero.  As we do not currently support rewriting existing documents, this should not be set.</param>
        public PdfPage(
            PdfPageTreeNode parent,
            int objectId,
            PhysicalPageSize size,
            PageOrientation orientation,
            double horizontalMarginProportion,
            double verticalMarginProportion,
            int generation = 0)
            : base(parent, objectId, generation)
        {
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }

            PageSize        = size;
            PageOrientation = orientation;

            UniSize pagePtSize = size.ToUniSize(orientation);

            TopMarginPosition     = pagePtSize.Height * verticalMarginProportion;
            BottomMarginPosition  = pagePtSize.Height - TopMarginPosition;
            LeftMarginPosition    = pagePtSize.Width * horizontalMarginProportion;
            RightMarginPosition   = pagePtSize.Width - LeftMarginPosition;
            PageAvailableWidth    = RightMarginPosition - LeftMarginPosition;
            CurrentVerticalCursor = TopMarginPosition;
            MediaBox = size.ToPdfRectangle(orientation);
        }
        public void UniSizeExtensionsClass_ToPdfRectangleMethod_ReturnsObjectWithFourthElementEqualInValueToHeightOfFirstParameter()
        {
            UniSize testParam0 = GetUniSize();

            PdfRectangle testOutput = testParam0.ToPdfRectangle();

            Assert.AreEqual((decimal)testParam0.Height, (testOutput[3] as PdfReal).Value);
        }
        public void UniSizeExtensionsClass_ToPdfRectangleMethod_ReturnsObjectWithSecondElementEqualToZero()
        {
            UniSize testParam0 = GetUniSize();

            PdfRectangle testOutput = testParam0.ToPdfRectangle();

            Assert.AreEqual(new PdfReal(0), testOutput[1]);
        }
        public void UniSizeExtensionsClass_ToPdfRectangleMethod_ReturnsObjectWithThirdElementEqualInValueToWidthOfFirstParameter()
        {
            UniSize testParam0 = GetUniSize();

            PdfRectangle testOutput = testParam0.ToPdfRectangle();

            Assert.AreEqual((decimal)testParam0.Width, (testOutput[2] as PdfReal).Value);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Convert a <see cref="UniSize" /> instance into a <see cref="PdfRectangle" /> of the same size and with its bottom-left corner at the origin.
 /// </summary>
 /// <param name="size">The size to be converted.</param>
 /// <returns>A <see cref="PdfRectangle" /> instance of the same size as the parameter.</returns>
 /// <exception cref="NullReferenceException">Thrown if the size parameter is null.</exception>
 public static PdfRectangle ToPdfRectangle(this UniSize size)
 {
     if (size == null)
     {
         throw new NullReferenceException();
     }
     return(new PdfRectangle(_zero.Value, _zero.Value, new PdfReal(size.Width), new PdfReal(size.Height)));
 }
        public void UniSizeExtensionsClass_ToPdfRectangleMethod_ThrowsNullReferenceExceptionWhenFirstParameterIsNull()
        {
            UniSize testParam0 = null;

            testParam0.ToPdfRectangle();

            Assert.Fail();
        }
        public void PhysicalPageSizeExtensionsClass_ToUniSizeMethodWithOneParameter_ReturnsCorrectValueWhenParameterEqualsA6()
        {
            PhysicalPageSize testParam0 = PhysicalPageSize.A6;

            UniSize testOutput = testParam0.ToUniSize();

            Assert.AreEqual(297, testOutput.Width);
            Assert.AreEqual(419, testOutput.Height);
        }
        public void PhysicalPageSizeExtensionsClass_ToUniSizeMethodWithTwoParameters_ReturnsCorrectValueWhenFirstParameterEqualsA6AndSecondParameterEqualsArbitrary()
        {
            PhysicalPageSize testParam0 = PhysicalPageSize.A6;
            PageOrientation  testParam1 = PageOrientation.Arbitrary;

            UniSize testOutput = testParam0.ToUniSize(testParam1);

            Assert.AreEqual(297, testOutput.Width);
            Assert.AreEqual(419, testOutput.Height);
        }
        public void PhysicalPageSizeExtensionsClass_ToUniSizeMethodWithTwoParameters_ReturnsCorrectValueWhenFirstParameterEqualsA4AndSecondParameterEqualsLandscape()
        {
            PhysicalPageSize testParam0 = PhysicalPageSize.A4;
            PageOrientation  testParam1 = PageOrientation.Landscape;

            UniSize testOutput = testParam0.ToUniSize(testParam1);

            Assert.AreEqual(595, testOutput.Height);
            Assert.AreEqual(841, testOutput.Width);
        }
        public void PhysicalPageSizeExtensionsClass_ToUniSizeMethodWithTwoParameters_ReturnsCorrectValueWhenFirstParameterEqualsA3AndSecondParameterEqualsPortrait()
        {
            PhysicalPageSize testParam0 = PhysicalPageSize.A3;
            PageOrientation  testParam1 = PageOrientation.Portrait;

            UniSize testOutput = testParam0.ToUniSize(testParam1);

            Assert.AreEqual(841, testOutput.Width);
            Assert.AreEqual(1190, testOutput.Height);
        }
        public static void PopulateSize(this TrainGraphAxisTickInfo tickInfo, IGraphicsContext context, IFontDescriptor font)
        {
            if (tickInfo is null)
            {
                throw new ArgumentNullException(nameof(tickInfo));
            }
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            UniSize measure = context.MeasureString(tickInfo.Label, font);

            tickInfo.Width  = measure.Width;
            tickInfo.Height = measure.Height;
        }