예제 #1
0
파일: 2.cs 프로젝트: shinysol/rennypark
        public static void DrawTable(XGraphics graph, XPen pen, double x1, double y1, double x2, double y2, byte rowCnt, byte clmnCnt, double firstClmnWdth
                                     , bool noDiv1stRow)
        {
            double cellHeight = (y2 - y1) / rowCnt;
            double cellWidth;

            graph.DrawRectangle(pen, new XRect(x1, y1, x2 - x1, y2 - y1));  // xbrush 추가
            if (clmnCnt == 1)
            {
                cellWidth = firstClmnWdth;
            }
            else
            {
                cellWidth = (x2 - (x1 + firstClmnWdth)) / (clmnCnt - 1);
            }
            if (rowCnt >= 2)
            {
                for (int i = 1; i <= rowCnt - 1; i++)
                {
                    graph.DrawLine(pen, x1, y1 + i * cellHeight, x2, y1 + i * cellHeight);
                }
            }
            if (clmnCnt >= 2)
            {
                for (int i = 1; i <= clmnCnt - 1; i++)
                {
                    graph.DrawLine(pen, x1 + firstClmnWdth + (i - 1) * cellWidth, y1 + (noDiv1stRow ? 1 : 0) * cellHeight, x1 + firstClmnWdth + (i - 1) * cellWidth, y2);
                }
            }
            if (noDiv1stRow)
            {
                graph.DrawRectangle(new XPen(XColor.Empty), new XSolidBrush(XColor.FromArgb(250, 250, 250)), new XRect(x1, y1, x2 - x1, cellHeight));
            }
        }
예제 #2
0
        private void DrawTextAlignment(XGraphics gfx, int number)
        {
            base.BeginBox(gfx, number, "Text Alignment");
            XRect         xRect         = new XRect(0.0, 0.0, 250.0, 140.0);
            XFont         font          = new XFont("Verdana", 10.0);
            XBrush        purple        = XBrushes.Purple;
            XStringFormat xStringFormat = new XStringFormat();

            gfx.DrawRectangle(XPens.YellowGreen, xRect);
            gfx.DrawLine(XPens.YellowGreen, xRect.Width / 2.0, 0.0, xRect.Width / 2.0, xRect.Height);
            gfx.DrawLine(XPens.YellowGreen, 0.0, xRect.Height / 2.0, xRect.Width, xRect.Height / 2.0);
            gfx.DrawString("TopLeft", font, purple, xRect, xStringFormat);
            xStringFormat.Alignment = XStringAlignment.Center;
            gfx.DrawString("TopCenter", font, purple, xRect, xStringFormat);
            xStringFormat.Alignment = XStringAlignment.Far;
            gfx.DrawString("TopRight", font, purple, xRect, xStringFormat);
            xStringFormat.LineAlignment = XLineAlignment.Center;
            xStringFormat.Alignment     = XStringAlignment.Near;
            gfx.DrawString("CenterLeft", font, purple, xRect, xStringFormat);
            xStringFormat.Alignment = XStringAlignment.Center;
            gfx.DrawString("Center", font, purple, xRect, xStringFormat);
            xStringFormat.Alignment = XStringAlignment.Far;
            gfx.DrawString("CenterRight", font, purple, xRect, xStringFormat);
            xStringFormat.LineAlignment = XLineAlignment.Far;
            xStringFormat.Alignment     = XStringAlignment.Near;
            gfx.DrawString("BottomLeft", font, purple, xRect, xStringFormat);
            xStringFormat.Alignment = XStringAlignment.Center;
            gfx.DrawString("BottomCenter", font, purple, xRect, xStringFormat);
            xStringFormat.Alignment = XStringAlignment.Far;
            gfx.DrawString("BottomRight", font, purple, xRect, xStringFormat);
            base.EndBox(gfx);
        }
예제 #3
0
        public void Print()
        {
            //  components.RemoveRange(8, 7);
            var       document = new PdfDocument();
            var       image    = XImage.FromFile(Program.form1.photopath);
            PdfPage   page     = document.AddPage();
            XGraphics gfx      = XGraphics.FromPdfPage(page);

            gfx.DrawImage(image, new XRect(15, 15, 150, 150));
            gfx.DrawLine(new XPen(XColors.Aqua, 0.3), 15, 170, 165, 170);
            gfx.DrawLine(new XPen(XColors.Black, 0.2), 175, page.Height, 175, 0);
            string path  = Program.form1.filepath;
            var    brush = XBrushes.Black;
            int    y     = 0;

            foreach (var component in components)
            {
                if (y > page.Height)
                {
                    page = document.AddPage();
                    gfx  = XGraphics.FromPdfPage(page);
                    y    = 15;
                }
                if (component != null)
                {
                    component.Print(ref gfx, ref y);
                }
            }
            document.Save(path);
            Process.Start(path);
        }
예제 #4
0
        void Box2(XGraphics gfx, RectangleF rect, float startAngle, float sweepAngle)
        {
            float  xc = rect.X + rect.Width / 2;
            float  yc = rect.Y + rect.Height / 2;
            double a  = startAngle * 0.017453292519943295;
            double b  = (startAngle + sweepAngle) * 0.017453292519943295;

            gfx.DrawRectangle(XPens.Black, rect);

            for (float deg = 0; deg < 360; deg += 10)
            {
                gfx.DrawLine(XPens.Yellow, xc, yc,
                             (float)(xc + rect.Width * Math.Cos(deg * 0.017453292519943295)),
                             (float)(yc + rect.Height * Math.Sin(deg * 0.017453292519943295)));
            }

            //if (rect.Width == rect.Height)
            //{
            //  float f = Math.Max(rect.Width / 2, rect.Height / 2);
            //  for (float deg = 0; deg < 360; deg += 10)
            //    gfx.DrawLine(XPens.Goldenrod, xc, yc,
            //      (float)(xc + f * Math.Cos(deg * 0.017453292519943295)),
            //      (float)(yc + f * Math.Sin(deg * 0.017453292519943295)));
            //}
            //gfx.DrawLine(XPens.PaleGreen, xc, rect.Y, xc, rect.Y + rect.Height);
            //gfx.DrawLine(XPens.PaleGreen, rect.X, yc, rect.X + rect.Width, yc);
            gfx.DrawLine(XPens.DarkGray, xc, yc, (float)(xc + rect.Width / 2 * Math.Cos(a)), (float)(yc + rect.Height / 2 * Math.Sin(a)));
            gfx.DrawLine(XPens.DarkGray, xc, yc, (float)(xc + rect.Width / 2 * Math.Cos(b)), (float)(yc + rect.Height / 2 * Math.Sin(b)));
        }
