Esempio n. 1
0
        /**************************************************************************************************
         * Function Name: frmMain
         *
         * Purpose: Class constructor
         *
         * Parameters: None
         *
         * Returns: None
         *
         * History:
         * Date             Who             Comment
         * 12/8/2010        ACT             Function creation.
         * 12/9/2010        ACT             Added initialization of printer & graphics class objects
         * 01/28/2011       ACT             Renamed Smartcard encoding framework object to _SCEncodeEthernet
         ***************************************************************************************************/
        public frmMain()
        {
            InitializeComponent();

            _thePrinterSDK  = new ZBRPrinter();
            _theGraphicsSDK = new ZBRGraphics();
        }
        // Form Load Event ----------------------------------------------------------------------------------

        private void frmMain_Load(object sender, EventArgs e)
        {
            _thePrinterSDK = new ZBRPrinter();
            LocatePrinters();
            cboPrn.Focus();

            //GetSDKVersions();
            //FormConfig();
        }
Esempio n. 3
0
        /**************************************************************************************************
         * Function Name: btnExit_Click
         *
         * Purpose: Event handler for Exit button click event, program cleanup, & signal application to exit.
         *
         * Parameters: sender = object which caused the event to be called
         *                  e = arguments related to the event
         *
         * Returns: None
         *
         * History:
         * Date             Who             Comment
         * 12/8/2010        ACT             Function creation.
         * 01/28/2011       ACT             Renamed Smartcard encoding framework object to _SCEncodeEthernet
         ***************************************************************************************************/
        private void btnExit_Click(object sender, EventArgs e)
        {
            _thePrinterSDK  = null;
            _theGraphicsSDK = null;

            Dispose(true);

            Application.Exit();
        }
Esempio n. 4
0
        /**************************************************************************************************
         * Function Name: GetPrinterIPAddress
         *
         * Purpose: Retrieves the IP Address for the selected ethernet-connected printer.,
         *
         * Parameters: driverName = string containing name of selected printer
         *                 IPAddr = string to hold the selected printer's IP Address
         *
         * Returns: None
         *
         * History:
         * Date             Who             Comment
         * 12/10/2010       ACT             Function creation.
         * 12/29/2010       ACT             Added using SDK GetIPAddress function.
         ***************************************************************************************************/
        private static void GetPrinterIPAddress(string driverName, ref string IPAddr)
        {
            ZBRPrinter prn = null;

            try
            {
                string errMsg = string.Empty;

                prn = new ZBRPrinter();
                prn.GetIPAddress(driverName, out IPAddr);
            }
            catch (Exception ex)
            {
                IPAddr = string.Empty;
                MessageBox.Show("GetPrinterIPAddress threw exception: " + ex.Message);
            }
            finally
            {
                prn = null;
            }
        }
Esempio n. 5
0
        // Gets the DLL version for the SDK -----------------------------------------------------------------
        public string GetSDKVersion()
        {
            ZBRPrinter prn = null;

            string version = "";

            try
            {
                prn = new ZBRPrinter();

                version = prn.GetPrinterSDKVersion();
            }
            catch (Exception ex)
            {
                version = ex.ToString();
            }
            finally
            {
                prn = null;
            }
            return(version);
        }
Esempio n. 6
0
        // Class Initialization

        public SampleCodeMag()
        {
            _thePrinterSDK = new ZBRPrinter();
        }
Esempio n. 7
0
        // CONTACT Sample Code ----------------------------------------------------------------------------------

        public void ContactEncode(string drvName, string _contactReader, int eject, out string msg)
        {
            ZBRPrinter printer  = null;
            int        errValue = 0;

            msg = "";
            try
            {
                printer = new ZBRPrinter();

                // Opens a connection to a printer driver
                if (!printer.Open(drvName, out msg))
                {
                    msg = "CONTACT Open Error: " + ZBRUtil.TranslateErrorCode(errValue) + "\n" + "Error Code : " + errValue.ToString();
                    return;
                }

                // Moves the card into position for encoding
                if (printer.MoveCardToSmartCardEncoder(CONTACT, out errValue) == 0)
                {
                    msg = "CONTACT StartCard Error:" + ZBRUtil.TranslateErrorCode(errValue) + "\n" + "Error Code : " + errValue.ToString();
                    return;
                }

                byte[] key = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };


                //perform the smart card encoding:
                ContactSupport contact  = new ContactSupport();
                string         cardType = "PVC,SLE4428";
                contact.ContactTest(ref cardType, _contactReader, key, true, out msg);

                if (msg.Length > 0)
                {
                    return;
                }

                if (printer.MoveSmartCardToPrintReadyPosition(CONTACT, out errValue) == 0)
                {
                    msg = "CONTACT Prnt Card Error: " + errValue.ToString();
                    return;
                }

                if (printer.EjectCard(out errValue) == 0)
                {
                    msg = "CONTACT Eject Card Error: " + errValue.ToString();
                    return;
                }
            }
            catch (Exception ex)
            {
                msg += ex.Message;
                System.Windows.Forms.MessageBox.Show(ex.ToString(), "CONTACTCode threw exception");
            }
            finally
            {
                if (printer != null)
                {
                    printer.EjectCard(out errValue);
                    if (msg.Length == 0)
                    {
                        printer.Close(out msg);
                    }
                    else
                    {
                        string tempmsg = "";
                        printer.Close(out tempmsg);
                    }
                    printer = null;
                }
            }
        }