Пример #1
0
        public override void DrawBarcode(IGraphicsRenderer g, RectangleF displayRect)
        {
            base.DrawBarcode(g, displayRect);
            float bearerWidth = WideBarRatio * 2 * zoom;

            using (Pen pen = new Pen(Color, bearerWidth))
            {
                float x0  = displayRect.Left;
                float x01 = displayRect.Left + bearerWidth / 2;
                float y0  = displayRect.Top;
                float y01 = displayRect.Top + bearerWidth / 2;
                float x1  = displayRect.Left + displayRect.Width;
                float x11 = displayRect.Left + displayRect.Width - bearerWidth / 2;
                float y1  = displayRect.Top + barArea.Bottom * zoom;
                float y11 = displayRect.Top + barArea.Bottom * zoom - bearerWidth / 2;

                g.DrawLine(pen, x0, y01 - 0.5F, x1, y01 - 0.5F);
                g.DrawLine(pen, x0, y11, x1, y11);
                if (this.drawVerticalBearerBars)
                {
                    g.DrawLine(pen, x01 - 0.5F, y0, x01 - 0.5F, y1);
                    g.DrawLine(pen, x11, y0, x11, y1);
                }
            }
        }
Пример #2
0
        private void DrawBarcode(IGraphicsRenderer g, float width, float height)
        {
            SizeF originalSize = CalcBounds();
            float kx           = width / originalSize.Width;
            float ky           = height / originalSize.Height;

            Draw2DBarcode(g, kx, ky);

            //If swiss qr, draw the swiss cross
            if (text.StartsWith("SPC"))
            {
                float top = showText ? height - 21 : height;
                g.FillRectangle(Brushes.White, width / 2 - width / 100f * 7, top / 2 - top / 100 * 7, width / 100f * 14, top / 100 * 14);
                g.FillRectangle(Brushes.Black, width / 2 - width / 100f * 6, top / 2 - top / 100 * 6, width / 100f * 12, top / 100 * 12);
                g.FillRectangle(Brushes.White, width / 2 - width / 100f * 4, top / 2 - top / 100 * 1.5f, width / 100f * 8, top / 100 * 3);
                g.FillRectangle(Brushes.White, width / 2 - width / 100f * 1.5f, top / 2 - top / 100 * 4, width / 100f * 3, top / 100 * 8);
            }
            if (text.StartsWith("ST"))
            {
                Pen skyBluePen = new Pen(Brushes.Black);
                skyBluePen.Width = (kx * 4 * zoom) / 2;

                g.DrawLine(skyBluePen, width - 2, height / 2, width - 2, height - 2);
                g.DrawLine(skyBluePen, width / 2, height - 2, width - 2, height - 2);
            }
            // draw the text.
            if (showText)
            {
                string data = StripControlCodes(text);
                if (data.Length > 0)
                {
                    // When we print, .Net automatically scales the font. However, we need to handle this process.
                    // Downscale the font to the screen resolution, then scale by required value (ky).
                    float fontZoom = 18f / (int)g.MeasureString(data, FFont).Height *ky;
                    using (Font drawFont = new Font(FFont.Name, FFont.Size * fontZoom, FFont.Style))
                    {
                        g.DrawString(data, drawFont, Brushes.Black, new RectangleF(0, height - 18 * ky, width, 18 * ky));
                    }
                }
            }
        }
Пример #3
0
        private void DoLines(string data, IGraphicsRenderer g, float zoom)
        {
            using (Pen pen = new Pen(Color))
            {
                float currentWidth = 0;
                foreach (char c in data)
                {
                    float       width;
                    BarLineType lt;
                    OneBarProps(c, out width, out lt);

                    float heightStart = 0;
                    float heightEnd   = barArea.Height;

                    if (lt == BarLineType.BlackHalf)
                    {
                        heightEnd = barArea.Height * 2 / 5;
                    }
                    else if (lt == BarLineType.BlackLong && showText)
                    {
                        heightEnd += 7;
                    }
                    else if (lt == BarLineType.BlackTracker)
                    {
                        heightStart = barArea.Height * 1 / 3;
                        heightEnd   = barArea.Height * 2 / 3;
                    }
                    else if (lt == BarLineType.BlackAscender)
                    {
                        heightEnd = barArea.Height * 2 / 3;
                    }
                    else if (lt == BarLineType.BlackDescender)
                    {
                        heightStart = barArea.Height * 1 / 3;
                    }

                    width       *= zoom;
                    heightStart *= zoom;
                    heightEnd   *= zoom;
                    pen.Width    = width;

                    if (lt == BarLineType.BlackHalf)
                    {
                        g.DrawLine(pen,
                                   currentWidth + width / 2,
                                   barArea.Bottom * zoom,
                                   currentWidth + width / 2,
                                   barArea.Bottom * zoom - heightEnd);
                    }
                    else if (lt != BarLineType.White)
                    {
                        g.DrawLine(pen,
                                   currentWidth + width / 2,
                                   barArea.Top * zoom + heightStart,
                                   currentWidth + width / 2,
                                   barArea.Top * zoom + heightEnd);
                    }

                    currentWidth += width;
                }
            }
        }