Esempio n. 1
1
        /// <summary>
        /// Renders the matrix code.
        /// </summary>
        protected internal override void Render(XGraphics gfx, XBrush brush, XPoint position)
        {
            XGraphicsState state = gfx.Save();

            switch (Direction)
            {
                case CodeDirection.RightToLeft:
                    gfx.RotateAtTransform(180, position);
                    break;

                case CodeDirection.TopToBottom:
                    gfx.RotateAtTransform(90, position);
                    break;

                case CodeDirection.BottomToTop:
                    gfx.RotateAtTransform(-90, position);
                    break;
            }

            XPoint pos = position + CalcDistance(Anchor, AnchorType.TopLeft, Size);

            if (MatrixImage == null)
                MatrixImage = DataMatrixImage.GenerateMatrixImage(Text, Encoding, Rows, Columns);

            if (QuietZone > 0)
            {
                XSize sizeWithZone = new XSize(Size.Width, Size.Height);
                sizeWithZone.Width = sizeWithZone.Width / (Columns + 2 * QuietZone) * Columns;
                sizeWithZone.Height = sizeWithZone.Height / (Rows + 2 * QuietZone) * Rows;

                XPoint posWithZone = new XPoint(pos.X, pos.Y);
                posWithZone.X += Size.Width / (Columns + 2 * QuietZone) * QuietZone;
                posWithZone.Y += Size.Height / (Rows + 2 * QuietZone) * QuietZone;

                gfx.DrawRectangle(XBrushes.White, pos.X, pos.Y, Size.Width, Size.Height);
                gfx.DrawImage(MatrixImage, posWithZone.X, posWithZone.Y, sizeWithZone.Width, sizeWithZone.Height);
            }
            else
                gfx.DrawImage(MatrixImage, pos.X, pos.Y, Size.Width, Size.Height);

            gfx.Restore(state);
        }
Esempio n. 2
0
        private MemoryStream CreatePDFReport(string filename, string confidenceRate, string keyUsed, string secretInfo, bool isInfoSecretHere)
        {
            PdfDocument document = new PdfDocument();

            document.Info.Title = $"Report of the confidence rate of the document \"{filename} \" ";

            PdfPage page = document.AddPage();

            XGraphics gfx = XGraphics.FromPdfPage(page);

            XFont          font = new XFont("Calibri", 11, XFontStyle.Regular);
            XTextFormatter tf   = new XTextFormatter(gfx);

            XRect rect = new XRect(40, 100, page.Width - 100, 220);

            gfx.DrawRectangle(XBrushes.SeaShell, rect);
            tf.DrawString($"Confidence rate : {confidenceRate} Clé utilisée : {keyUsed} ", font, XBrushes.Black, rect, XStringFormats.TopLeft);
            if (isInfoSecretHere)
            {
                string secretInfoToWrite = $"The secret information was : {secretInfo}";
                rect = new XRect(20, 400, page.Width - 50, page.Height);
                gfx.DrawRectangle(XBrushes.SeaShell, rect);
                tf.Alignment = XParagraphAlignment.Justify;
                tf.DrawString(secretInfoToWrite, font, XBrushes.Black, rect, XStringFormats.TopLeft);
            }


            MemoryStream memoryStream = new MemoryStream();

            document.Save(memoryStream);

            return(memoryStream);
        }
        public override void CreatePDFLayout(XGraphics page, CheckBox checkBox, XRect bounds, double scaleFactor)
        {
            if (checkBox.BackgroundColor != default)
            {
                page.DrawRectangle(checkBox.BackgroundColor.ToXBrush(), bounds);
            }

            var adjustedBounds = new XRect(bounds.Location, new XSize(bounds.Height, bounds.Height));
            var checkPath      = new[]
            {
                new XPoint(adjustedBounds.Width * 0.15, adjustedBounds.Height * 0.3),
                new XPoint(adjustedBounds.Width * 0.3, adjustedBounds.Height * 0.7),
                new XPoint(adjustedBounds.Width * 0.85, adjustedBounds.Height * 0.8)
            };

            switch (Device.RuntimePlatform)
            {
            case Device.iOS:
            case Device.macOS:
                if (checkBox.IsChecked)
                {
                    page.DrawEllipse(checkBox.Color.ToXBrush(), adjustedBounds);
                    page.DrawLines(new XPen(XColors.White, scaleFactor * 3), checkPath);
                }
                else
                {
                    page.DrawEllipse(new XPen(checkBox.Color.ToXColor(), scaleFactor), adjustedBounds);
                }

                break;

            case Device.Android:
                if (checkBox.IsChecked)
                {
                    page.DrawRectangle(checkBox.Color.ToXBrush(), adjustedBounds);
                    page.DrawLines(new XPen(XColors.White, scaleFactor * 3), checkPath);
                }
                else
                {
                    page.DrawRectangle(new XPen(checkBox.Color.ToXColor(), scaleFactor), adjustedBounds);
                }

                break;

            case Device.UWP:
            case Device.WPF:
                if (checkBox.IsChecked)
                {
                    page.DrawRectangle(checkBox.Color.ToXBrush(), adjustedBounds);
                    page.DrawLines(new XPen(XColors.LightBlue, scaleFactor * 3), checkPath);
                }
                else
                {
                    page.DrawRectangle(new XPen(checkBox.Color.ToXColor(), scaleFactor), adjustedBounds);
                }

                break;
            }
        }