예제 #5
0
        void DrawGridline(XGraphics gfx, XPoint origin, XPen pen, double delta, XRect box)
        {
            double xmin = box.X, ymin = box.Y, xmax = box.X + box.Width, ymax = box.Y + box.Height;
            double x, y;

            y = origin.Y;
            while (y < ymax)
            {
                gfx.DrawLine(pen, xmin, y, xmax, y);
                y += delta;
            }
            y = origin.Y - delta;
            while (y > ymin)
            {
                gfx.DrawLine(pen, xmin, y, xmax, y);
                y -= delta;
            }
            x = origin.X;
            while (x < xmax)
            {
                gfx.DrawLine(pen, x, ymin, x, ymax);
                x += delta;
            }
            x = origin.X - delta;
            while (x > xmin)
            {
                gfx.DrawLine(pen, x, ymin, x, ymax);
                x -= delta;
            }
        }
예제 #6
0
        private void DrawHeader(XGraphics gfx)
        {
            gfx.DrawLine(XPens.Orange, 50, 50, 250, 50);

            XRect rcImage = new XRect(50, 35, 100, 15);

            gfx.DrawRectangle(XBrushes.Orange, rcImage);
            gfx.DrawString("APPLICANT", FontUtility.HeaderTitle, XBrushes.White, rcImage, XStringFormats.Center);

            gfx.DrawString("John Doe", FontUtility.HeaderContentBig, XBrushes.Black, new XRect(50, 62, 100, 0));
            gfx.DrawString("*****@*****.**", FontUtility.HeaderContentNormal, XBrushes.Black, new XRect(50, 75, 100, 0));
            gfx.DrawString("802-123-4567", FontUtility.HeaderContentNormal, XBrushes.Black, new XRect(50, 85, 100, 0));

            gfx.DrawLine(XPens.DarkBlue, 280, 50, 500, 50);

            XRect rcImage2 = new XRect(280, 35, 100, 15);

            gfx.DrawRectangle(XBrushes.DarkBlue, rcImage2);
            gfx.DrawString("APPLYING FOR", FontUtility.HeaderTitle, XBrushes.White, rcImage2, XStringFormats.Center);

            gfx.DrawString("Cyber Reverse Engineer", FontUtility.HeaderContentBig, XBrushes.Black, new XRect(280, 62, 100, 0));
            gfx.DrawString("iNovex Information Systems Savage, MD", FontUtility.HeaderContentNormal, XBrushes.Black, new XRect(280, 75, 100, 0));

            XPen pen = new XPen(XColors.Orange, 1);

            pen.DashStyle = XDashStyle.Solid;
            gfx.DrawPie(pen, XBrushes.OrangeRed, 545, 5, 60, 60, 90, 90);
            gfx.DrawString("18", FontUtility.HeaderTitle, XBrushes.White, new XRect(555, 50, 50, 0));
        }
예제 #7
0
        void Box(XGraphics gfx, XRect rect, double startAngle, double sweepAngle)
        {
            double xc = rect.X + rect.Width / 2;
            double yc = rect.Y + rect.Height / 2;
            double a  = startAngle * 0.017453292519943295;
            double b  = (startAngle + sweepAngle) * 0.017453292519943295;

            XGraphicsState state = gfx.Save();

            gfx.IntersectClip(rect);
#if true
#if true_
            for (double deg = 0; deg < 360; deg += 10)
            {
                gfx.DrawLine(XPens.Yellow, xc, yc,
                             (xc + rect.Width / 2 * Math.Cos(deg * 0.017453292519943295)),
                             (yc + rect.Height / 2 * Math.Sin(deg * 0.017453292519943295)));
            }
#endif
            double f = Math.Max(rect.Width / 2, rect.Height / 2);
            for (double deg = 0; deg < 360; deg += 10)
            {
                gfx.DrawLine(XPens.Goldenrod, xc, yc,
                             (xc + f * Math.Cos(deg * 0.017453292519943295)),
                             (yc + f * Math.Sin(deg * 0.017453292519943295)));
            }

            gfx.DrawLine(XPens.PaleGreen, xc, rect.Y, xc, rect.Y + rect.Height);
            gfx.DrawLine(XPens.PaleGreen, rect.X, yc, rect.X + rect.Width, yc);
            //gfx.DrawLine(XPens.DarkGray, xc, yc, (xc + rect.Width / 2 * Math.Cos(a)), (yc + rect.Height / 2 * Math.Sin(a)));
            //gfx.DrawLine(XPens.DarkGray, xc, yc, (xc + rect.Width / 2 * Math.Cos(b)), (yc + rect.Height / 2 * Math.Sin(b)));
#endif
            gfx.Restore(state);
            gfx.DrawRectangle(properties.Pen1.Pen, rect);
        }
