Example #1
0
        public void NewLine(bool pBanding = false, EnumDocumentParts pArea = EnumDocumentParts.BODY)
        {
            var _line = new PrintableLine()
            {
                Banding = pBanding, LineNumber = BodyList.Lines.Count
            };

            _line.Add(new PrintableText(" ", CurrentFont));
            switch (pArea)
            {
            case EnumDocumentParts.HEADER:
                HeaderList.Lines.Add(_line);
                CurrentLineIndex = HeaderList.Lines.Count - 1;
                CurrentZone      = EnumDocumentParts.HEADER;
                break;

            case EnumDocumentParts.BODY:
                BodyList.Lines.Add(_line);
                CurrentLineIndex = BodyList.Lines.Count - 1;
                CurrentZone      = EnumDocumentParts.BODY;
                break;

            case EnumDocumentParts.FOOTER:
                FooterList.Lines.Add(_line);
                CurrentLineIndex = FooterList.Lines.Count - 1;
                CurrentZone      = EnumDocumentParts.FOOTER;
                break;
            }
        }
Example #2
0
        protected override void OnPrintPage(PrintPageEventArgs e)
        {
            var g = e.Graphics;

            g.PageUnit = GraphicsUnit.Millimeter;
            float _x = XMin;
            float _y = YMin;

            //lets print the header
            HeaderList.Lines.ForEach(l =>
            {
                PrintDocumentLine(l, g, ref _y);
            });

            // lets print the lines
            if (BodyList.LastPrintedLine > 1)
            {
                PrintDocumentLine(BodyList.Lines[1], g, ref _y, BodyXOffset); // column titles in following new pages
            }
            while (_y <= YMax && BodyList.LastPrintedLine < BodyList.Lines.Count)
            {
                PrintDocumentLine(BodyList.Lines[BodyList.LastPrintedLine], g, ref _y, BodyXOffset);
                BodyList.LastPrintedLine++;
            }

            // lets print the footer
            _y = YMax;
            FooterList.Lines.ForEach(l =>
            {
                PrintDocumentLine(l, g, ref _y);
            });

            if (PageCounter != 0)
            {
                var _pCounter = new PrintableLine();
                _pCounter.Add(new PrintableText(string.Format("Page {0}", PageCounter), new Font("Courier New", 12, FontStyle.Bold)));
                PrintDocumentLine(_pCounter, g, ref _y);
                PageCounter++;
            }

            // are going to be more pages?
            e.HasMorePages = (BodyList.LastPrintedLine < BodyList.Lines.Count);

            base.OnPrintPage(e);
        }
Example #3
0
        private void PrintDocumentLine(PrintableLine Line, Graphics g, ref float _y, float xOffset = 0)
        {
            //var l = BodyList.Lines[BodyList.LastPrintedLine];
            Line.Graphics = g;
            var _x  = XMin;
            var __y = _y;

            if (Line.Banding && (Line.LineNumber % 2 == 0))
            {
                g.FillRectangle(new SolidBrush(Color.GhostWhite), XMin + xOffset, _y, Line.Width, Line.Height);
            }
            Line.Things.ForEach(t =>
            {
                t.Draw(_x + xOffset, __y);
                _x += t.Width;
            });

            _y += Line.Height;
            _x  = XMin;
        }