Esempio n. 4
0
        void AddAllocation(XGraphics gfx, PdfData pdfData)
        {
            //int startingHeight = 135;
            int ItemHeight = 20;

            var            fontTitle = new XFont("OpenSans", 10, XFontStyle.Bold);
            XTextFormatter tfTitle   = new XTextFormatter(gfx);
            XRect          rectTitle = new XRect(leftMargin - 10, startingHeight, 100, ItemHeight);

            gfx.DrawRectangle(XBrushes.White, rectTitle);
            tfTitle.DrawString("Allocation", fontTitle, XBrushes.Black, rectTitle, XStringFormats.TopLeft);
            startingHeight = startingHeight + ItemHeight;

            int xMargin = 0;
            //Draw table Header
            //for (int i = 0; i < 2; i++)
            //{
            //    XRect rectTitle1 = new XRect(xMargin + 60, startingHeight, 250, ItemHeight);
            //    gfx.DrawRectangle(XBrushes.SlateGray, rectTitle1);
            //    tfTitle.DrawString("  " + "Header" + i.ToString(), fontTitle, XBrushes.White, rectTitle1, XStringFormats.TopLeft);
            //    //startingHeight = startingHeight + ItemHeight;
            //    xMargin = 251;
            //}

            XRect rectTitle1 = new XRect(xMargin + leftMargin, startingHeight, 250, ItemHeight);

            gfx.DrawRectangle(XBrushes.LightSeaGreen, rectTitle1);
            tfTitle.DrawString("  " + "Allocation", fontTitle, XBrushes.White, rectTitle1, XStringFormats.TopLeft);
            xMargin = 251;

            XRect rectTitle2 = new XRect(xMargin + leftMargin, startingHeight, 250, ItemHeight);

            gfx.DrawRectangle(XBrushes.LightSeaGreen, rectTitle2);
            tfTitle.DrawString("  " + "Comment", fontTitle, XBrushes.White, rectTitle2, XStringFormats.TopLeft);

            startingHeight = startingHeight + ItemHeight + 1;
            for (int i = 0; i < pdfData.Allocation.Count; i++)
            {
                var            font = new XFont("OpenSans", 10, XFontStyle.Regular);
                XTextFormatter tf   = new XTextFormatter(gfx);

                XRect rect = new XRect(leftMargin, startingHeight, 250, ItemHeight);
                gfx.DrawRectangle(XBrushes.AliceBlue, rect);
                //var data = $"{i} {pdfData.Allocation[i].Allocation} | {pdfData.Allocation[i].Comment}";
                var data = $"{"  " + pdfData.Allocation[i].Allocation}";
                tf.DrawString(data, font, XBrushes.Black, rect, XStringFormats.TopLeft);


                XRect rect2 = new XRect(251 + leftMargin, startingHeight, 250, ItemHeight);
                gfx.DrawRectangle(XBrushes.AliceBlue, rect2);
                //var data = $"{i} {pdfData.Allocation[i].Allocation} | {pdfData.Allocation[i].Comment}";
                var data2 = $"{" " + pdfData.Allocation[i].Comment}";
                tf.DrawString(data2, font, XBrushes.Black, rect2, XStringFormats.TopLeft);

                startingHeight = startingHeight + ItemHeight + 1;
            }
        }
        public IActionResult TextAlignment()
        {
            const string text =
                "Facin exeraessisit la consenim iureet dignibh eu facilluptat vercil dunt autpat. " +
                "Ecte magna faccum dolor sequisc iliquat, quat, quipiss equipit accummy niate magna " +
                "facil iure eraesequis am velit, quat atis dolore dolent luptat nulla adio odipissectet " +
                "lan venis do essequatio conulla facillandrem zzriusci bla ad minim inis nim velit eugait " +
                "aut aut lor at ilit ut nulla ate te eugait alit augiamet ad magnim iurem il eu feuissi.\n" +
                "Guer sequis duis eu feugait luptat lum adiamet, si tate dolore mod eu facidunt adignisl in " +
                "henim dolorem nulla faccum vel inis dolutpatum iusto od min ex euis adio exer sed del " +
                "dolor ing enit veniamcon vullutat praestrud molenis ciduisim doloborem ipit nulla consequisi.\n" +
                "Nos adit pratetu eriurem delestie del ut lumsandreet nis exerilisit wis nos alit venit praestrud " +
                "dolor sum volore facidui blaor erillaortis ad ea augue corem dunt nis  iustinciduis euisi.\n" +
                "Ut ulputate volore min ut nulpute dolobor sequism olorperilit autatie modit wisl illuptat dolore " +
                "min ut in ute doloboreet ip ex et am dunt at.";

            PdfDocument document = new PdfDocument();

            PdfPage        page = document.AddPage();
            XGraphics      gfx  = XGraphics.FromPdfPage(page);
            XFont          font = new XFont("Times New Roman", 16, XFontStyle.Bold);
            XTextFormatter tf   = new XTextFormatter(gfx);

            XRect xRect = new XRect(40, 40, 250, 220);

            gfx.DrawRectangle(XBrushes.SeaShell, xRect);
            tf.DrawString("Naslov", font, XBrushes.Black, xRect, XStringFormats.TopLeft);

            font = new XFont("Times New Roman", 10, XFontStyle.Bold);

            XRect rect = new XRect(40, 100, 250, 220);

            gfx.DrawRectangle(XBrushes.SeaShell, rect);
            //tf.Alignment = ParagraphAlignment.Left;
            tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);

            rect = new XRect(310, 100, 250, 220);
            gfx.DrawRectangle(XBrushes.SeaShell, rect);
            tf.Alignment = XParagraphAlignment.Right;
            tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);

            rect = new XRect(40, 400, 250, 220);
            gfx.DrawRectangle(XBrushes.SeaShell, rect);
            tf.Alignment = XParagraphAlignment.Center;
            tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);

            rect = new XRect(310, 400, 250, 220);
            gfx.DrawRectangle(XBrushes.SeaShell, rect);
            tf.Alignment = XParagraphAlignment.Justify;
            tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);

            MemoryStream stream = new MemoryStream();

            document.Save(stream, false);
            stream.Position = 0;
            return(File(stream, "application/pdf", "alignment.pdf"));
        }