예제 #8
0
파일: PdfBase.cs 프로젝트: emmanuelt88/ibvd
        public virtual void DrawFooter(string text, XGraphics graphics, PdfPage page, int pageNumber, bool showPage)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            XFont font = new XFont("Arial", 13, XFontStyle.Bold);

            graphics.DrawLine(new XPen(XColors.Black), 40, page.Height.Point - 20, page.Width.Point - 40, page.Height.Point - 20);
            graphics.DrawLine(new XPen(XColors.Black), 40, page.Height.Point - 40, page.Width.Point - 40, page.Height.Point - 40);

            graphics.DrawString(text, font, XBrushes.Black,
                                new XRect(0, -22, page.Width, page.Height),
                                XStringFormats.BottomCenter);

            if (showPage)
            {
                font = new XFont("Arial", 10, XFontStyle.Regular);

                graphics.DrawString(string.Format("Pág. {0}", pageNumber.ToString().PadRight(3, '\0')), font, XBrushes.Black,
                                    new XRect(230, -25, page.Width, page.Height),
                                    XStringFormats.BottomCenter);
            }
        }
예제 #9
0
        /// <summary>
        /// Demonstrates the use of XGraphics.DrawBeziers.
        /// </summary>
        public override void RenderPage(XGraphics gfx)
        {
            base.RenderPage(gfx);

            int n     = 2;
            int count = 1 + 3 * n;

            XPoint[] points = new XPoint[count];
            Random   rnd    = new Random(42);

            for (int idx = 0; idx < count; idx++)
            {
                points[idx].X = 20 + rnd.Next(600);
                points[idx].Y = 50 + rnd.Next(800);
            }

            // Draw the points
            XPen pen = new XPen(XColors.Red, 0.5);

            pen.DashStyle = XDashStyle.Dash;
            for (int idx = 0; idx + 3 < count; idx += 3)
            {
                gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx]));
                gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 1]));
                gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 2]));
                gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 3]));
                gfx.DrawLine(pen, points[idx], points[idx + 1]);
                gfx.DrawLine(pen, points[idx + 2], points[idx + 3]);
            }

            // Draw the curve
            gfx.DrawBeziers(properties.Pen2.Pen, points);
        }
예제 #10
0
        /// <summary>
        /// Draws a line, either above or below the current text line
        /// the font is required to get the height of the row
        /// </summary>
        /// <param name="AXPos1"></param>
        /// <param name="AXPos2"></param>
        /// <param name="ALinePosition"></param>
        /// <param name="AFont"></param>
        /// <returns></returns>
        public override Boolean DrawLine(float AXPos1, float AXPos2, eLinePosition ALinePosition, eFont AFont)
        {
            float YPos;

            YPos = CurrentYPos;

            if (ALinePosition == eLinePosition.eBelow)
            {
                YPos = CurrentYPos + GetFontHeight(AFont);
            }
            else if (ALinePosition == eLinePosition.eAbove)
            {
                YPos = CurrentYPos;
            }

            if (AXPos1 != LeftMargin)
            {
                // lines above/below columns should not touch
                AXPos1 = AXPos1 + Cm(0.3f);
            }

            if (PrintingMode == ePrintingMode.eDoPrint)
            {
                FXGraphics.DrawLine(FXBlackPen, AXPos1, YPos, AXPos2, YPos);
            }

            return(true);
        }
예제 #11
0
        private static void DesenharCelula(XGraphics gfx, int inicioCelula, double topoTabela, int larguraCelula,
                                           double alturaLinha, XPen pen, string texto, bool titulo = false, bool tituloCentralizado = false)
        {
            var baseCelula = topoTabela + alturaLinha;

            gfx.DrawLine(pen, inicioCelula, topoTabela, larguraCelula, topoTabela);
            gfx.DrawLine(pen, inicioCelula, topoTabela, inicioCelula, baseCelula);
            gfx.DrawLine(pen, inicioCelula, baseCelula, larguraCelula, baseCelula);
            gfx.DrawLine(pen, larguraCelula, topoTabela, larguraCelula, baseCelula);

            if (string.IsNullOrWhiteSpace(texto) == false)
            {
                var font = new XFont("Verdana", 12, (titulo ? XFontStyle.Bold : XFontStyle.Regular));

                var format = new XStringFormat
                {
                    Alignment     = (tituloCentralizado ? XStringAlignment.Center : XStringAlignment.Near),
                    LineAlignment = XLineAlignment.BaseLine
                };

                var tx = new XTextFormatter(gfx);

                if (tituloCentralizado)
                {
                    var textMeasure = gfx.MeasureString(texto, font);

                    gfx.DrawString(texto, font, XBrushes.Black, ((double)larguraCelula / 2), topoTabela + textMeasure.Height, format);
                }
                else
                {
                    tx.DrawString(texto, font, XBrushes.Black, new XRect(new XPoint(inicioCelula + 5, topoTabela + 5), new XPoint(larguraCelula, baseCelula)));
                }
            }
        }
예제 #12
0
        private double printColumn(PDFColumn column, double[] bg, double[] border, double x, double y)
        {
            double width  = column.GetWidth() * pageWidth / widthSum;
            double height = column.GetHeight() * HeaderLineHeight;

            if (height > 0 && width > 0)
            {
                XRect cellIn = new XRect();
                cellIn.Location = new XPoint(x, y);
                cellIn.Size     = new XSize(width, height);

                gfx.DrawRectangle(new XSolidBrush(RGBColor.GetXColor(bg)), cellIn);

                String label  = textWrap(column.GetName(), width - 2 * CellOffset, f1);
                double text_x = x + (width - gfx.MeasureString(label, f1).Width) / 2;

                double text_y = y + (height + f1.Size) / 2;
                gfx.DrawString(label, f1, new XSolidBrush(RGBColor.GetXColor(headerTextColor)), new XPoint(text_x, text_y));

                var points = new XPoint[4];
                points[0] = new XPoint(x + width, y + height);
                points[1] = new XPoint(x + width, y);
                points[2] = new XPoint(x, y);
                points[3] = new XPoint(x, y + height);
                gfx.DrawLine(new XPen(RGBColor.GetXColor(border), BorderWidth), points[0], points[1]);
                gfx.DrawLine(new XPen(RGBColor.GetXColor(border), BorderWidth), points[1], points[2]);
                gfx.DrawLine(new XPen(RGBColor.GetXColor(border), BorderWidth), points[2], points[3]);
                gfx.DrawLine(new XPen(RGBColor.GetXColor(border), BorderWidth), points[3], points[0]);
            }
            return(width);
        }
