Ejemplo n.º 1
0
        void PreviewForm_DrawPrintHeader(object sender, TreeViewPrintHeaderFooterEventArgs e)
        {
            // Get the rectangle area to draw
            Rectangle header = e.DrawRectangle;

            //IMAGE
            //scale the image
            SizeF imageSize = new SizeF(header.Width / 3, header.Height * 0.8f);
            //Locating the logo on the right corner of the Drawing Surface
            PointF imageLocation = new PointF(e.DrawRectangle.Width - imageSize.Width + 100, header.Y + 5);

#if NETCORE
            Bitmap img = new Bitmap(@"..\..\..\CustomImage.png");
#else
            Bitmap img = new Bitmap(@"..\..\CustomImage.png");
#endif
            //Draw the image in the Header.
            e.Graphics.DrawImage(img, new RectangleF(new PointF(imageLocation.X, imageLocation.Y + 10), imageSize));

            //TITLE
            Color      activeColor = Color.FromArgb(44, 71, 120);
            SolidBrush brush       = new SolidBrush(activeColor);
            Font       font        = new Font("Segoe UI", 20, FontStyle.Bold);
            //Set formatting for the text
            StringFormat format = new StringFormat();
            format.Alignment     = StringAlignment.Near;
            format.LineAlignment = StringAlignment.Near;
            //Draw the title
            e.Graphics.DrawString("Information about countries", font, brush, new RectangleF(header.Location.X + 20, header.Location.Y + 30, e.DrawRectangle.Width, e.DrawRectangle.Height), format);

            ///BORDER LINES - Draw some lines in the header
            Pen pen = new Pen(Color.DarkBlue, 0.8f);
            e.Graphics.DrawLine(pen, new Point(header.Left, header.Top + 14), new Point(header.Right, header.Top + 14));
            e.Graphics.DrawLine(pen, new Point(header.Left, header.Top + 17), new Point(header.Right, header.Top + 17));
            e.Graphics.DrawLine(pen, new Point(header.Left, header.Bottom - 8), new Point(header.Right, header.Bottom - 8));
            e.Graphics.DrawLine(pen, new Point(header.Left, header.Bottom - 5), new Point(header.Right, header.Bottom - 5));

            //Dispose drawing resources
            font.Dispose();
            format.Dispose();
            pen.Dispose();
        }
Ejemplo n.º 2
0
        void PreviewForm_DrawPrintFooter(object sender, TreeViewPrintHeaderFooterEventArgs e)
        {
            //Get the rectangle area to draw
            Rectangle footer = e.DrawRectangle;

            //Draw copy right
            StringFormat format = new StringFormat();

            format.LineAlignment = StringAlignment.Center;
            format.Alignment     = StringAlignment.Center;
            Font       font  = new Font("Segoe UI", 8);
            SolidBrush brush = new SolidBrush(Color.Red);

            e.Graphics.DrawString("@copyright", font, brush, CenterPoint(footer), format);
            e.Graphics.DrawString(string.Format("page {0} of {1}", e.PageNumber, e.PageCount), font, brush, new Point(footer.Right - 100, CenterPoint(footer).Y), format);

            //Dispose resources
            format.Dispose();
            font.Dispose();
            brush.Dispose();
        }