Exemple #1
0
        public void IsToPrint_NegativePage_ThrowsException()
        {
            var pd = new PrintDefinition();

            pd.SetPrintAttribute(new PrintOnAllPagesAttribute(PrintAppendixes.Footer));
            Assert.That(() => pd.IsToPrint(PrintAppendixes.Footer, -1, false), Throws.InstanceOf <ArgumentOutOfRangeException>());
        }
Exemple #2
0
        public void SetPrintAttribute()
        {
            var pd = new PrintDefinition();

            pd.SetPrintAttribute(new PrintOnPageAttribute(PrintAppendixes.Footer, 1));

            Assert.That(pd.IsDefined(PrintAppendixes.Footer), Is.True);
        }
Exemple #3
0
        public void IsToPrint_CheckLastPage()
        {
            var pd = new PrintDefinition();

            Assert.That(pd.IsToPrint(PrintAppendixes.Footer, 2, true), Is.False);

            pd.SetPrintAttribute(new PrintOnPageAttribute(PrintAppendixes.Footer, PrintPartDefinitionAttribute.LastPage));

            Assert.That(pd.IsToPrint(PrintAppendixes.Footer, 2, true), Is.True);
        }
        private void SetPrintOnAttributes()
        {
            var customPageAttributes = (IPrintPartDefinition[])GetType().GetCustomAttributes(typeof(IPrintPartDefinition), true);

            foreach (var printOnAttribute in customPageAttributes)
            {
                PrintDefinition.SetPrintAttribute(printOnAttribute);
            }
            PrintDimension.InternalPrintDefinition = PrintDefinition;
        }
Exemple #5
0
        public void IsToPrint_IncludePage()
        {
            var pd = new PrintDefinition();

            Assert.That(pd.IsToPrint(PrintAppendixes.Footer, 1, false), Is.False);

            pd.SetPrintAttribute(new PrintOnPageAttribute(PrintAppendixes.Footer, 2));

            Assert.That(pd.IsToPrint(PrintAppendixes.Footer, 1, false), Is.False);
            Assert.That(pd.IsToPrint(PrintAppendixes.Footer, 2, false), Is.True);
        }
Exemple #6
0
        public void IsToPrint_CheckSinglePage()
        {
            var pd = new PrintDefinition();

            pd.SetPrintAttribute(new PrintOnPageAttribute(PrintAppendixes.Footer, PrintPartDefinitionAttribute.LastPage));

            // do not print on page #1
            Assert.That(pd.IsToPrint(PrintAppendixes.Footer, 1, false), Is.False);

            // but print on last page
            Assert.That(pd.IsToPrint(PrintAppendixes.Footer, 1, true), Is.True);
        }
        protected override void PreparePrint()
        {
            base.PreparePrint();
            PrintDimension.Margin = new Thickness(50);

            if (_printingAppendix.HasFlag(PrintAppendixes.Summary))
            {
                PrintDefinition.SetPrintAttribute(new PrintOnAllPagesAttribute(PrintAppendixes.Summary));
            }
            if (_printingAppendix.HasFlag(PrintAppendixes.Footer))
            {
                PrintDefinition.SetPrintAttribute(new PrintOnAllPagesAttribute(PrintAppendixes.Footer));
            }
            if (_printingAppendix.HasFlag(PrintAppendixes.Header))
            {
                PrintDefinition.SetPrintAttribute(new PrintOnAllPagesAttribute(PrintAppendixes.Header));
            }
        }
Exemple #8
0
        protected override void PreparePrint()
        {
            base.PreparePrint();
            PrintDimension.Margin = new Thickness(50);

            if (_printingAppendix.HasFlag(PrintAppendixes.Summary))
            {
                PrintDefinition.SetPrintAttribute(new PrintOnAllPagesAttribute(PrintAppendixes.Summary));
                PrintDimension.SummaryHeight = GetSummary().ComputeDesiredSize().Height;
            }
            if (_printingAppendix.HasFlag(PrintAppendixes.Footer))
            {
                PrintDefinition.SetPrintAttribute(new PrintOnAllPagesAttribute(PrintAppendixes.Footer));
                PrintDimension.FooterHeight = GetFooter().ComputeDesiredSize().Height;
            }
            if (_printingAppendix.HasFlag(PrintAppendixes.Header))
            {
                PrintDefinition.SetPrintAttribute(new PrintOnAllPagesAttribute(PrintAppendixes.Header));
                PrintDimension.HeaderHeight = GetHeader().ComputeDesiredSize().Height;
            }
        }
Exemple #9
0
        public void IsToPrint_InvalidArgumentException()
        {
            var pd = new PrintDefinition();

            Assert.That(() => pd.IsToPrint((PrintAppendixes)(-1), 1, false), Throws.ArgumentException);
        }
Exemple #10
0
        public void SetPrintAttribute_Null_ThrowsException()
        {
            var pd = new PrintDefinition();

            Assert.That(() => pd.SetPrintAttribute(null), Throws.ArgumentNullException);
        }