예제 #13
0
 private void drawLines(XGraphics gfx, PdfPage page, int w1 = -1, int w2 = -1, int w3 = -1, int w4 = -1, int w5 = -1)
 {
     gfx.DrawLine(XPens.Black, w1, 50, w1, page.Height - 55);
     gfx.DrawLine(XPens.Black, w2, 50, w2, page.Height - 55);
     gfx.DrawLine(XPens.Black, w3, 50, w3, page.Height - 55);
     gfx.DrawLine(XPens.Black, w4, 50, w4, page.Height - 55);
     gfx.DrawLine(XPens.Black, w5, 50, w5, page.Height - 55);
 }
예제 #14
0
        public void DrawHorizontalLineDouble(double pinSize, double y, double margin)
        {
            XGraphics graph = XGraphics.FromPdfPage(pdfPage);
            XPen      pen   = new XPen(XColor.FromName("Black"), pinSize);

            graph.DrawLine(pen, 0 + margin, y, this.Width - margin, y);
            graph.DrawLine(pen, 0 + margin, y + pinSize * 2, this.Width - margin, y + pinSize * 2);
            graph.Dispose();
        }
예제 #15
0
        private void DrawSummary(XGraphics g, TimeSpan plannedEnd, TimeSpan actualEnd)
        {
            if (_subTitleFont == null)
            {
                throw new InvalidOperationException(nameof(_titleFont));
            }

            if (_itemFont == null)
            {
                throw new InvalidOperationException(nameof(_itemFont));
            }

            if (_itemTitleFont == null)
            {
                throw new InvalidOperationException(nameof(_itemTitleFont));
            }

            _currentY += 2 * _itemTitleFont.Height;

            var linePen = new XPen(XColors.Gray);

            g.DrawLine(linePen, _leftMargin, _currentY, _rightX, _currentY);

            _currentY += _subTitleFont.Height;

            g.DrawString(Resources.OVERALL_STATUS, _subTitleFont, _blackBrush, new XPoint(_leftMargin, _currentY));
            _currentY += _subTitleFont.Height;

            var minsOvertime = (actualEnd - plannedEnd).TotalMinutes;

            if (minsOvertime > 1)
            {
                var mins = (int)Math.Round(minsOvertime);

                var msg = mins == 1
                   ? Resources.OVERTIME_BY_1
                   : string.Format(Resources.OVERTIME_BY, mins);

                g.DrawString(msg, _itemTitleFont, _redBrush, new XPoint(_leftMargin, _currentY));
            }
            else if (minsOvertime < -1)
            {
                var mins = Math.Abs((int)Math.Round(minsOvertime));
                var msg  = mins == 1
                   ? Resources.UNDERTIME_BY_1
                   : string.Format(Resources.UNDERTIME_BY, mins);

                g.DrawString(msg, _itemTitleFont, _greenBrush, new XPoint(_leftMargin, _currentY));
            }
            else
            {
                g.DrawString(Resources.ON_TIME, _itemTitleFont, _greenBrush, new XPoint(_leftMargin, _currentY));
            }

            _currentY += (double)_itemFont.Height / 2;
            g.DrawLine(linePen, _leftMargin, _currentY, _rightX, _currentY);
        }
예제 #16
0
        public static void CreateRibPdf()
        {
            int x, y;

            x = 50;
            y = 4;
            // Create a font
            XFont font12B = new XFont("Verdana", 6, XFontStyle.Bold);
            XFont font12  = new XFont("Verdana", 6, XFontStyle.Regular);
            XPen  pen     = new XPen(XColors.Black, 0.5)
            {
                DashStyle = XDashStyle.Solid
            };

            // Create a new PDF document
            PdfDocument document = new PdfDocument();

            document.Info.Title        = "Créé grâce à PDFsharp";
            document.Info.Author       = "OrionBanque";
            document.Info.CreationDate = DateTime.Now;
            document.Info.Subject      = "RIB du compte";

            // Create an empty page
            PdfPage page = document.AddPage();

            // Get an XGraphics object for drawing
            XGraphics gfx = XGraphics.FromPdfPage(page);

            // Draw the first Top Line
            gfx.DrawLine(pen, 4, y, page.Width - 4, y);
            gfx.DrawString("RELEVE D'IDENTITE BANCAIRE", font12B, XBrushes.Black, new XRect(0, y, page.Width, page.Height), XStringFormats.TopCenter);
            y += 40;

            // Draw the text
            gfx.DrawString("Banque", font12B, XBrushes.Black, new XRect(x, y, page.Width, page.Height), XStringFormats.TopLeft);
            gfx.DrawString("Guichet", font12B, XBrushes.Black, new XRect(x + 50, y, page.Width, page.Height), XStringFormats.TopLeft);
            gfx.DrawString("Compte", font12B, XBrushes.Black, new XRect(x + 100, y, page.Width, page.Height), XStringFormats.TopLeft);
            gfx.DrawString("Clé", font12B, XBrushes.Black, new XRect(x + 180, y, page.Width, page.Height), XStringFormats.TopLeft);
            y += 10;

            gfx.DrawString("55700", font12, XBrushes.Black, new XRect(x, y, page.Width, page.Height), XStringFormats.TopLeft);
            gfx.DrawString("55700 ", font12, XBrushes.Black, new XRect(x + 50, y, page.Width, page.Height), XStringFormats.TopLeft);
            gfx.DrawString("3370074882301 ", font12, XBrushes.Black, new XRect(x + 100, y, page.Width, page.Height), XStringFormats.TopLeft);
            gfx.DrawString("39 ", font12, XBrushes.Black, new XRect(x + 180, y, page.Width, page.Height), XStringFormats.TopLeft);
            y += 30;

            // Draw the separator line
            gfx.DrawLine(pen, 4, y, page.Width - 4, y);

            // Save the document...
            const string filename = "RIB.pdf";

            document.Save(filename);
            // ...and start a viewer.
            Process.Start(filename);
        }
