Exemple #1
0
        public void testTemplate()
        {
            QRPageCreator.LoadAppSettings();

            //Create QR Page creater
            QRPageCreator qrPageGen = new QRPageCreator(buildMockUpQRLabelData(), buildMockUpTemplate());

            qrPageGen.parseData();

            List <QRPage> pages = qrPageGen.generateLabelPages();

            outputPages(pages);

            QRPrintController qrPC = new QRPrintController();

            if (qrPC.findPrinter(QRPrintController.UncontrolledPrinter_Key))
            {
                if (qrPC.print(pages, QRPrintController.UncontrolledPrinter_Key))
                {
                    Console.Out.WriteLine("Printing succeed.");
                }
                else
                {
                    Console.Out.WriteLine("Printing failed.");
                }
            }
        }
Exemple #2
0
        public void run()
        {
            int total                    = 5;
            int txtPerQRLabel            = 3;
            int labelPerPage             = 4;
            int qrLocIndex               = 0;
            int inner_label_left         = 170;
            int inner_label_height       = 20;
            int inner_label_width        = 100;
            int inner_label_vertical_top = 30;

            //----------------------Preparing testing data
            QRPage.PageNumberLoc  = new Point(300, 950);
            QRPage.PageNumberFont = new Font("Times New Roman", 14, FontStyle.Bold);

            //Create an array of QR Label information
            QRLabel[] infos = new QRLabel[total];
            for (int i = 0; i < total; i++)
            {
                infos[i] = new QRLabel();

                //Append mockup QR Image
                infos[i].qrImg = new QRImage(new Point(10, 10),
                                             (Bitmap)System.Drawing.Image.FromFile(Environment.CurrentDirectory + @"\..\..\imgs\26.gif"));

                //Append logo image
                infos[i].logoImg = new QRImage(new Point(160, 120), 100, 46,
                                               (Bitmap)System.Drawing.Image.FromFile(Environment.CurrentDirectory + QRPageCreator.JNJLogo_GIF));

                //Create Labels
                QRInnerLabel[] labels = new QRInnerLabel[txtPerQRLabel];

                labels[0] = new QRInnerLabel(
                    "LOC: XXX",
                    Color.Black, new Font("Times New Roman", 10, FontStyle.Bold),
                    new Point(inner_label_left, 0 * inner_label_height + inner_label_vertical_top), inner_label_width, inner_label_height);
                labels[1] = new QRInnerLabel(
                    System.DateTime.Now.ToLocalTime().ToShortTimeString(),
                    Color.Black, new Font("Times New Roman", 8, FontStyle.Regular),
                    new Point(inner_label_left, 1 * inner_label_height + inner_label_vertical_top), inner_label_width, inner_label_height);
                labels[2] = new QRInnerLabel(
                    "QR CODE: XXX",
                    Color.Black, new Font("Times New Roman", 8, FontStyle.Regular),
                    new Point(inner_label_left, 2 * inner_label_height + inner_label_vertical_top), inner_label_width, inner_label_height);

                infos[i].innerLabels = labels;

                //Define top left of QR Label
                infos[i].loc = new Point(10, qrLocIndex * (192 + 20) + 50);
                if (qrLocIndex >= labelPerPage - 1)
                {
                    qrLocIndex = qrLocIndex - labelPerPage;
                }
                qrLocIndex++;
            }

            //Create a mock up page layout template
            QRPageLayoutTemplate pageLayoutTempl = new QRPageLayoutTemplate();

            pageLayoutTempl.capacity = labelPerPage;

            //----------------------Test Function
            QRPageCreator qrPageGen = new QRPageCreator();

            qrPageGen.qrLabels = infos;
            List <QRPage> pages = qrPageGen.generateLabelPages();

            outputPages(pages);
        }