Esempio n. 6
0
        private static void drawHeaderTable(PdfPage newPage, XGraphics gfx, XPen pen, int startX, int startY, int columnWidth, int rowHeight)
        {
            int columnCount = AppForm.CURR_OCTT_DOC.getNumberOfDays();

            gfx.DrawRectangle(pen, startX, startY, columnWidth * columnCount, rowHeight);

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

            string dayName = "";
            int    modPos  = 0;

            for (int kk = 0; kk < columnCount; kk++)
            {
                while (true)
                {
                    if (AppForm.CURR_OCTT_DOC.getIsDayIncluded(modPos))
                    {
                        break;
                    }
                    modPos++;
                }


                dayName = AppForm.getDayText()[modPos];
                modPos++;

                XRect           rect    = new XRect(startX + kk * columnWidth + 4, startY + 4, columnWidth - 8, rowHeight - 8);
                XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

                //XFont font = new XFont("Arial", 10, XFontStyle.Bold, options);
                XFont         font   = getMyFont(Settings.TTREP_FONT_DAY_NAMES, options);
                XBrush        brush  = XBrushes.Black;
                XStringFormat format = new XStringFormat();



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

                //gfx.DrawRectangle(XPens.Black, XBrushes.LightBlue, rect);
                char[] separator = new char[1];
                separator[0] = ',';
                string[] ss = Settings.TTREP_COLOR_HEADER.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);


                format.LineAlignment = XLineAlignment.Center;
                format.Alignment     = XStringAlignment.Center;
                gfx.DrawString(dayName, font, brush, rect, format);
            }
        }
Esempio n. 7
0
        public void FillRectangle(Brush b, RectangleF rectangle)
        {
            var brush = GetXBrush(b);

            if (brush != null)
            {
                g.DrawRectangle(brush, rectangle);
            }
        }
        public IActionResult Watermark()
        {
            const string text =
                "Facin exeraessisit la consenim iureet dignibh eu facilluptat vercil dunt autpat. " +
                "Ecte magna faccum dolor sequisc iliquat, quat, quipiss equipit accummy niate magna " +
                "facil iure eraesequis am velit, quat atis dolore dolent luptat nulla adio odipissectet " +
                "lan venis do essequatio conulla facillandrem zzriusci bla ad minim inis nim velit eugait " +
                "aut aut lor at ilit ut nulla ate te eugait alit augiamet ad magnim iurem il eu feuissi.\n" +
                "Guer sequis duis eu feugait luptat lum adiamet, si tate dolore mod eu facidunt adignisl in " +
                "henim dolorem nulla faccum vel inis dolutpatum iusto od min ex euis adio exer sed del " +
                "dolor ing enit veniamcon vullutat praestrud molenis ciduisim doloborem ipit nulla consequisi.\n" +
                "Nos adit pratetu eriurem delestie del ut lumsandreet nis exerilisit wis nos alit venit praestrud " +
                "dolor sum volore facidui blaor erillaortis ad ea augue corem dunt nis  iustinciduis euisi.\n" +
                "Ut ulputate volore min ut nulpute dolobor sequism olorperilit autatie modit wisl illuptat dolore " +
                "min ut in ute doloboreet ip ex et am dunt at.";

            PdfDocument document = new PdfDocument();

            PdfPage        page = document.AddPage();
            XGraphics      gfx  = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Prepend);
            XFont          font = new XFont("Times New Roman", 16, XFontStyle.Bold);
            XTextFormatter tf   = new XTextFormatter(gfx);

            XRect xRect = new XRect(40, 40, 250, 220);

            gfx.DrawRectangle(XBrushes.SeaShell, xRect);
            tf.DrawString("Naslov", font, XBrushes.Black, xRect, XStringFormats.TopLeft);

            font = new XFont("Times New Roman", 10, XFontStyle.Bold);

            XRect rect = new XRect(40, 100, 250, 220);

            gfx.DrawRectangle(XBrushes.SeaShell, rect);
            //tf.Alignment = ParagraphAlignment.Left;
            tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);

            var size = gfx.MeasureString("PDFSharp", font);

            gfx.TranslateTransform(page.Width / 2, page.Height / 2);
            gfx.RotateTransform(-Math.Atan(page.Height / page.Width) * 180 / Math.PI);
            gfx.TranslateTransform(-page.Width / 2, -page.Height / 2);

            var format = new XStringFormat();

            format.Alignment     = XStringAlignment.Near;
            format.LineAlignment = XLineAlignment.Near;

            XBrush brush = new XSolidBrush(XColor.FromArgb(128, 255, 0, 0));

            gfx.DrawString("Wathermark", font, brush, new XPoint((page.Width - size.Width) / 2, (page.Height - size.Height) / 2), format);
            MemoryStream stream = new MemoryStream();

            document.Save(stream, false);
            stream.Position = 0;
            return(File(stream, "application/pdf", "watermark.pdf"));
        }