예제 #17
0
        private void drawSpaceSymbol(PointF position, XColor color, XFont font, XGraphics gfx)
        {
            var size = gfx.MeasureString("M", font);
            var pen = new XPen(color, 1);

            gfx.DrawLine(pen, new XPoint(position.X, position.Y + size.Height), new XPoint(position.X + size.Width, position.Y + size.Height));
            gfx.DrawLine(pen, new XPoint(position.X, position.Y + size.Height), new XPoint(position.X, position.Y + size.Height * 0.8));
            gfx.DrawLine(pen, new XPoint(position.X + size.Width, position.Y + size.Height), new XPoint(position.X + size.Width, position.Y + size.Height * 0.8));

        }
        void DrawCurve(XGraphics gfx)
        {
            XPen pen = new XPen(XColors.Navy, 4);

            gfx.DrawLine(pen, 0, 20, 250, 20);

            pen           = new XPen(XColors.Firebrick, 6);
            pen.DashStyle = XDashStyle.Dash;
            gfx.DrawLine(pen, 0, 40, 250, 40);
            pen.Width     = 7.3;
            pen.DashStyle = XDashStyle.DashDotDot;
            gfx.DrawLine(pen, 0, 60, 250, 60);

            pen         = new XPen(XColors.Goldenrod, 10);
            pen.LineCap = XLineCap.Flat;
            gfx.DrawLine(pen, 10, 90, 240, 90);
            gfx.DrawLine(XPens.Black, 10, 90, 240, 90);

            pen         = new XPen(XColors.Goldenrod, 10);
            pen.LineCap = XLineCap.Square;
            gfx.DrawLine(pen, 10, 110, 240, 110);
            gfx.DrawLine(XPens.Black, 10, 110, 240, 110);

            pen         = new XPen(XColors.Goldenrod, 10);
            pen.LineCap = XLineCap.Round;
            gfx.DrawLine(pen, 10, 130, 240, 130);
            gfx.DrawLine(XPens.Black, 10, 130, 240, 130);
        }
예제 #19
0
        private static void drawMainTable(PdfPage newPage, XGraphics gfx, XPen pen, int startX, int startY, int columnWidth, int rowHeight, DataTable dt)
        {
            int rowCount    = AppForm.CURR_OCTT_DOC.IncludedTerms.Count;
            int columnCount = AppForm.CURR_OCTT_DOC.getNumberOfDays();

            for (int j = 0; j < rowCount; j++)
            {
                gfx.DrawLine(pen, startX, startY + (j + 1) * rowHeight, startX + columnCount * columnWidth, startY + (j + 1) * rowHeight);

                for (int k = 0; k < columnCount; k++)
                {
                    gfx.DrawLine(pen, startX + (k + 1) * columnWidth, startY, startX + (k + 1) * columnWidth, startY + rowCount * rowHeight);
                }
            }

            for (int j = 0; j < rowCount; j++)
            {
                DataRow dr = dt.Rows[j];
                for (int k = 0; k < columnCount; k++)
                {
                    string cellString = (string)dr[k];
                    if (cellString != "")
                    {
                        XRect rect = new XRect(startX + k * columnWidth + 4, startY + j * rowHeight + 4, columnWidth - 8, rowHeight - 8);

                        //
                        XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

                        //XFont font = new XFont("Arial", 6, XFontStyle.Regular,  options);
                        XFont  font  = getMyFont(Settings.TTREP_FONT_TIME_SLOTS, options);
                        XBrush brush = XBrushes.Black;
                        //XStringFormat format = new XStringFormat();
                        //
                        char[] separator = new char[1];
                        separator[0] = ',';
                        string[] ss = Settings.TTREP_COLOR_TS.Split(separator, 3);
                        int      R  = System.Convert.ToInt32(ss[0]);
                        int      G  = System.Convert.ToInt32(ss[1]);
                        int      B  = System.Convert.ToInt32(ss[2]);

                        gfx.DrawRectangle(XPens.Black, new XSolidBrush(XColor.FromArgb(R, G, B)), rect);

                        //
                        //gfx.DrawRectangle(XPens.Black, XBrushes.LightCyan, rect);

                        rect = new XRect(startX + k * columnWidth + 6, startY + j * rowHeight + 6, columnWidth - 12, rowHeight - 12);

                        XTextFormatter tf = new XTextFormatter(gfx);
                        tf.Alignment = XParagraphAlignment.Center;
                        tf.DrawString(cellString, font, brush, rect, XStringFormat.TopLeft);
                    }
                }
            }
        }
예제 #20
0
        private void DrawHLine(int x, int y, int Width, string lColorCode = "0", string sLineType = "")
        {
            // XPen mPen = new XPen(XColors.Black);
            XPen mPen = new XPen(XColor(Lib.GetColorName(lColorCode)));

            if (sLineType == "DOT")
            {
                mPen.DashStyle = XDashStyle.Dot;
            }
            gfx.DrawLine(mPen, x, y, x + Width, y);
        }
