Example #1
0
        private void CheckPrinterStatus(LabelPrinter printer, ref int error, ref String message)
        {
            int iStatus = 0;


            {
                message += "Printer Status\r\n";

                iStatus  = printer.GetCommandInterpreterInAction();
                message += " " + iStatus.ToString() + ": Command interpreter in action" + "\r\n";
                error   += iStatus;

                iStatus  = printer.GetPaperError();
                message += " " + iStatus.ToString() + ": Paper error" + "\r\n";
                error   += iStatus;

                iStatus  = printer.GetRibbonEnd();
                message += " " + iStatus.ToString() + ": Ribbon end" + "\r\n";
                error   += iStatus;

                iStatus  = printer.GetBatchProcessing();
                message += " " + iStatus.ToString() + ": Batch processing" + "\r\n";
                error   += iStatus;

                iStatus  = printer.GetPrinting();
                message += " " + iStatus.ToString() + ": Printing" + "\r\n";
                error   += iStatus;

                iStatus  = printer.GetPause();
                message += " " + iStatus.ToString() + ": Pause" + "\r\n";
                error   += iStatus;

                iStatus  = printer.GetWaitingForPeeling();
                message += " " + iStatus.ToString() + ": Waiting for peeling" + "\r\n";
                error   += iStatus;
            }
        }
Example #2
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            String statusMessage = "";
            int    errorCode     = 0;
            int    resultCode    = LabelConst.CLS_SUCCESS;
            int    type          = (int)connectType.SelectedValue;

            if (lstPrinters.SelectedItems.Count <= 0)
            {
                MessageBox.Show("No printer is selected.", "Error");
                return;
            }

            LabelPrinter printer = new LabelPrinter();



            resultCode = printer.Connect(type, lstPrinters.Items[0].Text);
            printer.SetLog(1, "C:\\Users\\bukha\\Desktop\\Logs", 10);

            if (resultCode != LabelConst.CLS_SUCCESS)
            {
                this.PrinterErrorProc(printer, eErrorKind.eErrConnect, resultCode, null);
                return;
            }

            resultCode = printer.PrinterCheck();
            if (resultCode != LabelConst.CLS_SUCCESS)
            {
                this.PrinterErrorProc(printer, eErrorKind.eErrPrinterCheck, resultCode, null);
                printer.Disconnect();
                return;
            }

            statusMessage = "";

            this.CheckPrinterStatus(printer, ref errorCode, ref statusMessage);

            if (errorCode != 0)
            {
                this.PrinterErrorProc(printer, eErrorKind.eErrPrinterStatus, 0, statusMessage);
                printer.Disconnect();
                return;
            }

            printer.SetMeasurementUnit(LabelConst.CLS_UNIT_INCH);
            LabelDesign design = new LabelDesign();

            this.DesignLabel(design);

            resultCode = printer.Print(design, 3);

            if (resultCode != LabelConst.CLS_SUCCESS)
            {
                this.PrinterErrorProc(printer, eErrorKind.eErrPrint, resultCode, null);
                printer.Disconnect();
                return;
            }
            System.Threading.Thread.Sleep(500);

            while (true)
            {
                resultCode = printer.PrinterCheck();
                if (resultCode != LabelConst.CLS_SUCCESS)
                {
                    this.PrinterErrorProc(printer, eErrorKind.eErrPrinterCheck, resultCode, null);
                    printer.Disconnect();
                    return;
                }
                if (printer.GetPrinting() == 0 & printer.GetBatchProcessing() == 0)
                {
                    break;
                }
            }

            statusMessage = "";
            this.CheckPrinterStatus(printer, ref errorCode, ref statusMessage);
            if (errorCode != 0)
            {
                this.PrinterErrorProc(printer, eErrorKind.eErrPrinterStatus, 0, statusMessage);
            }
            else
            {
                MessageBox.Show("Success", "Print Result");
            }
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Create an instance( LabelPrinter class )
            LabelPrinter printer = new LabelPrinter();

            // Get Type
            int type = (int)comboBox1.SelectedValue;

            // Get Address
            String addr = txt_Address.Text;

            // Set COMM Properties( COMM only )
            if (LabelConst.CLS_PORT_COM == type)
            {
                printer.SetCommProperties(LabelConst.CLS_COM_BAUDRATE_9600, LabelConst.CLS_COM_PARITY_NONE, LabelConst.CLS_COM_HANDSHAKE_DTRDSR);
            }

            // Connect printer
            int result = printer.Connect(type, addr);

            if (LabelConst.CLS_SUCCESS == result)
            {
                // Printer Check
                result = printer.PrinterCheck();

                // Disconnect
                printer.Disconnect();

                if (LabelConst.CLS_SUCCESS == result)
                {
                    String msg = "PrinterCheck() : Success\n";

                    // CommandInterpreterInAction
                    int status = printer.GetCommandInterpreterInAction();
                    msg += "\n CommandInterpreterInAction -> " + status;

                    // PaperError
                    status = printer.GetPaperError();
                    msg   += "\n PaperError -> " + status;

                    // RibbonEnd
                    status = printer.GetRibbonEnd();
                    msg   += "\n RibbonEnd -> " + status;

                    // BatchProcessing
                    status = printer.GetBatchProcessing();
                    msg   += "\n BatchProcessing -> " + status;

                    // Printing
                    status = printer.GetPrinting();
                    msg   += "\n Printing -> " + status;

                    // Pause
                    status = printer.GetPause();
                    msg   += "\n Pause -> " + status;

                    // WaitingForPeeling
                    status = printer.GetWaitingForPeeling();
                    msg   += "\n WaitingForPeeling -> " + status;

                    // PrintHeadLowTemp
                    status = printer.GetPrintHeadLowTemp();
                    msg   += "\n PrintHeadLowTemp -> " + status;

                    // PrintHeadFailure
                    status = printer.GetPrintHeadFailure();
                    msg   += "\n PrintHeadFailure -> " + status;

                    // PrintHeadOverheat
                    status = printer.GetPrintHeadOverheat();
                    msg   += "\n PrintHeadOverheat -> " + status;

                    // MechanismOpen
                    status = printer.GetMechanismOpen();
                    msg   += "\n MechanismOpen -> " + status;

                    // AutoCutterError
                    status = printer.GetAutoCutterError();
                    msg   += "\n AutoCutterError -> " + status;

                    // FanMotorError
                    status = printer.GetFanMotorError();
                    msg   += "\n FanMotorError -> " + status;

                    // MiscError
                    status = printer.GetMiscError();
                    msg   += "\n MiscError -> " + status;


                    // Show Status
                    MessageBox.Show(msg, "Citizen_Label_sample", MessageBoxButtons.OK, MessageBoxIcon.None);
                }
                else
                {
                    // Printer Check Error
                    MessageBox.Show("PrinterCheck Error : " + result.ToString(), "Citizen_Label_sample", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                // Connect Error
                MessageBox.Show("Connect Error : " + result.ToString(), "Citizen_Label_sample", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }