Beispiel #1
0
        public float POSDrawBarcode(string dataBarcode, System.Drawing.Printing.PrintPageEventArgs e, float y, Color color, TextAlign textAlign)
        {
            if (dataBarcode.Length != 12)
            {
                y = POSDrawString("", e, new Font("Arial", 11), color, y, textAlign, 0);
                return(y);
            }
            Ean13 ean13 = new Ean13(dataBarcode);
            float x     = 0;

            switch (textAlign)
            {
            case TextAlign.Left:
                x = 0;
                break;

            case TextAlign.Center:
                x = POSGetWidthPrinter(e) - ean13.Width;
                if (x < 0)
                {
                    x = 0;
                }
                x = x / 2;
                break;

            case TextAlign.Right:
                x = POSGetWidthPrinter(e) - ean13.Width;
                if (x < 0)
                {
                    x = 0;
                }
                break;

            default:
                break;
            }
            ean13.DrawEan13Barcode(e.Graphics, new Point((int)x, (int)y));
            y += ean13.Height + 2;
            return(y);
        }
 public float POSDrawBarcode(string dataBarcode, System.Drawing.Printing.PrintPageEventArgs e, float y, Color color, TextAlign textAlign)
 {
     if (dataBarcode.Length != 12)
     {
         y = POSDrawString("", e, new Font("Arial", 11), color, y, textAlign, 0);
         return y;
     }
     Ean13 ean13 = new Ean13(dataBarcode);
     float x = 0;
     switch (textAlign)
     {
         case TextAlign.Left:
             x = 0;
             break;
         case TextAlign.Center:
             x = POSGetWidthPrinter(e) - ean13.Width;
             if (x < 0)
             {
                 x = 0;
             }
             x = x / 2;
             break;
         case TextAlign.Right:
             x = POSGetWidthPrinter(e) - ean13.Width;
             if (x < 0)
             {
                 x = 0;
             }
             break;
         default:
             break;
     }
     ean13.DrawEan13Barcode(e.Graphics, new Point((int)x, (int)y));
     y += ean13.Height + 2;
     return y;
 }