예제 #21
0
 // Create PDF
 private void BtnEddigi_Click(object sender, EventArgs e)
 {
     if (cc.IfLogin())
     {
         // órák lekérdezése
         MySqlCommand parancs = new MySqlCommand();
         parancs.Parameters.AddWithValue("tanarneve", TxtOktatoNev.Text);
         parancs.Connection  = cc.connection;
         parancs.CommandText = "SELECT oraterv.datum FROM oraterv INNER JOIN kurzus ON(kurzus.id = oraterv.kurzus_id) INNER JOIN tanar ON(tanar.id = kurzus.tanar_id) WHERE tanar.nev = @tanarneve AND MONTH(oraterv.datum) = " + ComboHonapok.SelectedItem.ToString() + "";
         parancs.ExecuteNonQuery();
         MySqlDataReader olvas = parancs.ExecuteReader();
         // PDF elmentése, készítése
         SaveFileDialog sfd = new SaveFileDialog();
         // PDF dokumentum készítése
         PdfDocument doc  = new PdfDocument();
         PdfPage     page = doc.AddPage();
         XGraphics   xg   = XGraphics.FromPdfPage(page);
         XBrush      xb   = new XSolidBrush(XColors.Black);
         XFont       xf   = new XFont("Open Sans", 14f);
         // téglalap
         xg.DrawLine(new XPen(Color.Red, 5f), new Point(60, 40), new Point(520, 40));
         xg.DrawLine(new XPen(Color.Orange, 5f), new Point(520, 40), new Point(520, 80));
         xg.DrawLine(new XPen(Color.Red, 5f), new Point(60, 80), new Point(520, 80));
         xg.DrawLine(new XPen(Color.Orange, 5f), new Point(60, 40), new Point(60, 80));
         // téglalap vége
         xg.DrawString("COOLSCOOL ISKOLA " + TxtOktatoNev.Text + " OKTATÓJA", xf, xb, new PointF(150, 65));
         int hanyszor = 1;
         while (olvas.Read())
         {
             xg.DrawString(olvas[0].ToString() + "..........................................................", xf, xb, new PointF(60, (103 + (hanyszor * 30))));
             hanyszor++;
         }
         xg.DrawString("...............................................................", xf, xb, new PointF(300, 770));
         xg.DrawString("Vezető oktató aláírása:  " + _vo.nev, xf, xb, new PointF(300, 800));
         doc.Info.Author       = "CoolScool";
         doc.Info.Creator      = _vo.nev;
         doc.Info.CreationDate = DateTime.Now;
         sfd.FileName          = TxtOktatoNev.Text + " munka.pdf";
         if (sfd.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 doc.Save(new System.IO.FileInfo(sfd.FileName).FullName);
             }
             catch (System.IO.IOException)
             {
                 MessageBox.Show("HIBA! A fájlt egy másik folyamat használja!");
             }
         }
         olvas.Close();
         cc.connection.Close();
     }
 }
예제 #22
0
        public void Draw(XGraphics gfx)
        {
            string s = "Testtext";
            //gfx.DrawLine(XPens.GreenYellow, 5, 100, 30, 50);
            //gfx.DrawEllipse(XBrushes.DarkBlue, new XRect(30, 40, 250, 235));
            XFont font = new XFont("Arial", 40, XFontStyle.Italic);

            gfx.DrawString(s, font, XBrushes.Firebrick, 40, 60);
            XSize size = gfx.MeasureString(s, font);

            gfx.DrawLine(XPens.DarkBlue, 40, 60, 40 + size.Width, 60);
            gfx.DrawLine(XPens.DarkBlue, 40, 60, 40, 60 + size.Height);
        }
        /// <summary>
        /// Demonstrates the use of XGraphics.Transform.
        /// </summary>
        public override void RenderPage(XGraphics gfx)
        {
            base.RenderPage(gfx);

            gfx.Save();

            gfx.IntersectClip(new XRect(20, 20, 300, 500));
            gfx.DrawRectangle(XBrushes.Yellow, 0, 0, gfx.PageSize.Width, gfx.PageSize.Height);

            gfx.IntersectClip(new XRect(100, 200, 300, 500));
            gfx.DrawRectangle(XBrushes.LightBlue, 0, 0, gfx.PageSize.Width, gfx.PageSize.Height);

            gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
            gfx.DrawPolygon(properties.Pen1.Pen, GetPentagram(75, new PointF(150, 200)));


            Matrix matrix = new Matrix();

            //matrix.Scale(2f, 1.5f);
            //matrix.Translate(-200, -400);
            //matrix.Rotate(45);
            //matrix.Translate(200, 400);
            //gfx.Transform = matrix;
            //gfx.TranslateTransform(50, 30);

#if true
            gfx.TranslateTransform(30, 40, XMatrixOrder.Prepend);
            gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Prepend);
            gfx.RotateTransform(15, XMatrixOrder.Prepend);
#else
            gfx.TranslateTransform(30, 40, XMatrixOrder.Append);
            gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Append);
            gfx.RotateTransform(15, XMatrixOrder.Append);
#endif
            bool id = matrix.IsIdentity;
            matrix.Scale(2.0f, 2.0f, MatrixOrder.Prepend);
            //matrix.Translate(30, -50);
            matrix.Rotate(15, MatrixOrder.Prepend);
            //Matrix mtx = gfx.Transform.ToGdipMatrix();
            //gfx.Transform = matrix;

            gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
            gfx.DrawPolygon(properties.Pen2.Pen, GetPentagram(75, new PointF(150, 200)));

            //gfx.ResetClip();
            gfx.Restore();

            gfx.DrawLine(XPens.Red, 0, 0, 1000, 1000);

            gfx.DrawPolygon(XPens.SandyBrown, GetPentagram(75, new PointF(150, 200)));
        }
예제 #24
0
        /// <summary>
        /// Draws the table lines inside the outerframe
        /// </summary>
        /// <param name="rect">XRect the size of the outer frame</param>
        private void DrawInnerFrame(XRect rect)
        {
            var penRegular = new XPen(XColor.FromName("Black"), 0.5);

            //The vertical lines
            _gfx.DrawLine(penRegular, rect.TopLeft.X + rect.Width / 2, rect.TopLeft.Y, rect.TopLeft.X + rect.Width / 2, rect.BottomLeft.Y);
            _gfx.DrawLine(penRegular, rect.TopLeft.X + rect.Width * 0.75, rect.TopLeft.Y, rect.TopLeft.X + rect.Width * 0.75, rect.BottomLeft.Y);

            //The horizontal lines
            for (double i = rect.TopLeft.Y + (rect.Height / _rows); i < rect.BottomLeft.Y; i += rect.Height / _rows)
            {
                _gfx.DrawLine(penRegular, rect.TopLeft.X, i, rect.TopRight.X, i);
            }
        }