Esempio n. 9
0
        /// <inheritdoc cref="ICanvas"/>
        public ICanvas DrawRectangle(PointPair rect)
        {
            ValidationUtil.RequireNonNull(rect);

            var r = rect.ToRectangle(currentDrawingSpace);

            currentGfx.DrawRectangle(GetBrush(), r.X, r.Y, r.Width, r.Height);

            return(this);
        }
Esempio n. 10
0
        private static void drawTermsTable(PdfPage newPage, XGraphics gfx, XPen pen, int startX, int startY, int columnWidth, int rowHeight)
        {
            int rowCount = AppForm.CURR_OCTT_DOC.IncludedTerms.Count;

            gfx.DrawRectangle(pen, startX, startY, columnWidth, rowHeight * rowCount);

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

            for (int j = 0; j < rowCount; j++)
            {
                int[]     term      = (int [])AppForm.CURR_OCTT_DOC.IncludedTerms[j];
                string [] printTerm = new string[4];
                for (int t = 0; t < 4; t++)
                {
                    if (term[t] < 10)
                    {
                        printTerm[t] = "0" + System.Convert.ToString(term[t]);
                    }
                    else
                    {
                        printTerm[t] = System.Convert.ToString(term[t]);
                    }
                }

                string termText = printTerm[0] + ":" + printTerm[1] + "-" + printTerm[2] + ":" + printTerm[3];


                XRect rect = new XRect(startX + 4, startY + j * rowHeight + 4, columnWidth - 8, rowHeight - 8);

                XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
                //XFont font = new XFont("Arial", 8, XFontStyle.Bold, options);
                XFont font = getMyFont(Settings.TTREP_FONT_TIME_PERIODS, options);

                XBrush        brush  = XBrushes.Black;
                XStringFormat format = new XStringFormat();

                //gfx.DrawRectangle(XPens.Black, XBrushes.Bisque, rect);
                char[] separator = new char[1];
                separator[0] = ',';
                string[] ss = Settings.TTREP_COLOR_TP.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.LightBlue, rect);

                format.LineAlignment = XLineAlignment.Center;
                format.Alignment     = XStringAlignment.Center;
                gfx.DrawString(termText, font, brush, rect, format);
            }
        }
Esempio n. 11
0
        public static void Test(string filename)
        {
            PdfDocument document = PdfReader.Open(filename);

            document.Options.ColorMode = PdfColorMode.Cmyk;

            // Set version to PDF 1.4 (Acrobat 5) because we use transparency.
            if (document.Version < 14)
            {
                document.Version = 14;
            }

            PdfPage page = document.Pages[0];

            // Get an XGraphics object for drawing beneath the existing content

            XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Append);

            gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(1, 0.68, 0, 0.12)), new XRect(30, 60, 50, 50));
            gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0, 0.70, 1, 0)), new XRect(550, 60, 50, 50));

            gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0, 0, 0, 0)), new XRect(90, 100, 50, 50));
            gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0, 0, 0, 0)), new XRect(150, 100, 50, 50));

            gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0.7, 0, 0.70, 1, 0)), new XRect(90, 100, 50, 50));
            gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0.5, 0, 0.70, 1, 0)), new XRect(150, 100, 50, 50));

            gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0.35, 0.15, 0, 0.08)), new XRect(50, 360, 50, 50));
            gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0.25, 0.10, 0, 0.05)), new XRect(150, 360, 50, 50));
            gfx.DrawRectangle(new XSolidBrush(XColor.FromCmyk(0.15, 0.05, 0, 0)), new XRect(250, 360, 50, 50));
        }
Esempio n. 12
0
        private void DrawRectangle(XGraphics gfx, int number)
        {
            base.BeginBox(gfx, number, "DrawRectangle");
            XPen pen = new XPen(XColors.Navy, 3.1415926535897931);

            gfx.DrawRectangle(pen, 10, 0, 100, 60);
            gfx.DrawRectangle(XBrushes.DarkOrange, 130, 0, 100, 60);
            gfx.DrawRectangle(pen, XBrushes.DarkOrange, 10, 80, 100, 60);
            gfx.DrawRectangle(pen, XBrushes.DarkOrange, 150, 80, 60, 60);
            base.EndBox(gfx);
        }
