Exemplo n.º 1
0
        private void PerformPrintTest(ref ZXPSampleCode zxp, string test, string cardType)
        {
            try
            {
                lbJobStatus.Visible = true;
                lbJobStatus.Text    = "Waiting for " + test + " to complete";
                Refresh();
                Application.DoEvents();

                switch (test)
                {
                case "Inhibit Print":
                    zxp.Perform_Inhibit_Panel_Print(cardType);
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PerformPrintTest exception: " + ex.Message);
            }
            finally
            {
                lbJobStatus.Text = "Job Result = " + zxp.Msg;
            }
        }
Exemplo n.º 2
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            ZXPSampleCode zxp = null;

            try
            {
                zxp = new ZXPSampleCode(this.cboPrn.Text);

                btnRun.Enabled = false;

                // Sets the card type
                //zxp.CardType = this.cboCardType.Text;

                lbStatus.Text    = "Active Job: Monochrome Print";
                lbStatus.Visible = true;
                Refresh();
                Application.DoEvents();

                // Runs the specified sample code
                PerformPrintTest(ref zxp, "Inhibit Print", cboCardType.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("btnRun_Click threw exception: " + ex.Message);
            }
            finally
            {
                zxp              = null;
                btnRun.Enabled   = true;
                lbStatus.Visible = false;
                Refresh();
                Application.DoEvents();
            }
        }
Exemplo n.º 3
0
 private void DisconnectFromPrinter(ref ZXPSampleCode z, ref Job job)
 {
     try
     {
         z.Disconnect(ref job);
     }
     catch (Exception ex)
     {
         MessageBox.Show("DisconnectFromPrinter threw exception: " + ex.Message);
     }
 }
Exemplo n.º 4
0
        // Initializes the printer selection combo box
        //     based on printer discovery from GetDeviceList
        // --------------------------------------------------------------------------------------------------

        private bool cboPrnInit(bool usb)
        {
            Cursor.Current = Cursors.WaitCursor;

            this.cboPrn.Text = string.Empty;
            this.cboPrn.Items.Clear();
            this.cboPrn.Refresh();

            ZXPSampleCode z    = null;
            bool          bRet = true;

            try
            {
                if (!string.IsNullOrEmpty(cboPrn.Text))
                {
                    return(true);
                }
                else //search for printers
                {
                    z = new ZXPSampleCode();
                    //----------------------------------------------------------------------------------------------------
                    //note: pass true for searching for usb-connected printers, false to search for ethernet printers
                    //for ethernert printers, only those printers on the same subnet as the sample application will be
                    //located
                    //----------------------------------------------------------------------------------------------------
                    z.GetDeviceList(usb);
                    if (z.DeviceList != null)
                    {
                        Array array = (Array)z.DeviceList;

                        for (int i = 0; i < array.GetLength(0); i++)
                        {
                            this.cboPrn.Items.Add((string)array.GetValue(i));
                        }

                        this.cboPrn.Text = (string)array.GetValue(0);
                    }
                    else
                    {
                        bRet = false;
                    }
                }
            }
            catch
            {
                bRet = false;
            }
            finally
            {
                z = null;
                Cursor.Current = Cursors.Default;
            }
            return(bRet);
        }
Exemplo n.º 5
0
        private void btnLocatePrinters_Click(object sender, EventArgs e)
        {
            ZXPSampleCode z = null;

            try
            {
                Cursor = Cursors.WaitCursor;

                lbStatus.Visible = true;
                lbJobStatus.Text = "Searching for printers";
                Refresh();
                Application.DoEvents();

                // Get a list of ZXP devices
                if (cboPrnInit(rbUSB.Checked))
                {
                    // Displays versions
                    z = new ZXPSampleCode(this.cboPrn.Text);
                    this.lblVersions.Text = z.GetVersions();

                    if (!z.IsZXP7)
                    {
                        // Loads card types based on type of sample type
                        _cardTypeList = new ArrayList();

                        CardTypesInit(ref z, this.cboPrn.Text);

                        cboCardTypeInit();
                    }
                    else
                    {
                        cboCardType.Enabled = false;
                    }
                }
                else //do not close the program
                {
                    string temp = rbUSB.Checked ? " USB" : " Ethernet";
                    MessageBox.Show("Could not locate a ZXP Printer via " + temp, "Warning");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("btnLocatePrinters_Click exception: " + ex.Message);
            }
            finally
            {
                z = null;
                lbStatus.Visible = false;
                Cursor           = Cursors.Default;
            }
        }
Exemplo n.º 6
0
        private void SetDestinations(ref ZXPSampleCode zxp, string source, string destination)
        {
            try
            {
                // Sets the card source location
                switch (source)
                {
                case "ATM Slot":
                    zxp.Feeder = FeederSourceEnum.ATMSlot;
                    break;

                case "Internal":
                    zxp.Feeder = FeederSourceEnum.Internal;
                    break;

                default:
                    zxp.Feeder = FeederSourceEnum.CardFeeder;
                    break;
                }

                // Sets the card destination location
                switch (destination)
                {
                case "Feeder":
                    zxp.Destination = DestinationTypeEnum.Feeder;
                    break;

                case "Hold":
                    zxp.Destination = DestinationTypeEnum.Hold;
                    break;

                case "Reject Bin":
                    zxp.Destination = DestinationTypeEnum.Reject;
                    break;

                default:
                    zxp.Destination = DestinationTypeEnum.Eject;
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SetDestinations threw exception: " + ex.Message);
            }
        }
Exemplo n.º 7
0
        // Builds the _cardTypes ArrayList
        //     from the selected printer
        // --------------------------------------------------------------------------------------------------
        private int CardTypesInit(ref ZXPSampleCode z, string deviceName)
        {
            Job job = null;

            try
            {
                _cardTypeList.Clear();

                job = new Job();

                if (!ConnectToPrinter(ref z, ref job, deviceName))
                {
                    return(0);
                }

                z.GetCardTypeList(ref job);
                if (z.CardTypeList != null)
                {
                    Array array = (Array)z.CardTypeList;
                    for (int i = 0; i < array.GetLength(0); i++)
                    {
                        _cardTypeList.Add((string)array.GetValue(i));
                    }
                }
                else
                {
                    MessageBox.Show("No ZMotif devices found");
                    this.Refresh();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("cboCardTypeInit Exception: " + e.Message);
            }
            finally
            {
                DisconnectFromPrinter(ref z, ref job);
                job = null;
            }
            return(_cardTypeList.Count);
        }
Exemplo n.º 8
0
        private void frmMain_Shown(object sender, EventArgs e)
        {
            ZXPSampleCode z = null;

            try
            {
                // Get a list of USB ZXP devices
                if (cboPrnInit(true))
                {
                    // Displays versions
                    z = new ZXPSampleCode(this.cboPrn.Text);
                    this.lblVersions.Text = z.GetVersions();

                    if (!z.IsZXP7)
                    {
                        // Loads card types based on type of sample type
                        _cardTypeList = new ArrayList();

                        CardTypesInit(ref z, this.cboPrn.Text);

                        cboCardTypeInit();
                    }
                    else
                    {
                        cboCardType.Enabled = false;
                    }
                }
                else //do not close the program
                {
                    MessageBox.Show("Could not locate a ZXP Printer on USB ports", "Warning");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmMain_Load threw exception: " + ex.Message);
            }
            finally
            {
                z = null;
            }
        }
Exemplo n.º 9
0
        private bool ConnectToPrinter(ref ZXPSampleCode z, ref Job job, string deviceName)
        {
            try
            {
                if (!z.Connect(ref job))
                {
                    Cursor.Current = Cursors.Default;

                    MessageBox.Show("Unable to open device [" + deviceName + "]");

                    DisconnectFromPrinter(ref z, ref job);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("ConnectToPrinter threw exception: " + ex.Message);
            }
            return(false);
        }
Exemplo n.º 10
0
        private void btnConnectToPrinter_Click(object sender, EventArgs e)
        {
            ZXPSampleCode z   = null;
            Job           job = null;

            try
            {
                Cursor = Cursors.WaitCursor;

                btnRun.Enabled = false;

                lbStatus.Visible = true;
                lbStatus.Text    = "Connecting to printer";
                Refresh();
                Application.DoEvents();

                job = new Job();

                z = new ZXPSampleCode(this.cboPrn.Text);

                if (z.Connect(ref job))
                {
                    // Displays versions
                    this.lblVersions.Text = z.GetVersions();

                    if (!z.IsZXP7)
                    {
                        // Loads card types based on type of sample type
                        _cardTypeList = new ArrayList();

                        CardTypesInit(ref z, this.cboPrn.Text);

                        cboCardTypeInit();
                    }
                    else
                    {
                        cboCardType.Enabled = false;
                    }

                    btnRun.Enabled = true;
                }
                else
                {
                    MessageBox.Show("Could not open connection to printer " + cboPrn.Text, "Warning");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("btnConnectToPrinter_Click exception: " + ex.Message);
            }
            finally
            {
                if (z != null)
                {
                    z.Disconnect(ref job);
                }
                z = null;
                lbStatus.Visible = false;
                Cursor           = Cursors.Default;
            }
        }