예제 #25
0
        private static void DrawCropMarks(PdfPage page, XGraphics gfx, XUnit xunitsBetweenTrimAndMediaBox)
        {
            XPoint upperLeftTrimBoxCorner  = page.TrimBox.ToXRect().TopLeft;
            XPoint upperRightTrimBoxCorner = page.TrimBox.ToXRect().TopRight;
            XPoint lowerLeftTrimBoxCorner  = page.TrimBox.ToXRect().BottomLeft;
            XPoint lowerRightTrimBoxCorner = page.TrimBox.ToXRect().BottomRight;

            //while blue would look nicer, then if they make color separations, the marks wouldn't show all all of them.
            //Note that in InDesign, there is a "registration color" which looks black but is actually 100% of all each
            //sep color, so it always prints. But I don't see a way to do that in PDF.
            //.25 is a standard width
            var pen = new XPen(XColor.FromKnownColor(XKnownColor.Black), .25);

            var gapLength = XUnit.FromMillimeter(3.175);         // this 3.175 is the industry standard

            gfx.DrawLine(pen, upperLeftTrimBoxCorner.X - gapLength, upperLeftTrimBoxCorner.Y,
                         upperLeftTrimBoxCorner.X - xunitsBetweenTrimAndMediaBox, upperLeftTrimBoxCorner.Y);
            gfx.DrawLine(pen, upperLeftTrimBoxCorner.X, upperLeftTrimBoxCorner.Y - gapLength, upperLeftTrimBoxCorner.X,
                         upperLeftTrimBoxCorner.Y - xunitsBetweenTrimAndMediaBox);

            gfx.DrawLine(pen, upperRightTrimBoxCorner.X + gapLength, upperRightTrimBoxCorner.Y,
                         upperRightTrimBoxCorner.X + xunitsBetweenTrimAndMediaBox, upperLeftTrimBoxCorner.Y);
            gfx.DrawLine(pen, upperRightTrimBoxCorner.X, upperRightTrimBoxCorner.Y - gapLength, upperRightTrimBoxCorner.X,
                         upperLeftTrimBoxCorner.Y - xunitsBetweenTrimAndMediaBox);

            gfx.DrawLine(pen, lowerLeftTrimBoxCorner.X - gapLength, lowerLeftTrimBoxCorner.Y,
                         lowerLeftTrimBoxCorner.X - xunitsBetweenTrimAndMediaBox, lowerLeftTrimBoxCorner.Y);
            gfx.DrawLine(pen, lowerLeftTrimBoxCorner.X, lowerLeftTrimBoxCorner.Y + gapLength, lowerLeftTrimBoxCorner.X,
                         lowerLeftTrimBoxCorner.Y + xunitsBetweenTrimAndMediaBox);

            gfx.DrawLine(pen, lowerRightTrimBoxCorner.X + gapLength, lowerRightTrimBoxCorner.Y,
                         lowerRightTrimBoxCorner.X + xunitsBetweenTrimAndMediaBox, lowerRightTrimBoxCorner.Y);
            gfx.DrawLine(pen, lowerRightTrimBoxCorner.X, lowerRightTrimBoxCorner.Y + gapLength, lowerRightTrimBoxCorner.X,
                         lowerRightTrimBoxCorner.Y + xunitsBetweenTrimAndMediaBox);
        }
예제 #26
0
        public void formatePDF(EventDTO eventSingle)
        {
            Bitmap qr = QRGenerator.CreateQRCodeAsBitmap(eventSingle.Id);
            // Bitmap logo = new Bitmap (@"\\Mac\\Home\\Desktop\\project\\test\\easvtickets\\PDFManager\\Core\\image001.jpg");
            PdfDocument doc  = new PdfDocument();
            PdfPage     page = doc.AddPage();
            Bitmap      logo = (Bitmap)logoEASV.EasvLogo;
            //Create graphic object for drawing string and images

            XImage    img = XImage.FromGdiPlusImage(qr);
            XGraphics gfx = XGraphics.FromPdfPage(page);

            XImage img2 = XImage.FromGdiPlusImage(logo);
            XFont  font = new XFont("Arial", 14);

            //            gfx.DrawString("Hello, World!", font, XBrushes.Black, new XRect(10, 10, page.Width, page.Height),
            //#pragma warning disable CS0618 // Type or member is obsolete
            //                         XStringFormat.Center);
            //#pragma warning restore CS0618 // Type or member is obsolete

            gfx.DrawString("Hi, Dear XX:", font, XBrushes.Black,
                           new XRect(40, 0, page.Width - 400, 100), XStringFormats.Center);
            gfx.DrawString("This is your ticket.", font, XBrushes.Black,
                           new XRect(40, 0, page.Width - 300, 150), XStringFormats.Center);

            gfx.DrawString("You have bought ticket of " + eventSingle.Name + ".", font, XBrushes.Black,
                           new XRect(40, 0, page.Width - 300, 200), XStringFormats.Center);
            //gfx.DrawLine(XPens.Black, 40, 130, page.Width - 40, 130);
            gfx.DrawString("The price is " + eventSingle.Price + ".", font, XBrushes.Black,
                           new XRect(40, 0, page.Width - 300, 250), XStringFormats.Center);
            gfx.DrawLine(XPens.Black, 40, 150, page.Width - 40, 150);

            gfx.DrawImage(img, 80, 180);

            gfx.DrawLine(XPens.Black, 40, 600, page.Width - 40, 600);

            gfx.DrawString("Med venlig hilsen", font, XBrushes.Black,
                           new XRect(40, 0, page.Width - 300, 1250), XStringFormats.Center);
            gfx.DrawString("Erhvervsakademi Sydvest", font, XBrushes.Black,
                           new XRect(40, 0, page.Width - 300, 1300), XStringFormats.Center);
            gfx.DrawImage(img2, 80, 680);
            gfx.DrawString("Spangsbjerg Kirkevej 103 - 6700 Esbjerg", font, XBrushes.Black,
                           new XRect(40, 0, page.Width - 300, 1500), XStringFormats.Center);

            string filename = "C:\\Users\\huaye\\Desktop\\HelloWorld.pdf";

            doc.Save(filename);
            // ...and start a viewer.
            Process.Start(filename);
        }