Esempio n. 13
0
        void RenderRectangles(XGraphics gfx)
        {
            gfx.TranslateTransform(15, 20);

            XPen pen = new XPen(XColors.Navy, Math.PI);

            gfx.DrawRectangle(pen, 10, 0, 100, 60);
            gfx.DrawRectangle(XBrushes.DarkOrange, 130, 0, 100, 60);
            gfx.DrawRectangle(pen, XBrushes.DarkOrange, 10, 80, 100, 60);
            gfx.DrawRectangle(pen, XBrushes.DarkOrange, 150, 80, 60, 60);
        }
        public override void CreatePDFLayout(XGraphics page, BoxView box, XRect bounds, double scaleFactor)
        {
            if (box.BackgroundColor != default)
            {
                page.DrawRectangle(box.BackgroundColor.ToXBrush(), bounds);
            }

            if (box.Color != default)
            {
                page.DrawRectangle(box.Color.ToXBrush(), bounds);
            }
        }
Esempio n. 15
0
        public void Draw(XPoint basePoint, XRect baseRect, XImage image)
        {
            XFont headerFont = new XFont("Arial", 16);
            XFont subfont    = new XFont("Arial", 10);
            char  degree     = Convert.ToChar('\u00b0');

            gfx.DrawString(parameterLeft.Name.Substring(5, parameterLeft.Name.Length - 5), headerFont, XBrushes.Black, basePoint, XStringFormats.Center);
            gfx.DrawString(parameterLeft.Value.ToString() + degree, subfont, XBrushes.Black, basePoint + new XPoint(-25, baseRect.Height * 0.05), XStringFormats.Center);
            gfx.DrawString(parameterRight.Value.ToString() + degree, subfont, XBrushes.Black, basePoint + new XPoint(25, baseRect.Height * 0.05), XStringFormats.Center);

            XBrush brush = XBrushes.Black;

            if (parameterLeft.LSI >= 75)
            {
                brush = XBrushes.Green;
            }
            else
            {
                brush = XBrushes.Gold;
            }

            gfx.DrawRoundedRectangle(brush,
                                     new XRect(basePoint + new XPoint(-baseRect.Width * 0.05, baseRect.Height * 0.075),
                                               new XSize(baseRect.Width * 0.1, baseRect.Height * 0.075)),
                                     new XSize(10, 10));
            gfx.DrawString(parameterLeft.LSI.ToString("0") + "%",
                           subfont,
                           XBrushes.Black,
                           basePoint + new XPoint(baseRect.Width * -0.025, baseRect.Height * 0.125));

            XSolidBrush blue   = new XSolidBrush(XColor.FromArgb(127, 0, 0, 255));
            XSolidBrush yellow = new XSolidBrush(XColor.FromArgb(127, 255, 255, 0));

            XPoint top    = new XPoint(basePoint.X - 20, basePoint.Y + baseRect.Height * 0.2);
            XPoint bottom = new XPoint(basePoint.X - 20, basePoint.Y + baseRect.Height * 0.8);

            XPoint leftRectPoint = Interpolate(bottom, top, -parameterLeft.Percentage);
            XRect  leftBar       = new XRect(leftRectPoint, new XSize(20, bottom.Y - leftRectPoint.Y));

            gfx.DrawRectangle(blue, leftBar);

            XPoint rigthRectPoint = Interpolate(bottom, top, -parameterRight.Percentage);
            XRect  rightBar       = new XRect(rigthRectPoint + new XPoint(30, 0), new XSize(20, bottom.Y - rigthRectPoint.Y));

            gfx.DrawRectangle(yellow, rightBar);

            gfx.DrawString("L", subfont, XBrushes.Black, bottom + new XPoint(5, -2));
            gfx.DrawString("R", subfont, XBrushes.Black, bottom + new XPoint(35, -2));

            gfx.DrawImage(image, new XRect(bottom.X, bottom.Y, 50, 50));
            image.Dispose();
        }
Esempio n. 16
0
        static void Main()
        {
            const string filename = "TextLayout_tempfile.pdf";

            const string text =
                "Facin exeraessisit la consenim iureet dignibh eu facilluptat vercil dunt autpat. " +
                "Ecte magna faccum dolor sequisc iliquat, quat, quipiss equipit accummy niate magna " +
                "facil iure eraesequis am velit, quat atis dolore dolent luptat nulla adio odipissectet " +
                "lan venis do essequatio conulla facillandrem zzriusci bla ad minim inis nim velit eugait " +
                "aut aut lor at ilit ut nulla ate te eugait alit augiamet ad magnim iurem il eu feuissi.\n" +
                "Guer sequis duis eu feugait luptat lum adiamet, si tate dolore mod eu facidunt adignisl in " +
                "henim dolorem nulla faccum vel inis dolutpatum iusto od min ex euis adio exer sed del " +
                "dolor ing enit veniamcon vullutat praestrud molenis ciduisim doloborem ipit nulla consequisi.\n" +
                "Nos adit pratetu eriurem delestie del ut lumsandreet nis exerilisit wis nos alit venit praestrud " +
                "dolor sum volore facidui blaor erillaortis ad ea augue corem dunt nis  iustinciduis euisi.\n" +
                "Ut ulputate volore min ut nulpute dolobor sequism olorperilit autatie modit wisl illuptat dolore " +
                "min ut in ute doloboreet ip ex et am dunt at.";

            PdfDocument document = new PdfDocument();

            PdfPage        page = document.AddPage();
            XGraphics      gfx  = XGraphics.FromPdfPage(page);
            XFont          font = new XFont("Times New Roman", 10, XFontStyle.Bold);
            XTextFormatter tf   = new XTextFormatter(gfx);

            XRect rect = new XRect(40, 100, 200, 232);

            gfx.DrawRectangle(XBrushes.SeaShell, rect);
            //tf.Alignment = ParagraphAlignment.Left;
            tf.Alignment = XParagraphAlignment.Left;
            tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);

            rect = new XRect(310, 100, 250, 232);
            gfx.DrawRectangle(XBrushes.SeaShell, rect);
            tf.Alignment = XParagraphAlignment.Right;
            tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);

            rect = new XRect(40, 400, 250, 232);
            gfx.DrawRectangle(XBrushes.SeaShell, rect);
            tf.Alignment = XParagraphAlignment.Center;
            tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);

            rect = new XRect(310, 400, 250, 232);
            gfx.DrawRectangle(XBrushes.SeaShell, rect);
            tf.Alignment = XParagraphAlignment.Justify;
            tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);

            // Save the document...
            document.Save(filename);
            // ...and start a viewer.
            Process.Start(filename);
        }
