Пример #1
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);
            }
            // draw the text.
            if (showText)
            {
                string data = StripControlCodes(text);
                // 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));
                }
            }
        }
Пример #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);

            // draw the text.
            if (showText)
            {
                string data = StripControlCodes(text);
                // 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
        internal void DrawString(IGraphicsRenderer g, float x1, float x2, string s, bool small)
        {
            if (String.IsNullOrEmpty(s))
            {
                return;
            }

            // 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 (Zoom).
            float fontZoom = 14f / (int)g.MeasureString(s, FFont).Height *zoom;
            Font  font     = small ? FSmallFont : FFont;

            using (Font drawFont = new Font(font.Name, font.Size * fontZoom, font.Style))
            {
                SizeF size = g.MeasureString(s, drawFont);
                size.Width  /= zoom;
                size.Height /= zoom;

                g.DrawString(s, drawFont, new SolidBrush(Color),
                             (x1 + (x2 - x1 - size.Width) / 2) * zoom,
                             (textUp ? 0 : drawArea.Height - size.Height) * zoom);
            }
        }