예제 #27
0
        private void DrawBody(XGraphics gfx)
        {
            for (int x = 0; x < 15; x++)
            {
                XGraphicsState state1 = gfx.Save();
                gfx.RotateAtTransform(-70, new XPoint(200 + (x * 20), 250));
                gfx.DrawString("Long Text Here : Always expect more " + (x + 1), FontUtility.HeaderContentNormal, XBrushes.Black, new XPoint(200 + (x * 20), 250));
                gfx.Restore(state1);
            }

            for (int x = 0; x < 15; x++)
            {
                XPen pen = new XPen(XColors.Gray, 1);
                gfx.DrawRectangle(pen, XBrushes.White, new XRect(195 + (x * 20), 260, 8, 25));
                if (x % 2 == 0)
                {
                    gfx.DrawRectangle(XBrushes.LightGray, new XRect(195 + (x * 20), 270, 8, 15));
                }
            }

            int lineHeight = 20;
            int topHeight  = 0;

            for (int x = 0; x < 20; x++)
            {
                topHeight = 300 + lineHeight * x;
                gfx.DrawLine(XPens.LightGray, 50, topHeight, 490, topHeight);

                if (x % 2 == 0)
                {
                    gfx.DrawString("&", FontUtility.BodyContentTick, XBrushes.Green, new XRect(50, topHeight + 8, 10, 0));
                }
                else
                {
                    gfx.DrawString("#", FontUtility.BodyContentTick, XBrushes.Green, new XRect(50, topHeight + 8, 10, 0));
                }
                gfx.DrawString("Associate Consultant " + (x + 1), FontUtility.BodyContentNormal, XBrushes.Black, new XRect(60, topHeight + 8, 100, 0));
                gfx.DrawString("8/2011 - present", FontUtility.BodyContentNormal, XBrushes.Black, new XRect(50, topHeight + 16, 100, 0));
                for (int y = 0; y < 16; y++)
                {
                    XPen pen = new XPen(XColors.Gray, 1);
                    gfx.DrawLine(pen, new XPoint(190 + (y * 20), topHeight), new XPoint(190 + (y * 20), (topHeight + 20)));
                    if (y % 2 == 0)
                    {
                        gfx.DrawImage(XImage.FromFile("../Images/Green-Tick.png"), new XRect(190 + (y * 20) + 5, topHeight + 6, 10, 10));
                    }
                }
            }
            gfx.DrawLine(XPens.LightGray, 50, topHeight + lineHeight, 490, topHeight + lineHeight);
        }
        public void HelloWorldPDF()
        {
            PdfDocument pdf = new PdfDocument();

            pdf.Info.Title = "Test pdf page";

            PdfPage page = pdf.AddPage();

            XGraphics gfx = XGraphics.FromPdfPage(page);

            XFont font = new XFont("Arial", 20, XFontStyle.Regular);

            //gfx.DrawString(
            //    "Hello, World!",
            //    font,
            //    XBrushes.Black,
            //    new XRect(0, 0, page.Width, page.Height),
            //    XStringFormats.Center
            //);

            XPen pen = XPens.DarkGray;


            gfx.DrawLine(pen, 50, 50, page.Width - 50, 50);
            gfx.DrawString("testing", font, XBrushes.Black, new XPoint(100, 70));
            gfx.DrawLine(pen, 50, 80, page.Width - 50, 80);
            gfx.DrawString("testingPass", font, XBrushes.DarkBlue, new XPoint(100, 200));
            gfx.DrawString("testingFail", font, XBrushes.DarkRed, new XPoint(100, 300));

            string filename = "";

            if (filename.Equals(""))
            {
                SaveFileDialog saveFile = new SaveFileDialog();
                saveFile.Filter = "PDF | *.pdf";
                saveFile.Title  = "Choose Save File Path";
                saveFile.ShowDialog();

                filename = saveFile.FileName;
            }

            try
            {
                pdf.Save(filename);
            }
            catch (Exception e)
            {
                Console.Out.WriteLine($"Error: {e.Message}");
            }
        }
예제 #29
0
        public override void DrawLine(Color c, float width, PointF p1, PointF p2, bool capStart = false, bool capEnd = false)
        {
            Pen p = new Pen(c, width);

            if (capStart)
            {
                p.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
            }
            if (capEnd)
            {
                p.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
            }
            g.DrawLine(p, p1, p2);
        }
예제 #30
0
        private static void PaintPdfCellLines(XGraphics graphicsDc, float left, float right, float top, float bottom)
        {
            //XPen blackPen = new XPen(XColor.FromArgb(0, 0, 0), 0.009);
            XPen greyPen = new XPen(XColor.FromArgb(192, 192, 192), 0.009);

            //left
            graphicsDc.DrawLine(greyPen, left, bottom, left, top);
            //top
            graphicsDc.DrawLine(greyPen, left, top, right, top);
            //right
            graphicsDc.DrawLine(greyPen, right, top, right, bottom);
            // bottom
            graphicsDc.DrawLine(greyPen, left, bottom, right, bottom);
        }