Esempio n. 17
0
        static void DrawRectangle(XGraphics gfx, int number)
        {
            BeginBox(gfx, number, "DrawRectangle");

            XPen pen = new XPen(XColors.Navy, System.Math.PI);

            gfx.DrawRectangle(pen, 10, 0, 100, 60);
            gfx.DrawRectangle(XBrushes.DarkOrange, 130, 0, 100, 60);
            gfx.DrawRectangle(pen, XBrushes.DarkOrange, 10, 80, 100, 60);
            gfx.DrawRectangle(pen, XBrushes.DarkOrange, 150, 80, 60, 60);

            EndBox(gfx);
        }
Esempio n. 18
0
        private void DrawRectangle(float sizemm, float mmfromleft, float mmfromtop)
        {
            XUnit _size = XUnit.FromMillimeter(sizemm);
            //  XGraphics gfx = XGraphics.FromPdfPage(_page);
            XPen  pen = new XPen(XColors.Black, 1);
            XUnit _x  = XUnit.FromMillimeter(mmfromleft);
            XUnit _y  = XUnit.FromMillimeter(mmfromtop);

            _x.Point = _x.Point - (_size.Point / 2d);
            _y.Point = _y.Point - (_size.Point / 2d);

            gfx.DrawRectangle(pen, XBrushes.White, _x, _y, _size.Point, _size.Point);
        }
Esempio n. 19
0
        /// <summary>
        /// Demonstrates the use of XGraphics.DrawRectangle.
        /// </summary>
        public override void RenderPage(XGraphics gfx)
        {
            base.RenderPage(gfx);

            // Stroke rectangle
            gfx.DrawRectangle(properties.Pen1.Pen, 50, 100, 450, 150);

            // Fill rectangle
            gfx.DrawRectangle(properties.Brush2.Brush, new Rectangle(50, 300, 450, 150));

            // Stroke and fill rectangle
            gfx.DrawRectangle(properties.Pen1.Pen, properties.Brush2.Brush, new RectangleF(50, 500, 450, 150));
        }
        /// <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)));
        }
Esempio n. 21
0
        public void Draw(XGraphics gfx)
        {
            TransformsProvider tp = new TransformsProvider(gfx);
            XRect rect            = tp.FromCmsToPts(new XRect(_Left, _Top, _Width, _Height));

            if (this._fillColorName == Color.Transparent.Name)
            {
                gfx.DrawRectangle(new XPen(XColor.FromName(_lineColorName), _lineWidth), rect);
            }
            else
            {
                gfx.DrawRectangle(new XPen(XColor.FromName(_lineColorName), _lineWidth), new XSolidBrush(XColor.FromName(_fillColorName)), rect);
            }
        }
Esempio n. 22
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);
        }
