コード例 #1
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;
            }
        }
コード例 #2
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;
            }
        }
コード例 #3
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;
            }
        }