Exemplo n.º 1
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);
            }
        }