Esempio n. 23
0
        private double PrintServicesListSummary(XGraphics printer, double totalCost, double summaryStartY, bool includeVat)
        {
            double summaryRowHeight = 0;
            double subTotal         = totalCost * 0.8f;
            double vatValue         = totalCost * 0.2f;

            XPen strokePen = new XPen(XColor.FromArgb(100, 100, 100));

            XFont  font           = new XFont("Times", 12, XFontStyle.Bold);
            string sDecimalFormat = "###,###.00";

            XSize size = XSize.Empty;

            if (includeVat)
            {
                // /* Print Subtotal */
                printer.DrawRectangle(strokePen, new XRect(COL2_START_X, summaryStartY, COL2_WIDTH, summaryRowHeight));

                size = printer.MeasureString("Sub Total : ", font);
                printer.DrawString("Sub Total : ", font, brush, new XPoint(COL2_START_X - size.Width, summaryStartY + summaryRowHeight * 1 / 4), XStringFormats.CenterLeft);
                printer.DrawString("$ " + subTotal.ToString(sDecimalFormat), font, brush, new XPoint(COL2_START_X + 10, summaryStartY + summaryRowHeight * 1 / 4), XStringFormats.CenterLeft);

                summaryStartY += summaryRowHeight;
                // /* End Print Subtotal */

                // /* Print VAT */
                //contents.addRect(firstRectEndX, summaryStartY, secondRectEndX, summaryRowHeight);
                //contents.stroke();

                //summaryPrinter.putTextToTheRight(summaryLabelRightX, summaryStartY + summaryRowHeight * 1 / 4, "Vat : ");
                //summaryPrinter.putTextToTheRight(docEndX - 10, summaryStartY + summaryRowHeight * 1 / 4, "$ " + vatValue.ToString(sDecimalFormat));

                summaryStartY += summaryRowHeight;
                // /* End Print VAT */
            }

            /* Print Total */
            size             = printer.MeasureString("Sub Total : ", font);
            summaryRowHeight = size.Height * 3;

            printer.DrawRectangle(strokePen, new XRect(COL2_START_X, summaryStartY - summaryRowHeight * 1 / 4, COL2_WIDTH, summaryRowHeight));

            printer.DrawString("Total : ", font, brush, new XPoint(COL2_START_X - size.Width, summaryStartY + summaryRowHeight * 1 / 4), XStringFormats.CenterLeft);
            printer.DrawString("$ " + totalCost.ToString(sDecimalFormat), font, brush, new XPoint(COL2_START_X + 10, summaryStartY + summaryRowHeight * 1 / 4), XStringFormats.CenterLeft);

            summaryStartY += summaryRowHeight;
            /* End Print Total */

            return(summaryStartY);
        }
Esempio n. 24
0
        void DrawCodePage(XGraphics gfx, XPoint origin)
        {
            const double dx        = 25;
            const double dy        = 25;
            XFont        labelFont = new XFont("Verdana", 10, XFontStyle.Bold);
            //XFont font = new XFont("Bauhaus", 16);
            XFont font = this.properties.Font1.Font;
            //XFont labelFont = font;
            //font = new XFont("Symbol", 16);
            Encoding encoding = Encoding.GetEncoding(1252);
            double   asdf     = XColors.LightGray.GS;
            //XBrush lighter = new XSolidBrush(XColor.FromGrayScale(XColor.LightGray.GS * 1.1));
            XBrush lighter = new XSolidBrush(XColor.FromGrayScale(0.9));

            XFontStyle style       = font.Style;
            double     lineSpace   = font.GetHeight(gfx);
            int        cellSpace   = font.FontFamily.GetLineSpacing(style);
            int        cellAscent  = font.FontFamily.GetCellAscent(style);
            int        cellDescent = font.FontFamily.GetCellDescent(style);
            int        cellLeading = cellSpace - cellAscent - cellDescent;

            double ascent  = lineSpace * cellAscent / cellSpace;
            double descent = lineSpace * cellDescent / cellSpace;
            double leading = lineSpace * cellLeading / cellSpace;

            double x = origin.X + dx;
            double y = origin.Y;

            //for (int idx = 0; idx < 16; idx++)
            //  gfx.DrawString("x" + idx.ToString("X"), labelFont, XBrushes.DarkGray, x + idx * dx, y);
            for (int row = 0; row < 16; row++)
            {
                x  = origin.X;
                y += dy;
                //gfx.DrawString(row.ToString("X") + "x", labelFont, XBrushes.DarkGray, x, y);
                for (int clm = 0; clm < 16; clm++)
                {
                    x += dx;
                    string glyph = encoding.GetString(new byte[1] {
                        Convert.ToByte(row * 16 + clm)
                    });
                    glyph += "!";
                    XSize size = gfx.MeasureString(glyph, font);
                    gfx.DrawRectangle(XBrushes.LightGray, x, y - size.Height + descent, size.Width, size.Height);
                    gfx.DrawRectangle(lighter, x, y - size.Height + descent, size.Width, leading);
                    gfx.DrawRectangle(lighter, x, y, size.Width, descent);
                    gfx.DrawString(glyph, font, XBrushes.Black, x, y);
                }
            }
        }
        public override void CreatePDFLayout(XGraphics page, ProgressBar progressBar, XRect bounds, double scaleFactor)
        {
            Color bgColor  = progressBar.BackgroundColor != default ? progressBar.BackgroundColor : Color.LightGray;
            Color barColor = Color.FromHex("#189DC4");


            page.DrawRectangle(bgColor.ToXBrush(), bounds);

            var progress = new XRect(bounds.X + scaleFactor, bounds.Y + scaleFactor,
                                     bounds.Width * progressBar.Progress, bounds.Height - 2 * scaleFactor);

            page.DrawRectangle(bgColor.ToXBrush(), bounds);
            page.DrawRectangle(barColor.ToXBrush(), progress);
        }
Esempio n. 26
0
        /// <summary>
        /// Adds blue stripes at the top and the bottom of PDF file.
        /// </summary>
        /// <param name="document">>A <see cref="PdfSharp`1"/> document.</param>
        private static void DrawRectangles(PdfDocument document)
        {
            int recHeight = 35;
            int margin    = 10;

            for (int i = 0; i < document.PageCount; i++)
            {
                PdfPage page = document.Pages[i];
                using (XGraphics gfx = XGraphics.FromPdfPage(page))
                {
                    gfx.DrawRectangle(XBrushes.DodgerBlue, 0, margin, page.Width, recHeight);
                    gfx.DrawRectangle(XBrushes.DodgerBlue, 0, page.Height - margin - recHeight, page.Width, recHeight);
                }
            }
        }
Esempio n. 27
0
 private static void DrawRectangleInternal(XGraphics gfx, XSolidBrush brush, XPen pen, bool isStroked, bool isFilled, ref XRect rect)
 {
     if (isStroked && isFilled)
     {
         gfx.DrawRectangle(pen, brush, rect);
     }
     else if (isStroked && !isFilled)
     {
         gfx.DrawRectangle(pen, rect);
     }
     else if (!isStroked && isFilled)
     {
         gfx.DrawRectangle(brush, rect);
     }
 }
Esempio n. 28
0
 public void DrawRectangle(IPen pen, IBrush brush, int x, int y, int width, int height)
 {
     if (pen != null && brush != null)
     {
         Graphics.DrawRectangle((XPen)pen.Raw, (XBrush)brush.Raw, x, y, width, height);
     }
     else if (pen == null && brush != null)
     {
         Graphics.DrawRectangle((XBrush)brush.Raw, x, y, width, height);
     }
     else if (pen != null && brush == null)
     {
         Graphics.DrawRectangle((XPen)pen.Raw, x, y, width, height);
     }
 }
Esempio n. 29
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);
        }
Esempio n. 30
0
        private void SamplePage2(PdfDocument document)
        {
            PdfPage   page = document.AddPage();
            XGraphics gfx  = XGraphics.FromPdfPage(page);

            gfx.MUH = PdfFontEncoding.Unicode;

            Document doc = new Document();

            MigraDoc.Rendering.DocumentRenderer docRender = new MigraDoc.Rendering.DocumentRenderer(doc);

            docRender.PrepareDocument();

            XRect A4Rect = new XRect(0, 0, XUnit.FromCentimeter(21).Point, XUnit.FromCentimeter(29.7).Point);

            int pageCount = docRender.FormattedDocument.PageCount;

            for (int idx = 0; idx < pageCount; idx++)
            {
                XRect rect = GetRect(idx);
                XGraphicsContainer container = gfx.BeginContainer(rect, A4Rect, XGraphicsUnit.Point);

                gfx.DrawRectangle(XPens.LightGray, A4Rect);

                docRender.RenderPage(gfx, idx + 1);

                gfx.EndContainer(container);
            }
        }
Esempio n. 31
0
        /// <summary>
        /// Creates the normal appearance form X object for the annotation that represents
        /// this acro form text field.
        /// </summary>
        void RenderAppearance()
        {
            PdfRectangle rect = Elements.GetRectangle(PdfAnnotation.Keys.Rect);
            XForm        form = new XForm(this.document, rect.Size);
            XGraphics    gfx  = XGraphics.FromForm(form);

            if (backColor != XColor.Empty)
            {
                gfx.DrawRectangle(new XSolidBrush(BackColor), rect.ToXRect() - rect.Location);
            }

            string text = Text;

            if (text.Length > 0)
            {
                gfx.DrawString(Text, Font, new XSolidBrush(ForeColor),
                               rect.ToXRect() - rect.Location + new XPoint(2, 0), XStringFormats.TopLeft);
            }

            form.DrawingFinished();

            // Get existing or create new appearance dictionary
            PdfDictionary ap = Elements[PdfAnnotation.Keys.AP] as PdfDictionary;

            if (ap == null)
            {
                ap = new PdfDictionary(this.document);
                Elements[PdfAnnotation.Keys.AP] = ap;
            }

            // Set XRef to normal state
            ap.Elements["/N"] = form.PdfForm.Reference;
        }
Esempio n. 32
0
        /// <summary>
        /// Renders the OMR code.
        /// </summary>
        protected internal override void Render(XGraphics gfx, XBrush brush, XFont font, XPoint position)
        {
            XGraphicsState state = gfx.Save();

            switch (Direction)
            {
                case CodeDirection.RightToLeft:
                    gfx.RotateAtTransform(180, position);
                    break;

                case CodeDirection.TopToBottom:
                    gfx.RotateAtTransform(90, position);
                    break;

                case CodeDirection.BottomToTop:
                    gfx.RotateAtTransform(-90, position);
                    break;
            }

            //XPoint pt = center - size / 2;
            XPoint pt = position - CodeBase.CalcDistance(AnchorType.TopLeft, Anchor, Size);
            uint value;
            uint.TryParse(Text, out value);
#if true
            // HACK: Project Wallenwein: set LK
            value |= 1;
            _synchronizeCode = true;
#endif
            if (_synchronizeCode)
            {
                XRect rect = new XRect(pt.X, pt.Y, _makerThickness, Size.Height);
                gfx.DrawRectangle(brush, rect);
                pt.X += 2 * _makerDistance;
            }
            for (int idx = 0; idx < 32; idx++)
            {
                if ((value & 1) == 1)
                {
                    XRect rect = new XRect(pt.X + idx * _makerDistance, pt.Y, _makerThickness, Size.Height);
                    gfx.DrawRectangle(brush, rect);
                }
                value = value >> 1;
            }
            gfx.Restore(state);
        }